/* Sales Training Agent - Main Stylesheet */
/* RTL Arabic Support with Saudi Dialect */

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f9fafb;
    --surface: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.8;
    direction: rtl;
    text-align: right;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
#header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-left i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger-color);
}

.status.connected .status-dot {
    background: var(--success-color);
}

/* Main Content */
#main-content {
    flex: 1;
    padding: 2rem;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Setup View */
#setup-view {
    display: none;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

#setup-view.active {
    display: grid;
}

.setup-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.setup-container h2 {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.setup-container h2 i {
    color: var(--primary-color);
}

.setup-section {
    margin-bottom: 2rem;
}

.setup-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.scenario-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.selection-card {
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface);
}

.selection-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.selection-card.selected {
    border-color: var(--primary-color);
    background: #f0f0ff;
}

.selection-card .card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.selection-card .card-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
}

.selection-card .card-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.selection-card .card-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.difficulty-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.difficulty-badge.easy {
    background: #d1fae5;
    color: #065f46;
}

.difficulty-badge.medium {
    background: #fef3c7;
    color: #92400e;
}

.difficulty-badge.hard {
    background: #fee2e2;
    color: #991b1b;
}

.start-section {
    text-align: center;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}

.help-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Buttons */
.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.primary-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

.primary-btn:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.6;
}

.secondary-btn {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.secondary-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* History Sidebar */
.history-sidebar {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.history-sidebar h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.history-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--primary-color);
}

.history-item .date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.history-item .persona {
    font-weight: 500;
    margin: 0.25rem 0;
}

.history-item .score {
    font-size: 0.875rem;
    color: var(--primary-color);
    font-weight: 600;
}

/* Call View */
#call-view.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
}

.call-container {
    display: grid;
    grid-template-columns: 250px 1fr 300px;
    gap: 1.5rem;
    flex: 1;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.persona-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.persona-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.persona-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2rem;
    color: white;
}

.persona-traits h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.persona-traits ul {
    list-style: none;
    font-size: 0.85rem;
}

.persona-traits li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.call-timer {
    text-align: center;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius);
    font-size: 1.5rem;
    font-weight: 600;
}

.call-timer i {
    margin-left: 0.5rem;
}

/* Chat Panel */
.chat-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.message {
    margin-bottom: 1rem;
    max-width: 80%;
}

.message.user {
    margin-right: auto;
}

.message.ai {
    margin-left: auto;
}

.message-content {
    padding: 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
}

.message.user .message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-left-radius: 4px;
}

.message.ai .message-content {
    background: var(--background);
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.input-area {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.speaking-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    color: var(--primary-color);
}

.speaking-indicator.hidden {
    display: none;
}

.pulse {
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

/* Coaching Panel */
.coaching-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.coaching-panel h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tip-button {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    transition: transform 0.2s;
}

.tip-button:hover {
    transform: scale(1.02);
}

.coaching-tips {
    max-height: 400px;
    overflow-y: auto;
}

.tip-placeholder {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: center;
    padding: 1rem;
}

.coaching-tip {
    padding: 1rem;
    background: #fef3c7;
    border-right: 4px solid var(--warning-color);
    border-radius: var(--radius) 0 0 var(--radius);
    margin-bottom: 1rem;
}

.coaching-tip .tip-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #92400e;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.coaching-tip .tip-text {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.coaching-tip .tip-context {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Call Controls */
.call-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
}

.control-btn {
    padding: 1rem 2rem;
    border-radius: 50px;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.control-btn:not(.end-call) {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.control-btn.end-call {
    background: var(--danger-color);
    color: white;
    padding: 1rem 2.5rem;
}

.control-btn:hover {
    transform: scale(1.05);
}

.control-btn.muted {
    background: var(--danger-color);
    color: white;
}

/* Analysis View */
#analysis-view.active {
    display: block;
}

.analysis-container {
    max-width: 1000px;
    margin: 0 auto;
}

.score-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2rem;
    align-items: center;
}

.overall-score {
    text-align: center;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
}

.score-breakdown {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.score-item {
    display: grid;
    grid-template-columns: 150px 1fr 50px;
    align-items: center;
    gap: 1rem;
}

.score-label {
    font-size: 0.9rem;
    font-weight: 500;
}

.score-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 1s ease-out;
}

.score-value {
    font-weight: 600;
    font-size: 0.9rem;
}

/* Metrics Panel */
.metrics-panel, .highlights-panel, .recommendations-panel, .feedback-panel, .transcript-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.metrics-panel h3, .highlights-panel h3, .recommendations-panel h3, .feedback-panel h3, .transcript-panel h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.metric {
    text-align: center;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius);
}

.metric-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Highlights */
.highlight-item {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    border-right: 4px solid;
}

.highlight-item.positive {
    background: #d1fae5;
    border-color: var(--success-color);
}

.highlight-item.improvement {
    background: #fef3c7;
    border-color: var(--warning-color);
}

.highlight-item.missed_opportunity {
    background: #fee2e2;
    border-color: var(--danger-color);
}

.highlight-item .highlight-type {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.highlight-item .highlight-text {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.highlight-item .highlight-context {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Recommendations */
.recommendations-panel ul {
    list-style: none;
}

.recommendations-panel li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.recommendations-panel li::before {
    content: '\f0a4';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: var(--primary-color);
}

/* Feedback */
.feedback-panel p {
    line-height: 1.8;
    color: var(--text-secondary);
}

/* Transcript */
.transcript-content {
    max-height: 400px;
    overflow-y: auto;
}

.transcript-entry {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.transcript-entry .speaker {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.transcript-entry.user .speaker {
    color: var(--primary-color);
}

.transcript-entry.ai .speaker {
    color: var(--secondary-color);
}

.transcript-entry .text {
    margin-top: 0.25rem;
}

.transcript-entry .timestamp {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Analysis Actions */
.analysis-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.product-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 1200px) {
    .call-container {
        grid-template-columns: 200px 1fr 250px;
    }
}

@media (max-width: 992px) {
    #setup-view.active {
        grid-template-columns: 1fr;
    }

    .history-sidebar {
        order: -1;
    }

    .call-container {
        grid-template-columns: 1fr;
    }

    .persona-panel {
        display: none;
    }

    .coaching-panel {
        position: fixed;
        bottom: 80px;
        right: 1rem;
        width: 300px;
        max-height: 50vh;
        z-index: 100;
    }

    .score-card {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    #header {
        padding: 1rem;
    }

    .header-left h1 {
        font-size: 1rem;
    }

    .selection-grid {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }
}
