/* Importation des polices */
@import url('https://fonts.googleapis.com/css2?family=Great+Vibes&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Alex+Brush&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;600;700&family=Oswald:wght@400;600;700&display=swap');

/* ═══════════════════════════════════════════════════
   SANDY SHORES MEDICAL CENTER
   ═══════════════════════════════════════════════════ */
:root {
    /* Palette Sandy Shores */
    --magnus-gold:       #e8820c;
    --magnus-gold-light: #f5a030;
    --magnus-gold-dark:  #c06a08;
    --magnus-gold-glow:  rgba(232, 130, 12, 0.35);

    --magnus-dark:  #071525;   /* fond principal — brun-noir */
    --magnus-bg:    #0a1929;   /* fond pages */
    --magnus-card:  #0f2847;   /* cartes */
    --magnus-deep:  #071220;   /* sidebar / plus sombre */
    --magnus-mid:   #0d2137;   /* hover states */
    --magnus-bord:  #1e3a5f;   /* bordures */
    --magnus-bord2: #143050;   /* bordures légères */

    --magnus-text:  #e2e8f0;   /* texte principal warm */
    --magnus-muted: #94a3b8;   /* texte secondaire */
    --magnus-dim:   #475569;   /* texte très atténué */

    --magnus-red:   #8b1a1a;   /* alertes / danger */
    --magnus-red2:  #ef4444;   /* danger vif */

    /* Alias de compatibilité (remplace les var OMC) */
    --omc-dark:     #071525;
    --omc-bg:       #0a1929;
    --omc-card:     #0f2847;
    --magnus-green: #e8820c;
    --bg-preview:   #f0f4f8;
}

[data-theme="dark"] {
    --bg-preview: #040d1a !important;
    --text-preview: #e2e8f0;
}

/* ── Police de base ── */
body {
    font-family: 'Rajdhani', 'Segoe UI', sans-serif !important;
}

h1 { color: var(--magnus-gold) !important; }

/* ── Titres de section avec ligne or ── */
.section-title {
    background: #0f2847 !important;
    border-left: 4px solid var(--magnus-gold) !important;
    color: var(--magnus-gold) !important;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ── Boutons principaux ── */
#print-btn, #discord-btn, .btn-generate {
    background: linear-gradient(135deg, var(--magnus-gold-dark), var(--magnus-gold)) !important;
    color: #071220 !important;
    font-weight: 900 !important;
    letter-spacing: 2px !important;
    text-transform: uppercase !important;
    border-radius: 3px !important;
    border: 1px solid var(--magnus-gold-light) !important;
}

#print-btn:hover, .btn-generate:hover {
    background: linear-gradient(135deg, var(--magnus-gold), var(--magnus-gold-light)) !important;
    box-shadow: 0 0 12px var(--magnus-gold-glow) !important;
}

/* ── Onglets / tabs SSMC ── */
.tab-btn {
    background: var(--magnus-deep) !important;
    color: var(--magnus-gold) !important;
    border-left: 3px solid var(--magnus-bord) !important;
    letter-spacing: 1px !important;
    text-transform: uppercase !important;
    border-radius: 2px !important;
}

.tab-btn:hover, .tab-btn.active {
    border-left-color: var(--magnus-gold) !important;
    background: var(--magnus-mid) !important;
}

/* ── Mode selector ── */
.mode-btn.active {
    background: var(--magnus-gold) !important;
    color: #071220 !important;
    font-weight: 900 !important;
}

/* ── Back link ── */
.back-link { color: var(--magnus-gold) !important; }

/* ── Cards menu principal ── */
.menu-card:hover:not(.locked) {
    border-color: var(--magnus-gold) !important;
    background: var(--magnus-mid) !important;
    box-shadow: 0 4px 20px rgba(232, 130, 12, 0.15) !important;
}

/* ── Autocomplete ── */
.autocomplete-item:hover {
    background: var(--magnus-mid) !important;
    color: var(--magnus-gold) !important;
}

/* ── Tampon médical (QR round-stamp) ── */
.round-stamp {
    border: 2px solid var(--magnus-gold) !important;
    color: var(--magnus-dark) !important;
    background: #f0f4f8 !important;
    border-radius: 8px !important;
    padding: 8px !important;
    text-align: center !important;
}

/* ── Scrollbar SSMC ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--magnus-deep); }
::-webkit-scrollbar-thumb { background: var(--magnus-bord); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--magnus-gold); }

/* ── Inputs SSMC ── */
input:focus, textarea:focus, select:focus {
    border-color: var(--magnus-gold) !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.2) !important;
}

/* ── Cert-tag (étiquette de type de document) ── */
.cert-tag {
    background: var(--magnus-gold) !important;
    color: #071220 !important;
    font-weight: 900 !important;
    letter-spacing: 2px !important;
    border-radius: 2px !important;
}

/* ── Cert main title ── */
.cert-main-title {
    color: var(--magnus-dark) !important;
}

