/**
 * Styles CSS communs pour le site SNT & Techno
 * Système de thème Light/Dark unifié
 */

/* ========================================
   SYSTÈME DE THÈMES - VARIABLES CSS
   ======================================== */

/* LIGHT MODE (défaut) */
:root {
    /* Couleurs de base */
    --bg: #f8fafc;
    --bg-alt: #f1f5f9;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    
    /* Texte */
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    /* Accents */
    --blue: #4f46e5;
    --blue-light: #eef2ff;
    --blue-text: #3730a3;
    --red: #dc2626;
    --red-light: #fef2f2;
    --green: #16a34a;
    --green-light: #f0fdf4;
    --orange: #ea580c;
    --orange-light: #fff7ed;
    
    /* Code */
    --code-bg: #f1f5f9;
    --code-border: #e2e8f0;
    
    /* Ombres */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    
    /* Rayons */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 4px;
    
    /* Navigation */
    --nav-bg: #ffffff;
    --nav-text: #475569;
    --nav-hover: #f1f5f9;
    --nav-accent: #4f46e5;
    
    /* Footer */
    --footer-bg: #f8fafc;
    --footer-border: #e2e8f0;
    
    /* Polices */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}

/* DARK MODE */
[data-theme="dark"] {
    --bg: #0f172a;
    --bg-alt: #1e293b;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --border-strong: #475569;
    
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    
    --blue: #818cf8;
    --blue-light: rgba(99, 102, 241, 0.15);
    --blue-text: #a5b4fc;
    --red: #f87171;
    --red-light: rgba(239, 68, 68, 0.15);
    --green: #4ade80;
    --green-light: rgba(34, 197, 94, 0.15);
    --orange: #fb923c;
    --orange-light: rgba(249, 115, 22, 0.15);
    
    --code-bg: #0f172a;
    --code-border: #334155;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    
    --nav-bg: #1e293b;
    --nav-text: #e2e8f0;
    --nav-hover: #334155;
    --nav-accent: #818cf8;
    
    --footer-bg: #1e293b;
    --footer-border: #334155;
}

/* ========================================
   RESET & BASE
   ======================================== */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

/* Body - ne pas écraser margin pour permettre le centrage des pages */
body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.3s ease, color 0.3s ease;
    /* margin et padding définis par chaque page */
}

/* ========================================
   TYPOGRAPHIE
   ======================================== */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    font-weight: 700;
    line-height: 1.3;
    color: var(--text);
}

h1 {
    font-size: 2rem;
    margin: 1em 0 0.5em;
}

h2 {
    font-size: 1.5rem;
    margin: 1.5em 0 0.5em;
    color: var(--blue);
}

h3 {
    font-size: 1.25rem;
    margin: 1.2em 0 0.4em;
    color: var(--red);
}

h4 {
    font-size: 1.1rem;
    margin: 1em 0 0.4em;
}

p {
    margin: 0.8em 0;
}

a {
    color: var(--blue);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    text-decoration: underline;
}

strong {
    font-weight: 600;
}

/* ========================================
   LISTES
   ======================================== */

ul, ol {
    margin: 0.8em 0 1em 1.5em;
}

li {
    margin: 0.3em 0;
}

/* ========================================
   CODE
   ======================================== */

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--code-bg);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-xs);
    border: 1px solid var(--code-border);
}

pre, .code-block {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: var(--radius-sm);
    padding: 1em;
    overflow-x: auto;
    margin: 1em 0;
}

pre code {
    background: none;
    border: none;
    padding: 0;
}

/* ========================================
   TABLEAUX
   ======================================== */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    background: var(--surface);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-alt);
    font-weight: 600;
    color: var(--text);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--surface-hover);
}

/* ========================================
   ENCADRÉS & ALERTES
   ======================================== */

