/* CoursIA - Modern, Premium Styling */

:root {
    /* Color Palette */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* Subject Colors */
    --math: #f59e0b;
    --french: #ec4899;
    --history: #8b5cf6;
    --svt: #10b981;
    --physics: #3b82f6;
    --english: #ef4444;
    --spanish: #f97316;

    /* Neutrals */
    --bg: #0f172a;
    --bg-light: #1e293b;
    --bg-lighter: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;

    /* Shadows */
    --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);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg) 0%, #1e1b4b 100%);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* Header */
header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: var(--spacing-md) 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.user-progress {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-right: var(--spacing-sm);
}

.header-points {
    font-weight: 700;
    color: var(--warning);
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-level {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-back,
.btn-tutor,
.btn-close {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-lighter);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-light);
}

.btn-back {
    background: transparent;
    color: var(--text-muted);
    padding: var(--spacing-xs) var(--spacing-sm);
}

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

.btn-tutor {
    background: var(--info);
    color: white;
    font-size: 0.9rem;
    padding: var(--spacing-xs) var(--spacing-sm);
}

.btn-close {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.5rem;
    padding: 0;
    width: 2rem;
    height: 2rem;
    justify-content: center;
}

/* Screens */
.screen {
    padding: var(--spacing-xl) 0;
}

/* Welcome Card */
.welcome-card {
    max-width: 500px;
    margin: var(--spacing-xl) auto;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    text-align: center;
    box-shadow: var(--shadow-xl);
}

.welcome-card h2 {
    font-size: 2rem;
    margin-bottom: var(--spacing-sm);
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-card p {
    color: var(--text-muted);
    margin-bottom: var(--spacing-lg);
}

.welcome-card button {
    width: 100%;
    margin-bottom: var(--spacing-sm);
    flex-direction: column;
    padding: var(--spacing-md);
}

.welcome-card button small {
    font-size: 0.85rem;
    font-weight: 400;
    opacity: 0.8;
}

/* Upload Card */
.upload-card {
    background: var(--bg-light);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    text-align: center;
    margin-bottom: var(--spacing-lg);
    transition: all 0.3s ease;
}

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

.upload-card h3 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-xs);
}

.upload-card p {
    color: var(--text-muted);
    margin-bottom: var(--spacing-md);
}

#upload-preview {
    margin-top: var(--spacing-md);
}

#preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
}

#upload-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
}

/* Course Grid */
#courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.course-card {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.course-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

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

.course-card h4 {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-xs);
}

.subject-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.subject-badge.Mathématiques {
    background: var(--math);
    color: white;
}

.subject-badge.Français {
    background: var(--french);
    color: white;
}

.subject-badge.Histoire-Géographie {
    background: var(--history);
    color: white;
}

.subject-badge.SVT {
    background: var(--svt);
    color: white;
}

.subject-badge.Physique-Chimie {
    background: var(--physics);
    color: white;
}

.subject-badge.Anglais {
    background: var(--english);
    color: white;
}

.subject-badge.Espagnol {
    background: var(--spanish);
    color: white;
}

.course-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* QCM Interface */
#question-card {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

#question-text {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
}

#options-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.option {
    background: var(--bg-lighter);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.option:hover {
    border-color: var(--primary);
    background: var(--bg-light);
}

.option.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.option.correct {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.option.incorrect {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

#feedback-card {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

#feedback-card.correct {
    border-color: var(--success);
}

#feedback-card.incorrect {
    border-color: var(--error);
}

#tutor-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

#tutor-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.tutor-message {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    max-width: 80%;
}

.tutor-message.user {
    background: var(--primary);
    margin-left: auto;
}

.tutor-message.assistant {
    background: var(--bg-lighter);
}

.modal-footer {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    border-top: 1px solid var(--border);
}

.modal-footer input {
    flex: 1;
    background: var(--bg-lighter);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--text);
    font-size: 1rem;
}

/* Loading */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    z-index: 2000;
}

/* Responsive */
@media (max-width: 768px) {
    #courses-grid {
        grid-template-columns: 1fr;
    }

    .welcome-card {
        margin: var(--spacing-md);
    }
}

/* Exams Calendar */
.exams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.exam-card {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

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

.exam-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
}

.exam-card.exam-today::before {
    background: var(--error);
}

.exam-card.exam-tomorrow::before {
    background: var(--warning);
}

.exam-card.exam-soon::before {
    background: var(--info);
}

.exam-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.exam-badge {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
}

.exam-badge.ds {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
}

.exam-badge.ie {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.exam-badge.dm {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.exam-badge.brevet {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.exam-subject {
    font-weight: bold;
    margin-left: var(--spacing-sm);
    color: var(--text);
}

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

.exam-title {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-sm);
    color: var(--text);
}

.exam-content-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    background: var(--bg-lighter);
    padding: 8px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-md);
}

.exam-prep-container {
    margin: var(--spacing-md) 0;
}

.exam-prep-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.exam-prep-bar {
    height: 8px;
    background: var(--bg-lighter);
    border-radius: 4px;
    overflow: hidden;
}

.exam-prep-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.5s ease-out;
}

.exam-card-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.revision-suggestion-card {
    background: var(--bg-lighter);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.revision-suggestion-card h4 {
    margin: 0;
    color: var(--primary-light);
}

.revision-suggestion-card p {
    margin: 4px 0 0 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.exam-detail-header {
    margin-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--spacing-md);
}

.exam-detail-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.exam-prep-large {
    margin: var(--spacing-lg) 0;
}

.exam-prep-large .exam-prep-bar {
    height: 12px;
}

.exam-detail-desc {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--bg-lighter);
    border-radius: var(--radius-md);
}

/* Gamification Styles */
.profile-card {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    max-width: 800px;
    margin: 0 auto;
    box-shadow: var(--shadow-xl);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    flex-wrap: wrap;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    box-shadow: var(--shadow-lg);
}

.level-info {
    flex: 1;
}

.level-badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: var(--spacing-xs);
}

.xp-bar-container {
    width: 100%;
    height: 12px;
    background: var(--bg-lighter);
    border-radius: 6px;
    margin-top: var(--spacing-sm);
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(to right, var(--primary-light), var(--secondary));
    width: 0%;
    transition: width 1s ease-out;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.stat-item {
    text-align: center;
    padding: var(--spacing-md);
    background: var(--bg-lighter);
    border-radius: var(--radius-md);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-light);
}

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

.badges-section h3 {
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--spacing-xs);
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--spacing-md);
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    opacity: 0.4;
    filter: grayscale(1);
    transition: all 0.3s ease;
}

.badge-item.earned {
    opacity: 1;
    filter: grayscale(0);
}

.badge-icon-large {
    font-size: 2.5rem;
    margin-bottom: 4px;
}

.badge-name {
    font-size: 0.75rem;
    font-weight: 600;
}

/* Points Animation */
@keyframes pointsFloat {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px);
        opacity: 0;
    }
}

.points-gain {
    position: fixed;
    color: var(--warning);
    font-weight: bold;
    font-size: 1.5rem;
    pointer-events: none;
    animation: pointsFloat 1s forwards;
    z-index: 10000;
}

/* Badge Earned Popup */
.badge-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
}

.badge-popup {
    background: var(--bg-light);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: scaleIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.badge-popup-icon {
    font-size: 5rem;
    margin-bottom: var(--spacing-md);
}