/* ==========================================================================
   style.css — Dicofr
   Mise en page globale, dark theme, mobile-first.

   SECTIONS :
     1. Variables CSS
     2. Reset / Base
     3. Overlay de connexion
     4. Layout principal
     5. Sidebar
     6. Barre haute (recherche)
     7. Boutons icônes
     8. Suggestions d'autocomplétion
     9. Zone article
    10. Barre de navigation basse
    11. Citations — bouton cœur
    12. Indicateurs état (favoris, citations visibles)
    13. Spinner de chargement
    14. Message d'accueil
    15. Responsive
    16. Animations
    17. Panneau Admin
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Variables CSS
   -------------------------------------------------------------------------- */
:root {
    --bg:              #0d0d0d;
    --bg-surface:      #1a1a1a;
    --bg-raised:       #252525;
    --bg-hover:        #2e2e2e;
    --border:          #333;
    --text:            #e8e8e8;
    --text-dim:        #888;
    --text-dimmer:     #555;
    --accent:          #c0392b;
    --accent-hover:    #e74c3c;
    --success:         #27ae60;

    --sidebar-w:       280px;
    --topbar-h:        56px;
    --bottombar-h:     56px;
    --radius:          10px;
    --transition:      0.18s cubic-bezier(0.4, 0, 0.2, 1);

    --article-font-size: 18px;
}


/* --------------------------------------------------------------------------
   2. Reset / Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 18px;
    line-height: 1.6;
    height: 100%;
}

body {
    display: flex;
    overflow-x: hidden;
}


/* --------------------------------------------------------------------------
   3. Overlay de connexion
   -------------------------------------------------------------------------- */

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Masqué quand l'utilisateur est connecté (géré par app.js) */
.login-overlay.hidden {
    display: none;
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.7);
}

.login-title {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 6px;
    text-align: center;
    letter-spacing: -0.01em;
}

.login-title i {
    color: var(--accent);
    margin-right: 8px;
}

.login-subtitle {
    color: var(--text-dim);
    font-size: 0.875rem;
    text-align: center;
    margin: 0 0 28px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-field label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-dim);
    letter-spacing: 0.02em;
}

.login-field input {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9375rem;
    padding: 11px 14px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.login-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.18);
}

.login-field input::placeholder {
    color: var(--text-dimmer);
}

.login-error {
    color: var(--accent-hover);
    font-size: 0.8125rem;
    min-height: 1em;
    margin: 0;
    text-align: center;
}

.login-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 12px;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s;
    margin-top: 4px;
}

.login-btn:hover { background: var(--accent-hover); }
.login-btn:active { transform: scale(0.98); }

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


/* --------------------------------------------------------------------------
   4. Layout principal
   -------------------------------------------------------------------------- */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}


/* --------------------------------------------------------------------------
   5. Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--sidebar-w);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--transition), box-shadow var(--transition);
    overflow: hidden;
}

.sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.5);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
}

.sidebar-overlay.open { display: block; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--topbar-h);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}

.sidebar-section {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dimmer);
    margin: 8px 16px 6px;
}

.ul_liked {
    list-style: none;
    margin: 0;
    padding: 0;
}

.li_liked {
    padding: 9px 20px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text);
    transition: background var(--transition);
    line-height: 1.3;
}

.li_liked:hover { background-color: var(--bg-hover); }
.li_liked:active { background-color: var(--bg-raised); }

/* Pied de sidebar : username + boutons */
.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-username {
    flex: 1;
    font-size: 13px;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-left: 4px;
}

.sidebar-logout-btn,
.sidebar-admin-btn {
    color: var(--text-dimmer);
    font-size: 17px;
    min-width: 36px;
    min-height: 36px;
}

.sidebar-logout-btn:hover { color: var(--accent-hover); }
.sidebar-admin-btn:hover  { color: var(--text); }

/* Scrollbar sidebar */
.sidebar-section::-webkit-scrollbar { width: 4px; }
.sidebar-section::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }


/* --------------------------------------------------------------------------
   6. Barre haute (recherche)
   -------------------------------------------------------------------------- */
.top-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: var(--topbar-h);
    background-color: rgba(26, 26, 26, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.search-wrapper {
    position: relative;
    flex: 1;
}

.search-wrapper input[type="text"] {
    width: 100%;
    padding: 9px 14px;
    background-color: var(--bg-raised);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-wrapper input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.18);
}

.search-wrapper input[type="text"]::placeholder { color: var(--text-dimmer); }


/* --------------------------------------------------------------------------
   7. Boutons icônes (top + bottom bars)
   -------------------------------------------------------------------------- */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background var(--transition), color var(--transition);
    padding: 0 6px;
    flex-shrink: 0;
}

.icon-btn:hover  { background-color: var(--bg-hover); }
.icon-btn:active { background-color: var(--bg-raised); }