.info-box {
    background: var(--blue-light);
    border-left: 4px solid var(--blue);
    padding: 1em 1.25em;
    margin: 1.5em 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.info-box h3, .info-box h4 {
    margin-top: 0;
    color: var(--blue);
}

.warning-box, .analogy {
    background: var(--orange-light);
    border-left: 4px solid var(--orange);
    padding: 1em 1.25em;
    margin: 1.5em 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.success-box {
    background: var(--green-light);
    border-left: 4px solid var(--green);
    padding: 1em 1.25em;
    margin: 1.5em 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.error-box {
    background: var(--red-light);
    border-left: 4px solid var(--red);
    padding: 1em 1.25em;
    margin: 1.5em 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ========================================
   DÉTAILS / ACCORDÉON
   ======================================== */

details {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0;
    margin: 1em 0;
    overflow: hidden;
}

summary {
    padding: 1em 1.25em;
    font-weight: 600;
    color: var(--blue);
    cursor: pointer;
    background: var(--bg-alt);
    transition: background 0.2s;
}

summary:hover {
    background: var(--surface-hover);
}

details[open] summary {
    border-bottom: 1px solid var(--border);
}

details > *:not(summary) {
    padding: 0 1.25em;
}

details > *:last-child {
    padding-bottom: 1em;
}

/* ========================================
   QUESTIONS & EXERCICES
   ======================================== */

.question-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0.5em 0;
}

.question-num {
    background: var(--blue-light);
    color: var(--blue);
    padding: 2px 10px;
    border-radius: var(--radius-xs);
    font-weight: 600;
    font-size: 0.9rem;
}

.dots {
    flex: 1;
    border-bottom: 2px dotted var(--border-strong);
    height: 1.2em;
}

.trou {
    display: inline-block;
    min-width: 100px;
    border-bottom: 2px dotted var(--blue);
    margin: 0 4px;
}

/* ========================================
   GRILLES
   ======================================== */

.two-col {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5em;
}

.three-col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5em;
}

@media (max-width: 768px) {
    .two-col, .three-col {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   IMAGES
   ======================================== */

img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

figure {
    margin: 1.5em 0;
    text-align: center;
}

figcaption {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.5em;
}

/* ========================================
   BLOCKQUOTE
   ======================================== */

blockquote {
    margin: 1.5em 0;
    padding: 1em 1.5em;
    border-left: 4px solid var(--border-strong);
    background: var(--bg-alt);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
    color: var(--text-muted);
}

/* ========================================
   SÉPARATEURS
   ======================================== */

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2em 0;
}

/* ========================================
   MISE EN PAGE - NAVBAR PLEINE LARGEUR, CONTENU CENTRÉ
   ======================================== */

/* Ne pas écraser les styles body des pages - ils gèrent leur propre centrage */

/* Conteneur principal centré pour le contenu */
.container, main {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5em;
}

/* Pour les pages de cours avec impression optimisée */
.page-wrapper {
    max-width: 210mm; /* Format A4 */
    margin: 0 auto;
    padding: 10mm 14mm 12mm;
}

@media screen {
    .page-wrapper {
        max-width: 900px;
        padding: 20px 24px;
    }
}

.page-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2em;
    box-shadow: var(--shadow);
    margin-bottom: 2em;
}

/* ========================================
   FOOTER
   ======================================== */

.site-footer {
    background: var(--footer-bg);
    border-top: 1px solid var(--footer-border);
    padding: 2em;
    margin-top: 3em;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.site-footer a {
    color: var(--blue);
}

.footer-content {
    display: flex;
    justify-content: center;
    gap: 2em;
    flex-wrap: wrap;
    max-width: 800px;
    margin: 0 auto;
}

/* ========================================
   UTILITAIRES
   ======================================== */

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.9rem; }
.mt-1 { margin-top: 0.5em; }
.mt-2 { margin-top: 1em; }
.mt-3 { margin-top: 1.5em; }
.mb-1 { margin-bottom: 0.5em; }
.mb-2 { margin-bottom: 1em; }
.mb-3 { margin-bottom: 1.5em; }

/* ========================================
   IMPRESSION
   ======================================== */

@media print {
    body {
        background: white;
        color: black;
        font-size: 12pt;
    }
    
    .page-content {
        box-shadow: none;
        padding: 0;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
    
    .info-box, .warning-box, .success-box, .error-box {
        border: 1px solid #ccc;
        background: #f9f9f9;
    }
    
    table {
        box-shadow: none;
    }
    
    .page {
        page-break-after: always;
    }
    
    .page:last-child {
        page-break-after: auto;
    }
}