/* ── Header barre latérale de saisie ── */
.sidebar {
    background: var(--magnus-deep) !important;
    border-right: 1px solid var(--magnus-bord) !important;
}

/* ── Preview area ── */
.preview-area, #preview-area {
    background-color: #0d2137 !important;
}

/* ── Section headings ── */
.sidebar-title, h2.sidebar-title {
    color: var(--magnus-gold) !important;
    letter-spacing: 3px !important;
    text-transform: uppercase !important;
    font-family: 'Oswald', 'Rajdhani', sans-serif !important;
}

/* ── Sélection de texte ── */
::selection { background: rgba(232, 130, 12, 0.3); color: #e2e8f0; }

/* ════════════════════════════════════════════════
   MODE CLAIR — SANDY SHORES
   UNIQUEMENT la zone de prévisualisation (droite)
   La sidebar gauche reste sombre en permanence
   ════════════════════════════════════════════════ */

/* Seul le fond derrière les documents change */
body.light-mode .preview-area,
body.light-mode #preview-area {
    background-color: #c8daea !important;
}

/* Protection absolue de la sidebar — rien ne change à gauche */
body.light-mode .sidebar,
body.light-mode .sidebar *,
body.light-mode #input-panel,
body.light-mode #input-panel * {
    /* On ne touche à RIEN ici */
}

[data-theme="dark"] {
    /* Mode Sombre */
    --bg-preview: #071220 !important; /* Bleu nuit profond */
    --text-preview: #f8fafc;
}

body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0; background: var(--omc-bg);
    height: 100vh; display: flex; overflow: hidden;
}

/* Importation de la police Great Vibes via Google Fonts */
.signature-line {
    margin-top: 60px;
    border-top: 2px solid #000; 
    display: inline-block;
    min-width: 250px;
    float: right;
    text-align: right;
    padding-top: 5px;
    clear: both;
    
    /* Typographie style "Stylo fin" */
    font-family: 'Alex Brush', cursive;
    font-size: 30px; /* Taille optimale pour cette police fine */
    font-weight: 400;
    color: #040d1a;
    letter-spacing: 0px;
    
    /* Petit décalage pour ne pas être parfaitement aligné sur la ligne */
    padding-right: 10px;
    transform: rotate(-1.5deg) translateY(-2px);
}

/* Cache les sections et lignes non utilisées */
.section { display: none; }
.section.active { display: block !important; margin-bottom: 20px; }

.row { display: none; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid #eee; }.row.active { 
    display: grid !important; 
    grid-template-columns: 2fr 1fr 1.5fr;
    padding: 5px 10px;
    border-bottom: 1px solid #f0f0f0;
}

.interface-container {
    display: flex !important; /* Force les deux colonnes côte à côte */
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 420px;
    min-width: 420px;
    background-color: #071220; /* Ton bleu sombre habituel */
    padding: 25px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid #040d1a;
}

#input-panel { width: 480px; background: var(--omc-dark); color: white; padding: 25px; overflow-y: auto; border-right: 1px solid #143050; }
.back-link { color: var(--magnus-green); text-decoration: none; font-size: 11px; font-weight: bold; margin-bottom: 15px; display: inline-block; }
.input-group { margin-bottom: 15px; border-bottom: 1px solid #143050; padding-bottom: 10px; }
label { display: block; font-size: 0.8em; font-weight: bold; color: #e2e8f0; margin-bottom: 5px; }
input, textarea, select { width: 100%; padding: 10px; border-radius: 4px; border: 1px solid #143050; background: #071525; color: white; box-sizing: border-box; }
#preview-area, .preview-area { 
    flex-grow: 1; 
    display: block !important;
    flex-direction: column; /* Pour empiler silhouette + feuille */
    align-items: center;
    padding: 40px; 
    overflow-y: auto; 
    background-color: var(--bg-preview) !important; /* Utilise la variable */
    transition: background-color 0.2s ease-in-out;
}

/* Espace entre la signature et les boutons d'action */
.signature-input-group {
    margin-bottom: 25px !important; /* Ajoute l'espace demandé */
}

/* Si tu n'as pas de classe, utilise l'ID du champ */
#doctor-signature {
    margin-bottom: 25px;
}
#document {
    width: 800px !important;
    min-width: 800px !important;
    
    /* HAUTEUR AUTOMATIQUE : S'adapte au contenu */
    height: auto !important;       
    min-height: 500px !important;  /* Juste pour pas qu'il soit minuscule si vide */
    
    background: white !important;
    color: #000 !important;
    
    /* PADDING : On met 60px en bas pour être sûr que la signature respire */
    padding: 40px 40px 60px 40px !important; 
    
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    position: relative;
    box-sizing: border-box;
    overflow: visible !important; /* IMPORTANT pour ne pas couper */
}
#print-btn, #discord-btn { width: 100%; padding: 15px; background: var(--magnus-green); border: none; font-weight: bold; cursor: pointer; margin-top: 12px; border-radius: 5px; }
#discord-btn { background: #5865F2; color: white; }