/* État désactivé (début / fin de l'historique) */
.icon-btn.dim { color: var(--text-dimmer); }

/* Bouton favori article */
#article-bookmark-btn { color: var(--text-dim); }
#article-bookmark-btn.liked { color: var(--accent); }

/* Boutons taille de texte */
.font-size-btn  { font-family: inherit; font-weight: 600; }
.font-size-label { font-size: 14px; line-height: 1; }
.font-size-btn:disabled { opacity: 0.3; cursor: default; }
.font-size-btn:disabled:hover { background: none; }


/* --------------------------------------------------------------------------
   8. Suggestions d'autocomplétion
   -------------------------------------------------------------------------- */
.suggestions {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    max-height: 320px;
    overflow-y: auto;
    background-color: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius);
    z-index: 50;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.suggestion-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text);
    transition: background var(--transition);
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.suggestion-entry {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion-cat {
    font-size: 11px;
    color: var(--text-dimmer);
    white-space: nowrap;
    flex-shrink: 0;
    font-style: italic;
}

.suggestion-item:hover { background-color: var(--bg-hover); }
.suggestion-item.active { background-color: var(--accent); color: #fff; }
.suggestion-item.active .suggestion-cat { color: rgba(255, 255, 255, 0.7); }

/* Scrollbar suggestions */
.suggestions::-webkit-scrollbar { width: 4px; }
.suggestions::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }


/* --------------------------------------------------------------------------
   9. Zone article
   -------------------------------------------------------------------------- */
.article-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px calc(var(--bottombar-h) + 28px);
    width: min(860px, 100%);
    align-self: center;
    font-size: var(--article-font-size);
}

/* Scrollbar article */
.article-content::-webkit-scrollbar { width: 5px; }
.article-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }


/* --------------------------------------------------------------------------
   10. Barre de navigation basse
   -------------------------------------------------------------------------- */
.bottom-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 12px;
    height: var(--bottombar-h);
    background-color: rgba(26, 26, 26, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.bottom-bar-separator {
    width: 1px;
    height: 24px;
    background-color: var(--border);
    margin: 0 4px;
}


/* --------------------------------------------------------------------------
   11. Citations — bouton cœur
   -------------------------------------------------------------------------- */
.citation_coeur_bouton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    transform: translateX(-34px);
    margin-right: -28px;
    color: var(--text-dimmer);
    cursor: pointer;
    font-size: 14px;
    opacity: 0;
    transition: color var(--transition), opacity var(--transition);
    vertical-align: middle;
}

.citation:hover .citation_coeur_bouton { opacity: 1; }
.citation_coeur_bouton.liked           { opacity: 1; color: var(--accent); }
.citation_coeur_bouton:hover           { color: var(--accent-hover); }


/* --------------------------------------------------------------------------
   12. Indicateurs d'état
   -------------------------------------------------------------------------- */
#btn-citations-toggle.citations-visible { color: var(--accent); }
#btn-liked-citations.citations-visible  { color: var(--accent); }


/* --------------------------------------------------------------------------
   13. Spinner de chargement
   -------------------------------------------------------------------------- */
.loading-spinner {
    display: none;
    position: fixed;
    top: calc(var(--topbar-h) + 14px);
    right: 20px;
    z-index: 300;
}

.loading-spinner.visible { display: block; }

.spinner-ring {
    width: 22px;
    height: 22px;
    border: 3px solid var(--border);
    border-top-color: var(--text-dim);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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


/* --------------------------------------------------------------------------
   14. Message d'accueil
   -------------------------------------------------------------------------- */
.welcome-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 20px;
    color: var(--text-dimmer);
    text-align: center;
    font-size: 15px;
}

.welcome-msg p { margin: 0; }


/* --------------------------------------------------------------------------
   15. Responsive
   -------------------------------------------------------------------------- */

/* Desktop : sidebar pousse le contenu (pas d'overlay) */
@media (min-width: 900px) {
    body.sidebar-open .main-content {
        margin-left: var(--sidebar-w);
        transition: margin-left var(--transition);
    }

    .sidebar-overlay { display: none !important; }
}

/* Tablette / mobile */
@media (max-width: 768px) {
    .article-content {
        padding: 16px 16px calc(var(--bottombar-h) + 56px);
        font-size: var(--article-font-size);
    }

    /* Barre de navigation flottante sur mobile */
    .bottom-bar {
        position: fixed;
        bottom: 14px;
        left: 16px;
        right: 16px;
        height: 54px;
        border-radius: 27px;
        border-top: none;
        border: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
        z-index: 100;
        padding: 0 10px;
    }

    .main-content { padding-bottom: 80px; }

    .icon-btn { font-size: 18px; min-width: 40px; }

    /* Panneau "plus" flottant au-dessus de la barre du bas */
    .bottom-more-panel {
        position: fixed;
        bottom: calc(14px + 54px + 8px);
        left: 16px;
        right: 16px;
        height: 54px;
        display: none;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 0 10px;
        background-color: rgba(26, 26, 26, 0.95);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 27px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
        z-index: 99;
    }
    .bottom-more-panel.open { display: flex; }
}

