/* ============================================
   RENDTACOPIE - GLOBAL CSS
   Variables, Reset, Composants Réutilisables
   ============================================ */

/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
    /* Fond chaleureux */
    --bg-warm: #3B4455;
    --bg-card: #e5e7eb;
    --bg-white: #FFFFFF;

    /* Couleurs principales */
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #E0E7FF;

    /* Couleurs profils */
    --prof-color: #059669;
    --prof-dark: #047857;
    --prof-light: #D1FAE5;
    --eleve-color: #2563EB;
    --eleve-dark: #1D4ED8;
    --eleve-light: #DBEAFE;

    /* Matières */
    --francais: #8B5CF6;
    --histoire-geo: #F59E0B;
    --emc: #10B981;

    /* Sémantique */
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --info: #3B82F6;
    --info-light: #DBEAFE;

    /* Gris chauds */
    --gray-50: #FAF9F7;
    --gray-100: #F5F3EE;
    --gray-200: #E8E6E1;
    --gray-300: #D5D3CE;
    --gray-400: #A8A5A0;
    --gray-500: #78756F;
    --gray-600: #5C5955;
    --gray-700: #403E3B;
    --gray-800: #2A2826;
    --gray-900: #1A1918;

    /* Ombres douces */
    --shadow-sm: 0 1px 2px rgba(26, 25, 24, 0.04), 0 1px 3px rgba(26, 25, 24, 0.06);
    --shadow-md: 0 4px 6px rgba(26, 25, 24, 0.05), 0 2px 4px rgba(26, 25, 24, 0.06);
    --shadow-lg: 0 10px 25px rgba(26, 25, 24, 0.08), 0 4px 10px rgba(26, 25, 24, 0.06);
    --shadow-xl: 0 20px 40px rgba(26, 25, 24, 0.1), 0 8px 16px rgba(26, 25, 24, 0.06);

    /* Rayons */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* ============================================
   RESET
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-warm);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    background: var(--bg-white);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo, .header-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.logo.prof { color: var(--prof-color); }
.logo.eleve { color: var(--eleve-color); }

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

.header-nav a {
    color: var(--gray-600);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
}

.header-nav a:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.header-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
}

.header-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-links a {
    color: var(--gray-600);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.header-links a:hover { color: var(--primary); }

.header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-user-name {
    font-weight: 500;
    color: var(--gray-700);
}

/* ============================================
   LAYOUT
   ============================================ */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.main.narrow { max-width: 800px; }
.main.wide { max-width: 1400px; }
.main-full { max-width: none; padding: 2rem; }

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    border: 1px solid var(--gray-200);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* ============================================
   BOUTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; }

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

.btn-secondary, .btn-light {
    background: var(--bg-white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-secondary:hover, .btn-light:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #059669; }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #DC2626; }

.btn-prof {
    background: var(--prof-color);
    color: white;
}
.btn-prof:hover { background: var(--prof-dark); }

.btn-eleve {
    background: var(--eleve-color);
    color: white;
}
.btn-eleve:hover { background: var(--eleve-dark); }

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
    box-shadow: none;
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: none;
}

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

/* ============================================
   FORMULAIRES
   ============================================ */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
}

.form-label .required { color: var(--danger); }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-white);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.7;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.form-hint {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success, .badge-free { background: var(--success-light); color: #065F46; }
.badge-warning { background: var(--warning-light); color: #92400E; }
.badge-danger { background: var(--danger-light); color: #991B1B; }
.badge-info { background: var(--info-light); color: #1E40AF; }
.badge-gray { background: var(--gray-200); color: var(--gray-700); }

.badge-easy { background: #FEF3C7; color: #92400E; }
.badge-medium { background: #FED7AA; color: #9A3412; }
.badge-hard { background: #FECACA; color: #991B1B; }
.badge-done { background: var(--primary-light); color: var(--primary); }

/* Credits Badge */
.credits-badge, .credits {
    background: var(--eleve-light);
    color: var(--eleve-color);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.875rem;
}

/* ============================================
   ALERTES / FLASH
   ============================================ */
.alert, .flash, .error {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert-success, .flash-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-error, .alert-danger, .flash-error, .error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-warning, .flash-warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FDE68A;
}

.alert-info, .flash-info {
    background: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

/* ============================================
   TABLES
   ============================================ */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    font-weight: 600;
    color: var(--gray-500);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--gray-50);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover { background: var(--gray-50); }

/* ============================================
   GRIDS
   ============================================ */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

.flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state, .empty {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

.empty-state p { margin-bottom: 1rem; }

/* ============================================
   BREADCRUMB
   ============================================ */
.breadcrumb { margin-bottom: 1.5rem; }
.breadcrumb a {
    color: var(--gray-500);
    text-decoration: none;
    transition: color var(--transition-fast);
}
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span { color: var(--gray-900); }

/* ============================================
   LOADING
   ============================================ */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-overlay.active { display: flex; }

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

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

.loading-text {
    margin-top: 1rem;
    font-weight: 500;
    color: var(--gray-700);
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--gray-500);
    font-size: 0.875rem;
    background: var(--bg-white);
    border-top: 1px solid var(--gray-200);
    margin-top: 3rem;
}

.footer a {
    color: var(--gray-600);
    transition: color var(--transition-fast);
}

.footer a:hover { color: var(--primary); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header-nav {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
    }

    .main { padding: 1rem; }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }

    .table { font-size: 0.875rem; }
    .table th, .table td { padding: 0.75rem 0.5rem; }

    .btn { padding: 0.625rem 1.25rem; }
}