.btn-print {
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #ccc !important;
    text-transform: uppercase;
    font-size: 11px;
    padding: 10px !important;
    cursor: pointer;
    width: 100%;
    margin-top: 15px;
}

.btn-print:hover {
    background: #f0f0f0 !important;
}
@media print { #input-panel, .back-link, button { display: none !important; } body { display: block !important; } #preview-area { background: white; padding: 0; } #document { box-shadow: none !important; width: 210mm !important; } }




/* =========================================
   VERSION MOBILE (SMARTPHONE & TABLETTE)
   ========================================= */
@media screen and (max-width: 1024px) {

    /* 1. On débloque la hauteur totale */
    body, html {
        height: auto !important;
        overflow-y: auto !important; /* Scroll vertical autorisé partout */
    }

    /* 2. Le conteneur principal empile les blocs */
    .interface-container {
        flex-direction: column !important; /* Haut vers Bas */
        height: auto !important; /* La hauteur s'adapte au contenu */
        min-height: 100vh;
        overflow: visible !important; /* Surtout pas de hidden ! */
        display: flex;
    }

    /* 3. La Barre Latérale (Inputs) */
    .sidebar {
        width: 100% !important;
        height: auto !important; /* Pas de hauteur fixe */
        min-height: auto !important;
        position: relative !important;
        border-right: none;
        border-bottom: 4px solid #040d1a;
        padding: 20px;
        box-sizing: border-box;
        z-index: 10;
        background: #071220; /* On assure le fond sombre */
    }
    
    /* Titres sidebar */
    .sidebar-title {
        text-align: center;
        margin-top: 10px;
    }

    /* 4. La zone de prévisualisation (Fond bleu derrière la feuille) */
    .preview-area {
        width: 100% !important;
        height: auto !important;
        display: block !important; /* Important pour le scroll */
        padding: 20px 0 !important;
        margin: 0 !important;
        
        /* C'est ICI le secret : on autorise le scroll horizontal */
        overflow-x: auto !important; 
        overflow-y: visible !important;
        
        background: #071220;
        flex-grow: 0 !important; /* Ne cherche pas à remplir le vide */
    }

    /* 5. Le Document Blanc (A4) */
    #document .document {
        margin: 40px auto 50px auto !important;
        /* Si l'écran est petit, l'utilisateur scrollera vers la droite */
        
        /* On force l'affichage */
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        transform: none !important; /* Pas de zoom bizarre qui casse la capture */
    }

    /* 6. Ajustements des champs de formulaire */
    .row-group {
        flex-direction: column;
        gap: 0;
    }
    .form-group {
        margin-bottom: 15px;
        width: 100%;
    }
    
    /* Menu Principal (Index) */
    .menu-grid {
        grid-template-columns: 1fr;
        padding: 10px;
    }
}


/* --- AUTOCOMPLETE (GLOBAL) --- */
.autocomplete-wrapper {
    position: relative;
    width: 100%;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #040d1a;
    border: 1px solid #475569;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 9999;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

.autocomplete-item {
    padding: 10px 15px;
    border-bottom: 1px solid #1e3a5f;
    cursor: pointer;
    color: #e2e8f0;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    transition: background 0.2s;
}

.autocomplete-item:hover {
    background: #e8820c; /* Bleu OMC au survol */
    color: white;
}

.autocomplete-item strong { display: block; font-size: 13px; }
.autocomplete-item small { color: #94a3b8; }
.autocomplete-item:hover small { color: #e2e8f0; }

/* ============================================================
   GESTION DU THÈME (LIGHT MODE)
   ============================================================ */

/* 1. PAR DÉFAUT (Mode Sombre) */
/* On cible .preview-area (Labo/Constat...) ET .dashboard-area (Dossiers) */
.preview-area, .dashboard-area {
    background-color: #071220 !important; /* Bleu nuit sombre par défaut */
    transition: background-color 0.3s ease;
}

/* 2. MODE CLAIR (Activé par le bouton) */
/* On change le fond des deux types de zones */
body.light-mode .preview-area,
body.light-mode .dashboard-area {
    background-color: #0d2137 !important; /* Gris clair bureau */
}

/* 3. PROTECTION ABSOLUE DE LA SIDEBAR */
/* On s'assure que rien ne change à gauche */
body.light-mode .sidebar,
body.light-mode .sidebar input,
body.light-mode .sidebar select,
body.light-mode .sidebar textarea,
body.light-mode .sidebar button:not(#theme-btn-toggle), 
body.light-mode .sidebar label,
body.light-mode .sidebar h1 {
    /* On ne touche à RIEN ici pour garder le menu sombre */
}


/* --- CORRECTION ICÔNE CALENDRIER (DATE) --- */
/* Inverse les couleurs de l'icône pour qu'elle soit blanche sur fond sombre */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.8;
}

/* Change aussi le curseur au survol */
input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}
