/* ============================================
   ADMIN PANEL — Les Aventuriers du Jeu
   Dark theme, clean, functional
   ============================================ */

:root {
    --admin-bg: #0f1117;
    --admin-surface: #1a1d27;
    --admin-surface2: #232736;
    --admin-border: #2d3145;
    --admin-text: #e4e6f0;
    --admin-text-muted: #8b8fa3;
    --admin-accent: #c8a45a;
    --admin-accent-hover: #d4b46a;
    --admin-danger: #e74c3c;
    --admin-danger-hover: #c0392b;
    --admin-success: #27ae60;
    --admin-radius: 10px;
    --sidebar-width: 260px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--admin-bg);
    color: var(--admin-text);
    min-height: 100vh;
}

/* --- Login Screen --- */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1117 0%, #1a1d27 50%, #0f1117 100%);
}

.login-card {
    background: var(--admin-surface);
    border: 1px solid var(--admin-border);
    border-radius: 16px;
    padding: 3rem 2.5rem;
    text-align: center;
    width: 100%;
    max-width: 400px;
    margin: 1rem;
}

.login-logo {
    width: 100px;
    height: 100px;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 20px rgba(200, 164, 90, 0.3));
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--admin-accent);
    margin-bottom: 0.25rem;
}

.login-card > p {
    color: var(--admin-text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.login-error {
    color: var(--admin-danger);
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

.btn-login {
    width: 100%;
    padding: 0.85rem;
    background: var(--admin-accent);
    color: #1a1d27;
    border: none;
    border-radius: var(--admin-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-login:hover { background: var(--admin-accent-hover); }

.back-link {
    display: inline-block;
    margin-top: 1.5rem;
    color: var(--admin-text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s;
}

.back-link:hover { color: var(--admin-accent); }

/* --- Dashboard Layout --- */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--admin-surface);
    border-right: 1px solid var(--admin-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--admin-border);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
}

.sidebar-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--admin-accent);
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.7rem 1rem;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--admin-text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.nav-item:hover {
    background: var(--admin-surface2);
    color: var(--admin-text);
}

.nav-item.active {
    background: rgba(200, 164, 90, 0.12);
    color: var(--admin-accent);
    font-weight: 600;
}

.nav-icon { font-size: 1.1rem; }

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--admin-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-back-site {
    display: block;
    padding: 0.6rem 1rem;
    background: var(--admin-surface2);
    color: var(--admin-text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
    transition: all 0.2s;
}

.btn-back-site:hover {
    background: var(--admin-border);
    color: var(--admin-text);
}

.btn-logout {
    padding: 0.6rem 1rem;
    background: rgba(231, 76, 60, 0.1);
    color: var(--admin-danger);
    border: 1px solid rgba(231, 76, 60, 0.2);
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(231, 76, 60, 0.2);
}

/* --- Mobile Header --- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--admin-surface);
    border-bottom: 1px solid var(--admin-border);
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 90;
}

.mobile-menu-btn, .mobile-logout-btn {
    background: none;
    border: none;
    color: var(--admin-text);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-title {
    font-weight: 700;
    color: var(--admin-accent);
    font-size: 1rem;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
}

.tab-content {
    display: none;
    animation: fadeIn 0.25s ease;
}

.tab-content.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.tab-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--admin-text);
}

.sub-header {
    font-size: 1.1rem;
    color: var(--admin-text-muted);
    margin-bottom: 1rem;
    font-weight: 600;
}

.btn-add {
    padding: 0.6rem 1.2rem;
    background: var(--admin-accent);
    color: #1a1d27;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-add:hover { background: var(--admin-accent-hover); }

/* --- Items List --- */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-item {
    background: var(--admin-surface);
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: border-color 0.2s;
}

.list-item:hover { border-color: var(--admin-accent); }

.list-item-info { flex: 1; min-width: 0; }

.list-item-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-sub {
    font-size: 0.85rem;
    color: var(--admin-text-muted);
}

.list-item-badge {
    padding: 0.25rem 0.6rem;
    background: rgba(200, 164, 90, 0.15);
    color: var(--admin-accent);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.list-item-badge.next {
    background: rgba(39, 174, 96, 0.15);
    color: var(--admin-success);
}

.list-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-edit, .btn-delete {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--admin-surface2);
    color: var(--admin-text-muted);
}

.btn-edit:hover {
    border-color: var(--admin-accent);
    color: var(--admin-accent);
}

.btn-delete {
    color: var(--admin-danger);
    border-color: rgba(231, 76, 60, 0.3);
}

.btn-delete:hover {
    background: rgba(231, 76, 60, 0.15);
    border-color: var(--admin-danger);
}

/* --- Items Grid (Gallery) --- */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.grid-item {
    background: var(--admin-surface);
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    overflow: hidden;
    transition: border-color 0.2s;
}

.grid-item:hover { border-color: var(--admin-accent); }

.grid-item-img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background: var(--admin-surface2);
}

.grid-item-body {
    padding: 0.75rem;
}

.grid-item-caption {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-item-cat {
    font-size: 0.75rem;
    color: var(--admin-text-muted);
    margin-bottom: 0.5rem;
}

.grid-item-actions {
    display: flex;
    gap: 0.4rem;
}

.grid-item-actions .btn-edit,
.grid-item-actions .btn-delete {
    flex: 1;
    text-align: center;
}

/* --- Admin Forms --- */
.admin-form { max-width: 700px; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.input-group.full-width { grid-column: 1 / -1; }

.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--admin-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input,
.input-group textarea,
.input-group select {
    padding: 0.7rem 0.9rem;
    background: var(--admin-surface2);
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    color: var(--admin-text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--admin-accent);
}

.input-group textarea {
    min-height: 80px;
    resize: vertical;
}

.btn-save {
    margin-top: 1.5rem;
    padding: 0.75rem 2rem;
    background: var(--admin-accent);
    color: #1a1d27;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save:hover { background: var(--admin-accent-hover); }

/* --- About Paragraphs Editor --- */
.about-paragraphs-editor {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.about-para-item {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.about-para-item textarea {
    flex: 1;
    padding: 0.7rem;
    background: var(--admin-surface2);
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    color: var(--admin-text);
    font-size: 0.85rem;
    font-family: inherit;
    min-height: 60px;
    resize: vertical;
}

.about-para-item textarea:focus {
    outline: none;
    border-color: var(--admin-accent);
}

/* --- Backup Cards --- */
.backup-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.backup-card {
    background: var(--admin-surface);
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    padding: 1.5rem;
}

.backup-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.backup-card p {
    color: var(--admin-text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.backup-card.danger { border-color: rgba(231, 76, 60, 0.3); }

.password-change-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.password-change-form .form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--admin-text-muted);
    margin-bottom: 0.3rem;
}

.password-change-form .form-group input {
    width: 100%;
    max-width: 350px;
    padding: 0.55rem 0.75rem;
    background: var(--admin-bg);
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    color: var(--admin-text);
    font-size: 0.9rem;
}

.password-change-form .form-group input:focus {
    border-color: var(--admin-accent);
    outline: none;
}

/* --- Upload Zone --- */
.upload-zone {
    border: 2px dashed var(--admin-border);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    transition: border-color 0.2s;
}

.upload-zone:hover { border-color: var(--admin-accent); }

.upload-preview {
    margin-bottom: 0.75rem;
}

.upload-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    object-fit: cover;
}

.upload-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-upload {
    padding: 0.55rem 1.2rem;
    background: var(--admin-accent);
    color: #1a1d27;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-upload:hover { background: var(--admin-accent-hover); }

.upload-status {
    font-size: 0.8rem;
    color: var(--admin-text-muted);
}

.btn-export, .btn-import, .btn-reset {
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-export {
    background: var(--admin-accent);
    color: #1a1d27;
}
.btn-export:hover { background: var(--admin-accent-hover); }

.btn-import {
    background: var(--admin-surface2);
    color: var(--admin-text);
    border: 1px solid var(--admin-border);
}
.btn-import:hover { border-color: var(--admin-accent); color: var(--admin-accent); }

.btn-reset {
    background: rgba(231, 76, 60, 0.15);
    color: var(--admin-danger);
    border: 1px solid rgba(231, 76, 60, 0.3);
}
.btn-reset:hover { background: rgba(231, 76, 60, 0.25); }

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: var(--admin-surface);
    border: 1px solid var(--admin-border);
    border-radius: 14px;
    width: 100%;
    max-width: 540px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--admin-border);
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--admin-text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s;
}

.modal-close:hover { color: var(--admin-text); }

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-body .input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--admin-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-body .input-group input,
.modal-body .input-group textarea,
.modal-body .input-group select {
    padding: 0.7rem 0.9rem;
    background: var(--admin-surface2);
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    color: var(--admin-text);
    font-size: 0.9rem;
    font-family: inherit;
}

.modal-body .input-group input:focus,
.modal-body .input-group textarea:focus,
.modal-body .input-group select:focus {
    outline: none;
    border-color: var(--admin-accent);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.btn-modal-cancel {
    padding: 0.65rem 1.25rem;
    background: var(--admin-surface2);
    color: var(--admin-text-muted);
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-modal-cancel:hover {
    color: var(--admin-text);
    border-color: var(--admin-text-muted);
}

.btn-modal-save {
    padding: 0.65rem 1.5rem;
    background: var(--admin-accent);
    color: #1a1d27;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-modal-save:hover { background: var(--admin-accent-hover); }

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 0.75rem 1.5rem;
    background: var(--admin-success);
    color: #fff;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error { background: var(--admin-danger); }

/* --- Checkbox Group --- */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--admin-accent);
    cursor: pointer;
}

.checkbox-group label {
    cursor: pointer;
    text-transform: none !important;
    font-size: 0.9rem !important;
    color: var(--admin-text) !important;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 1.25rem;
        padding-top: calc(56px + 1.25rem);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .list-item {
        flex-wrap: wrap;
    }

    .list-item-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--admin-border);
    }

    .tab-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .tab-header h2 {
        font-size: 1.25rem;
    }

    .backup-actions {
        grid-template-columns: 1fr;
    }

    .modal {
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .items-grid {
        grid-template-columns: 1fr 1fr;
    }

    .main-content {
        padding: 1rem;
        padding-top: calc(56px + 1rem);
    }
}
