/* ============================================
   NameSilo Support Training - Styles
   ============================================ */

:root {
    /* Colors */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252540;
    --bg-card: #1e1e35;
    
    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;
    
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --easy: #22c55e;
    --medium: #f59e0b;
    --hard: #ef4444;
    
    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ============================================
   Container & Layout
   ============================================ */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px;
}

/* ============================================
   Header
   ============================================ */

.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ============================================
   Stats Bar
   ============================================ */

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 32px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--bg-tertiary);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-secondary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Difficulty Tabs
   ============================================ */

.difficulty-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
}

.tab {
    padding: 10px 24px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab.active {
    background: var(--accent-primary);
    color: white;
}

/* ============================================
   Tests Grid
   ============================================ */

.tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.test-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--bg-tertiary);
    transition: var(--transition-normal);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.test-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: var(--transition-normal);
}

.test-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg);
}

.test-card:hover::before {
    opacity: 1;
}

.test-card.completed {
    border-color: var(--success);
}

.test-card.completed::before {
    background: var(--success);
    opacity: 1;
}

.test-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.test-number {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.test-difficulty {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.test-difficulty.easy {
    background: rgba(34, 197, 94, 0.15);
    color: var(--easy);
}

.test-difficulty.medium {
    background: rgba(245, 158, 11, 0.15);
    color: var(--medium);
}

.test-difficulty.hard {
    background: rgba(239, 68, 68, 0.15);
    color: var(--hard);
}

.test-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.test-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.test-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.test-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.completed-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--success);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* ============================================
   Admin Link
   ============================================ */

.admin-link {
    display: block;
    text-align: center;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-fast);
}

.admin-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ============================================
   Chat Page
   ============================================ */

.chat-page {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #151528 100%);
}

.chat-container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    max-height: 900px;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--bg-tertiary);
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--bg-tertiary);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.back-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.customer-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.customer-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.customer-details {
    display: flex;
    flex-direction: column;
}

.customer-name {
    font-weight: 600;
    font-size: 1rem;
}

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

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.timer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.timer-icon {
    font-size: 1.1rem;
}

.timer-value {
    font-family: 'SF Mono', 'Monaco', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-secondary);
}

.test-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.test-name {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ============================================
   Chat Messages
   ============================================ */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.customer {
    background: var(--bg-tertiary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.agent {
    background: var(--accent-primary);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    display: block;
}

.message.agent .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* ============================================
   Typing Indicator
   ============================================ */

.typing-indicator {
    display: none;
    padding: 12px 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.typing-indicator.visible {
    display: block;
}

.customer-name-typing {
    color: var(--text-secondary);
    font-weight: 500;
}

.dots span {
    animation: blink 1.4s infinite both;
}

.dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0%, 80%, 100% {
        opacity: 0;
    }
    40% {
        opacity: 1;
    }
}

/* ============================================
   Chat Input
   ============================================ */

.chat-input-form {
    padding: 16px 24px 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--bg-tertiary);
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#agentInput {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    min-height: 50px;
    max-height: 150px;
    transition: var(--transition-fast);
}

#agentInput:focus {
    outline: none;
    border-color: var(--accent-primary);
}

#agentInput:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn {
    width: 50px;
    height: 50px;
    border: none;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-hint {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* ============================================
   Completion Modal
   ============================================ */

.completion-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.completion-modal.visible {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: var(--radius-xl);
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--bg-tertiary);
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
}

.completion-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 32px;
}

.completion-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.completion-stat .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.completion-stat .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-secondary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* ============================================
   Admin Page
   ============================================ */

.admin-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #151528 100%);
}

.admin-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 24px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.admin-header-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.admin-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.admin-stat-card {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--bg-tertiary);
}

.admin-stat-icon {
    font-size: 2rem;
}

.admin-stat-info {
    display: flex;
    flex-direction: column;
}

.admin-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-secondary);
}

.admin-stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.transcripts-section h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
}

.transcripts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--bg-tertiary);
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 16px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.transcript-card {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--bg-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-fast);
}

.transcript-card:hover {
    border-color: var(--accent-primary);
}

.transcript-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.transcript-title {
    font-weight: 600;
}

.transcript-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
}

.transcript-actions {
    display: flex;
    gap: 8px;
}

/* ============================================
   Transcript Modal
   ============================================ */

.transcript-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
}

.transcript-modal.visible {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
}

.transcript-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.modal-header h2 {
    font-size: 1.2rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-meta {
    display: flex;
    gap: 24px;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.transcript-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
    padding: 20px;
    border-radius: var(--radius-md);
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.8;
    white-space: pre-wrap;
    max-height: 400px;
}

.transcript-content .customer-line {
    color: var(--warning);
}

.transcript-content .agent-line {
    color: var(--success);
}

/* ============================================
   Toast
   ============================================ */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--success);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 200;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ============================================
   Scrollbar
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .stats-bar {
        flex-wrap: wrap;
        gap: 20px;
    }
    
    .tests-grid {
        grid-template-columns: 1fr;
    }
    
    .chat-container {
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }
    
    .chat-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .chat-header-left,
    .chat-header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .admin-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
}
