/* ════════════════════════════════════════════════════════════════
   VAN PUYENBROECK — Admin CMS Styles
   ════════════════════════════════════════════════════════════════ */

:root {
    --bg:          #0a0a0a;
    --surface:     #121212;
    --surface2:    #1a1a1a;
    --surface3:    #222222;
    --border:      rgba(255,255,255,0.07);
    --accent:      #00ffcc;
    --accent2:     #7b5cf0;
    --danger:      #ff4d4f;
    --text:        #e8e8e8;
    --text2:       #888;
    --text3:       #555;
    --font:        'Syne', sans-serif;
    --mono:        'DM Mono', monospace;
    --radius:      8px;
    --sidebar-w:   220px;
    --trans:       0.2s ease;
}

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

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    overflow: hidden;
}

/* En dessous de 768px on autorise le scroll global : c'est le panneau
   .admin-main (et non plus le body) qui gère le défilement, mais on
   sécurise ici au cas où le contenu déborde sur très petit écran. */
@media (max-width: 768px) {
    html, body { overflow: visible; }
}

/* ── Login Screen ── */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, rgba(123,92,240,0.15) 0%, transparent 60%), var(--bg);
}
.login-card {
    width: 340px;
    text-align: center;
    padding: 2.5rem 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
}
.login-logo { margin-bottom: 1rem; }
.login-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.5px; }
.login-sub { color: var(--text2); margin-bottom: 2rem; font-size: 0.85rem; }
.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: #000;
    font-family: var(--font);
    font-weight: 700;
    font-size: 0.9rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity var(--trans), transform var(--trans);
}
.btn-login:hover { opacity: 0.9; transform: translateY(-1px); }
.login-note { margin-top: 1rem; font-size: 0.78rem; color: var(--text3); }
.login-error {
    margin-top: 1rem;
    padding: 0.65rem 0.85rem;
    background: rgba(255,77,79,0.08);
    border: 1px solid rgba(255,77,79,0.3);
    border-radius: var(--radius);
    color: var(--danger);
    font-size: 0.78rem;
    line-height: 1.5;
    text-align: left;
    word-break: break-word;
}

/* ── Admin App Layout ── */
.admin-app { display: flex; height: 100vh; height: 100dvh; position: relative; }
.hidden { display: none !important; }

/* ── Mobile top bar (hidden by default, shown under the breakpoint) ── */
.mobile-topbar {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 500;
}
.btn-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}
.mobile-topbar-title { font-weight: 700; font-size: 0.95rem; letter-spacing: -0.3px; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 899;
    opacity: 0;
    transition: opacity var(--trans);
}
.sidebar-overlay.show { display: block; opacity: 1; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.25rem 1rem;
    font-weight: 700;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.3px;
}
.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: none;
    border: none;
    border-radius: var(--radius);
    color: var(--text2);
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
    transition: background var(--trans), color var(--trans);
}
.nav-item:hover { background: var(--surface3); color: var(--text); }
.nav-item.active { background: rgba(0,255,204,0.08); color: var(--accent); }
.nav-item--external { opacity: 0.7; font-size: 0.8rem; }
.nav-item--external:hover { opacity: 1; }
.nav-item--external svg:last-child { margin-left: auto; opacity: 0.5; }
.nav-divider { height: 1px; background: var(--border); margin: 0.5rem 0; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
}
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--surface3);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
    flex-shrink: 0;
    overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { display: block; font-size: 0.72rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout {
    background: none; border: none; color: var(--text2); cursor: pointer; padding: 4px;
    border-radius: 4px; transition: color var(--trans);
}
.btn-logout:hover { color: var(--danger); }

/* ── Admin Main ── */
.admin-main {
    flex: 1;
    overflow-y: auto;
    background: var(--bg);
}

/* ── Panels ── */
.panel { padding: 2rem; }
.panel.hidden { display: none; }
.panel.active { display: block; }
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.panel-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.5px; }
.panel-sub { margin-top: 0.25rem; color: var(--text2); font-size: 0.85rem; }
.section-title { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text2); margin-bottom: 1rem; }

/* ── Dashboard Cards ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.dash-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.dash-card-icon { color: var(--accent); }
.dash-card-num { display: block; font-size: 1.8rem; font-weight: 700; font-family: var(--mono); }
.dash-card-label { display: block; font-size: 0.78rem; color: var(--text2); }

/* ── Quick Links ── */
.dashboard-links { margin-bottom: 2rem; }
.quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.quick-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text2);
    text-decoration: none;
    font-size: 0.82rem;
    transition: border-color var(--trans), color var(--trans);
}
.quick-link:hover { border-color: var(--accent); color: var(--accent); }
.quick-link--restricted:hover { border-color: var(--accent2); color: var(--accent2); }

/* ── Save notice ── */
.save-notice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(0,255,204,0.06);
    border: 1px solid rgba(0,255,204,0.2);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--accent);
}
.btn-export {
    margin-left: auto;
    padding: 0.35rem 0.75rem;
    background: var(--accent);
    color: #000;
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity var(--trans);
}
.btn-export:hover { opacity: 0.85; }