.bottom-show-sm  { display: none; }
.bottom-more-panel { display: none; }   /* masqué globalement ; affiché via .open sur mobile */

@media (max-width: 768px) {
    .bottom-hide-sm { display: none; }
    .bottom-show-sm { display: flex; align-items: center; }
}

@media (max-width: 380px) {
    .bottom-bar-separator { display: none; }
    .icon-btn { min-width: 36px; font-size: 16px; }
}

/* Responsive style_robert.css */
@media (max-width: 600px) {
    .num_A, .num_B, .num_C, .num_D {
        float: none;
        display: inline;
        margin-right: 4px;
    }
}


/* --------------------------------------------------------------------------
   17. Panneau Admin
   -------------------------------------------------------------------------- */

.admin-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .65);
    z-index: 300;
    display: none;
}
.admin-panel-overlay.open { display: block; }

.admin-panel {
    position: fixed;
    inset: 0;
    z-index: 301;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px 16px;
    overflow-y: auto;
}
.admin-panel.open { display: flex; }

.admin-panel-inner {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 660px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .6);
    margin-bottom: 40px;
}

.admin-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.admin-panel-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0 8px;
}
.admin-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    padding: 12px 14px;
    margin-bottom: -1px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color var(--transition), border-color var(--transition);
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.admin-tab-content { display: none; padding: 20px; }
.admin-tab-content.active { display: block; }

.admin-list { display: flex; flex-direction: column; gap: 8px; }

.admin-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
}
.admin-list-item-info { flex: 1; min-width: 0; }
.admin-list-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-list-item-meta {
    font-size: 11px;
    color: var(--text-dimmer);
    margin-top: 2px;
}

.admin-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}
.admin-badge-admin    { background: rgba(139,  92, 246, .18); color: #a78bfa; }
.admin-badge-user     { background: rgba( 96, 165, 250, .12); color: #60a5fa; }
.admin-badge-active   { background: rgba( 39, 174,  96, .15); color: #4ade80; }
.admin-badge-inactive,
.admin-badge-revoked  { background: rgba(239,  68,  68, .12); color: #f87171; }

.admin-btn-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    padding: 4px 10px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: border-color var(--transition), color var(--transition);
}
.admin-btn-toggle:hover { border-color: var(--accent); color: var(--accent); }

.admin-section-actions { margin-bottom: 16px; }

.admin-btn-primary {
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    padding: 8px 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: opacity var(--transition);
}
.admin-btn-primary:hover { opacity: .85; }
.admin-btn-primary:disabled { opacity: .5; cursor: default; }

.admin-new-key {
    background: rgba(39, 174, 96, .07);
    border: 1px solid rgba(39, 174, 96, .25);
    border-radius: 8px;
    padding: 14px 16px;
    margin-top: 16px;
}
.admin-new-key.hidden { display: none; }
.admin-new-key-title {
    font-size: 12px;
    font-weight: 600;
    color: #4ade80;
    margin-bottom: 8px;
}
.admin-new-key-value {
    font-family: monospace;
    font-size: 12px;
    color: var(--text);
    word-break: break-all;
    background: var(--bg-surface);
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    user-select: all;
    transition: background var(--transition);
}
.admin-new-key-hint {
    font-size: 11px;
    color: var(--text-dimmer);
    margin-top: 6px;
}

.admin-form { max-width: 380px; }
.admin-field { margin-bottom: 16px; }
.admin-field label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.admin-optional { color: var(--text-dimmer); }
.admin-field input,
.admin-field select {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    padding: 8px 10px;
    transition: border-color var(--transition);
}
.admin-field input::placeholder { color: var(--text-dimmer); }
.admin-field input:focus,
.admin-field select:focus {
    outline: none;
    border-color: var(--accent);
}
.admin-msg { font-size: 13px; min-height: 20px; margin-bottom: 12px; }
.admin-msg.success { color: var(--success); }
.admin-msg.error   { color: #f87171; }


/* --------------------------------------------------------------------------
   16. Animations / micro-interactions
   -------------------------------------------------------------------------- */
@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.article-content > * {
    animation: fade-in 0.22s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Le mot-vedette est cliquable pour liker l'article */
.s_ent {
    cursor: pointer;
    transition: opacity var(--transition);
}
.s_ent:hover { opacity: 0.8; }

.damier { text-align: center; margin: 0; }
