/* ============================================================================
   VIRTUAL TEACHER - MAIN STYLES
   Production-ready, responsive, accessible
   ============================================================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
    --bg-main: #ffffff;
    --bg-alt: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-main);
    min-height: 100vh;
}

/* ============================================================================
   LAYOUT
   ============================================================================ */

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

header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--radius-lg);
    margin-bottom: 40px;
    box-shadow: var(--shadow-lg);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header .tagline {
    font-size: 1.1rem;
    opacity: 0.9;
}

footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #475569;
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.1rem;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-full {
    width: 100%;
}

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

/* ============================================================================
   FORMS
   ============================================================================ */

.input-field, .answer-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
}

.input-field:focus, .answer-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.input-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.input-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

textarea.input-field {
    resize: vertical;
    min-height: 100px;
}

/* ============================================================================
   CARDS & CONTAINERS
   ============================================================================ */

.role-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

.role-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

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

.role-card .icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.role-card h2 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

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

/* ============================================================================
   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-content {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-content h2 {
    margin-bottom: 24px;
}

.modal .close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

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

.link-text {
    text-align: center;
    margin-top: 16px;
    color: var(--text-secondary);
}

.link-text a {
    color: var(--primary);
    text-decoration: none;
}

.link-text a:hover {
    text-decoration: underline;
}

/* ============================================================================
   MESSAGES & FEEDBACK
   ============================================================================ */

.error-message, .status-message {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-top: 16px;
    font-size: 0.95rem;
}

.error-message, .status-message.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.status-message.success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.status-message.info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

.status-message.warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-primary);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.placeholder {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 20px;
    font-size: 1.1rem;
}

.hidden {
    display: none !important;
}

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

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .role-selector {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        padding: 24px;
    }
    
    .btn-large {
        padding: 14px 24px;
        font-size: 1rem;
    }
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

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

.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border: #000000;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Logout link on completion screen */
.logout-link {
    margin-top: 20px;
    text-align: center;
}

.logout-link a {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
}

.logout-link a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* Topic selection header with student info */
.topic-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.topic-header h2 {
    margin: 0;
}

/* Two column form row for topic selection */
.form-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 600px) {
    .form-row-2col {
        grid-template-columns: 1fr;
    }
}

.student-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.switch-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.8rem;
}

.switch-link:hover {
    text-decoration: underline;
}

/* ============================================================================
   MARKDOWN TABLES
   ============================================================================ */

.table-wrapper {
    overflow-x: auto;
    margin: 16px 0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.markdown-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    font-size: 0.95rem;
    min-width: 300px;
}

.markdown-table th,
.markdown-table td {
    padding: 12px 16px;
    text-align: left;
    border: 1px solid var(--border);
    vertical-align: top;
}

.markdown-table th {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    font-weight: 600;
}

.markdown-table tbody tr:nth-child(even) {
    background: var(--bg-alt);
}

.markdown-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.05);
}

.markdown-table td strong {
    color: var(--primary);
}

/* First column styling */
.markdown-table td:first-child {
    font-weight: 500;
}

/* Responsive table */
@media (max-width: 600px) {
    .markdown-table {
        font-size: 0.85rem;
    }
    
    .markdown-table th,
    .markdown-table td {
        padding: 8px 10px;
    }
}