/* ── Items List ── */
.items-list { display: flex; flex-direction: column; gap: 0.5rem; }
.item-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--trans);
}
.item-row:hover { border-color: rgba(255,255,255,0.15); }
.item-row-info { flex: 1; min-width: 0; }
.item-row-title { font-weight: 600; font-size: 0.9rem; }
.item-row-sub { font-size: 0.78rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); }
.item-row-tag {
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
    padding: 2px 8px; border-radius: 20px; background: var(--surface3); color: var(--text2);
}
.btn-edit, .btn-add {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.78rem;
    cursor: pointer;
    transition: background var(--trans), border-color var(--trans);
}
.btn-edit:hover, .btn-add:hover { background: var(--surface2); border-color: rgba(255,255,255,0.15); }
.btn-add { background: var(--accent); color: #000; font-weight: 700; border-color: transparent; }
.btn-add:hover { opacity: 0.9; background: var(--accent); }

/* ── Texts Panel ── */
.texts-grid { display: flex; flex-direction: column; gap: 1rem; }
.text-field {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}
.text-field-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text2); margin-bottom: 0.5rem; }
.text-field-input {
    width: 100%; background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.85rem;
    resize: vertical;
    min-height: 60px;
    transition: border-color var(--trans);
}
.text-field-input:focus { outline: none; border-color: var(--accent); }
.text-field-save {
    margin-top: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: var(--accent);
    color: #000;
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 700;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.modal {
    width: 100%;
    max-width: 520px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
    background: none; border: none; color: var(--text2); cursor: pointer; padding: 4px;
    border-radius: 4px; transition: color var(--trans);
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; max-height: 60vh; overflow-y: auto; }
.modal-footer {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}
.modal-footer .btn-save {
    background: var(--accent); color: #000; font-weight: 700;
    padding: 0.5rem 1.25rem; border: none; border-radius: var(--radius);
    font-family: var(--font); font-size: 0.85rem; cursor: pointer;
    transition: opacity var(--trans);
}
.modal-footer .btn-save:hover { opacity: 0.9; }
.modal-footer .btn-cancel {
    background: var(--surface3); color: var(--text); border: 1px solid var(--border);
    padding: 0.5rem 1rem; border-radius: var(--radius);
    font-family: var(--font); font-size: 0.85rem; cursor: pointer;
}
.modal-footer .btn-delete {
    background: none; color: var(--danger); border: 1px solid rgba(255,77,79,0.3);
    padding: 0.5rem 1rem; border-radius: var(--radius);
    font-family: var(--font); font-size: 0.85rem; cursor: pointer;
    margin-left: auto;
    transition: background var(--trans);
}
.modal-footer .btn-delete:hover { background: rgba(255,77,79,0.1); }

/* ── Form fields in modal ── */
.field-group { display: flex; flex-direction: column; gap: 0.35rem; }
.field-label { font-size: 0.78rem; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.07em; }
.field-input, .field-select, .field-textarea {
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.85rem;
    transition: border-color var(--trans);
    width: 100%;
}
.field-input:focus, .field-select:focus, .field-textarea:focus {
    outline: none; border-color: var(--accent);
}
.field-textarea { resize: vertical; min-height: 80px; }
.field-select { appearance: none; }

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 1.5rem; left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 2000;
    transition: transform 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(0,255,204,0.3); color: var(--accent); }
.toast.error { border-color: rgba(255,77,79,0.3); color: var(--danger); }

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE — Tablette & Mobile
   ════════════════════════════════════════════════════════════════ */

/* ── Tablette (≤ 1024px) : sidebar un peu plus étroite ── */
@media (max-width: 1024px) {
    :root { --sidebar-w: 190px; }
}

/* ── Mobile / petite tablette (≤ 768px) : menu en tiroir ── */
@media (max-width: 768px) {
    .admin-app { flex-direction: column; height: auto; min-height: 100vh; min-height: 100dvh; }

    .mobile-topbar { display: flex; }

    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100vh; height: 100dvh;
        width: min(280px, 82vw);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 900;
        box-shadow: 2px 0 24px rgba(0,0,0,0.4);
    }
    .sidebar.open { transform: translateX(0); }

    .admin-main {
        width: 100%;
        height: auto;
        overflow-y: visible;
    }

    .panel { padding: 1.25rem; }
    .panel-header { flex-wrap: wrap; gap: 0.75rem; }
    .panel-title { font-size: 1.2rem; }

    .dashboard-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }

    .quick-links { flex-direction: column; }
    .quick-link { width: 100%; }

    .save-notice { flex-wrap: wrap; }
    .btn-export { margin-left: 0; width: 100%; justify-content: center; }

    .item-row { flex-wrap: wrap; }
    .item-row-info { min-width: 140px; }

    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal {
        max-width: 100%;
        width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        display: flex;
        flex-direction: column;
    }
    .modal-body { flex: 1; }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer .btn-delete { margin-left: 0; order: 3; width: 100%; text-align: center; }
    .modal-footer .btn-save,
    .modal-footer .btn-cancel { flex: 1; }

    .login-card { width: 100%; max-width: 340px; }

    .toast { left: 1rem; right: 1rem; transform: translateY(120%); width: auto; white-space: normal; text-align: center; }
    .toast.show { transform: translateY(0); }
}

/* ── Très petit mobile (≤ 420px) ── */
@media (max-width: 420px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .login-card { padding: 2rem 1.25rem; }
    .panel { padding: 1rem; }
    .item-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .item-row-tag { align-self: flex-start; }
    .btn-edit { align-self: stretch; text-align: center; justify-content: center; }
}

/* ── Confort tactile : cibles cliquables plus grandes sur écrans tactiles ── */
@media (hover: none) and (pointer: coarse) {
    .nav-item, .btn-edit, .btn-add, .quick-link, .field-input, .field-select, .field-textarea, .text-field-input {
        min-height: 40px;
    }
}
