/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN UI — Design unifié 2025
   Charge sur toutes les pages via base.html, après les CSS legacy
   (style.css, table.css, tabs.css) qu'il surcharge.
═══════════════════════════════════════════════════════════════════════════ */

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

body {
    margin: 0;
    font-family: 'Inter', 'Montserrat', sans-serif;
    background: #f0f2f5; color: #2d3748;
}

/* ───────────────────────────────────────────────────────────────────────────
   LAYOUT — sidebar / header / content
─────────────────────────────────────────────────────────────────────────── */

/* Loader overlay */
.overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(15,20,40,.6); backdrop-filter: blur(3px);
    display: none; align-items: center; justify-content: center;
}
.overlay.active { display: flex; }

/* Sidebar */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: 240px; height: 100vh;
    background: #1a2035;
    display: flex; flex-direction: column;
    transition: width .25s ease;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0,0,0,.2);
}
.sidebar.collapsed { width: 64px; }

.sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex; align-items: center;
    min-height: 72px;
    overflow: hidden;
}
.sidebar-header img { height: 32px; width: auto; transition: opacity .2s; }
#logo_aro       { display: block; }
#small_logo_aro { display: none; }
.sidebar.collapsed #logo_aro       { display: none; }
.sidebar.collapsed #small_logo_aro { display: block; }

.toggle-btn {
    position: absolute; top: 22px; right: -14px;
    width: 28px; height: 28px;
    background: #667eea; border: none; border-radius: 50%;
    color: #fff; cursor: pointer; font-size: .75em;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(102,126,234,.5);
    transition: background .15s, transform .25s;
    z-index: 101;
}
.toggle-btn:hover { background: #5a67d8; }
.sidebar.collapsed .toggle-btn { transform: rotate(180deg); }

.sidebar-menu {
    list-style: none; margin: 0; padding: 16px 0;
    flex: 1; overflow-y: auto; overflow-x: hidden;
}
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.sidebar-menu li { margin: 2px 8px; }
.sidebar-menu li a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    color: #a0aec0; text-decoration: none;
    border-radius: 9px; font-size: .875em; font-weight: 500;
    transition: background .15s, color .15s;
    white-space: nowrap; overflow: hidden;
}
.sidebar-menu li a:hover {
    background: rgba(102,126,234,.15); color: #e2e8f0;
}
.sidebar-menu li a.active {
    background: linear-gradient(135deg, rgba(102,126,234,.3), rgba(118,75,162,.2));
    color: #fff;
    box-shadow: inset 3px 0 0 #667eea;
}
.sidebar-menu li a i {
    font-size: 1em; width: 20px; text-align: center; flex-shrink: 0;
    color: #718096; transition: color .15s;
}
.sidebar-menu li a:hover i,
.sidebar-menu li a.active i { color: #a78bfa; }
.sidebar-menu li a span { transition: opacity .2s; }
.sidebar.collapsed .sidebar-menu li a span { opacity: 0; pointer-events: none; }
.sidebar.collapsed .sidebar-menu li a { justify-content: center; }

.sidebar-menu .nav-sep {
    height: 1px; background: rgba(255,255,255,.06);
    margin: 8px 16px;
}
.sidebar-menu .nav-label {
    font-size: .68em; font-weight: 700; color: #4a5568;
    text-transform: uppercase; letter-spacing: .1em;
    padding: 8px 20px 4px;
    white-space: nowrap; overflow: hidden;
    transition: opacity .2s;
}
.sidebar.collapsed .nav-label { opacity: 0; }

/* Main content */
.main-content {
    margin-left: 240px;
    min-height: 100vh;
    transition: margin-left .25s ease;
    display: flex; flex-direction: column;
}
.sidebar.collapsed ~ .main-content { margin-left: 64px; }
.not_authenticated { min-height: 100vh; }

/* Top header */
.header {
    position: sticky; top: 0; z-index: 50;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
    padding: 0 28px;
    height: 56px; min-height: 56px;
    display: flex; align-items: center; justify-content: flex-end;
    gap: 16px;
}
.header-user {
    display: flex; align-items: center; gap: 8px;
    font-size: .85em; color: #4a5568; cursor: pointer;
    padding: 6px 12px; border-radius: 8px;
    transition: background .15s;
}
.header-user:hover { background: #f7fafc; }
.header-user .user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: .8em; font-weight: 700; flex-shrink: 0;
}
.header-refresh {
    width: 34px; height: 34px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #718096; cursor: pointer; transition: all .15s;
}
.header-refresh:hover { background: #f7fafc; color: #667eea; }

/* Content area */
.content { flex: 1; padding: 28px 32px; }

/* Flash messages */
.flashes { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-radius: 9px;
    font-size: .875em; font-weight: 500;
    animation: flashIn .3s ease;
}
@keyframes flashIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }
.flash-success { background: #f0fff4; color: #276749; border: 1px solid #9ae6b4; }
.flash-success::before { content: "✓"; font-weight: 700; }
.flash-error   { background: #fff5f5; color: #9b2c2c; border: 1px solid #feb2b2; }
.flash-error::before   { content: "✕"; font-weight: 700; }

/* QR Modal (utilisé par base.html) */
#QRModal .modal-content {
    max-width: 480px; border-radius: 16px; overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.logo_header { text-align: center; padding: 20px; background: #1a2035; }
.logo_header img { height: 80px; }
#QRModal .section { padding: 20px 24px; }
#QRModal .section h2 { font-size: 1em; color: #4a5568; margin: 0 0 14px; }
.qr-container { display: flex; gap: 16px; justify-content: center; }
.qr-card {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 14px 18px; background: #f7fafc;
    border: 1px solid #e2e8f0; border-radius: 10px;
    font-size: .8em; color: #718096;
}
.qr-card img { width: 150px; height: 150px; border-radius: 6px; }
#QRModal footer { text-align: center; padding: 12px; font-size: .75em; color: #a0aec0; border-top: 1px solid #e2e8f0; }


/* ───────────────────────────────────────────────────────────────────────────
   PAGES ADMIN — page-header, table, badges, modal, form
─────────────────────────────────────────────────────────────────────────── */

/* Page header */
.page-header {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e2e8f0;
}
.page-header-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.15em; flex-shrink: 0;
}
.page-header h2 {
    margin: 0; font-size: 1.35em; font-weight: 700;
    color: #1a2035;
}
.page-header .ph-sub {
    font-size: .78em; color: #718096; margin-top: 2px;
}
.add-item-btn {
    margin-left: auto;
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 18px;
    background: linear-gradient(135deg, #667eea, #5a67d8);
    color: #fff; border: none; border-radius: 9px;
    font-size: .84em; font-weight: 600; cursor: pointer;
    box-shadow: 0 3px 10px rgba(102,126,234,.35);
    transition: all .18s; text-decoration: none;
}
.add-item-btn:hover {
    background: linear-gradient(135deg, #5a67d8, #4c51bf);
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(102,126,234,.45);
    color: #fff;
}

/* Table */
.item-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: #fff; border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
    overflow: hidden;
}
.item-table thead tr { background: #1a2035; }
.item-table thead th {
    padding: 13px 16px;
    font-size: .78em; font-weight: 700;
    color: #a0aec0; text-transform: uppercase;
    letter-spacing: .06em; border: none;
    white-space: nowrap;
}
.item-table thead th a {
    color: #a0aec0; text-decoration: none;
    transition: color .15s;
}
.item-table thead th a:hover { color: #fff; }
.item-table tbody tr {
    border-bottom: 1px solid #f0f2f5;
    transition: background .12s;
}
.item-table tbody tr:last-child { border-bottom: none; }
.item-table tbody tr:hover { background: #f7f9ff; }
.item-table tbody td {
    padding: 11px 16px;
    font-size: .875em; color: #2d3748;
    vertical-align: middle;
}

/* Badges actif/inactif */
.badge-active {
    display: inline-flex; align-items: center; gap: 5px;
    background: #f0fff4; color: #276749;
    border: 1px solid #9ae6b4;
    padding: 3px 10px; border-radius: 20px;
    font-size: .75em; font-weight: 600;
}
.badge-inactive {
    display: inline-flex; align-items: center; gap: 5px;
    background: #fff5f5; color: #9b2c2c;
    border: 1px solid #feb2b2;
    padding: 3px 10px; border-radius: 20px;
    font-size: .75em; font-weight: 600;
}

/* Action icons */
.action-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 7px;
    cursor: pointer; transition: all .15s;
    color: #718096; font-size: .9em;
    margin-right: 3px;
}
.action-btn:hover { background: #edf2f7; color: #2d3748; }
.action-btn.danger:hover { background: #fff5f5; color: #e53e3e; }
.action-btn.success:hover { background: #f0fff4; color: #38a169; }

/* Modal overlay */
.modal {
    display: none; position: fixed; inset: 0;
    background: rgba(15,20,40,.72);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center; justify-content: center;
}
.modal.open, .modal[style*="flex"], .modal[style*="block"] {
    display: flex !important;
}
.modal-content {
    width: 100%; max-width: 520px;
    background: #fff; border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,.4);
    animation: modalIn .22s ease;
    max-height: 90vh; display: flex; flex-direction: column;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(-16px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Modal header */
.modal-header {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 22px;
    background: linear-gradient(135deg, #1a2035, #2d3a5a);
    color: #fff; flex-shrink: 0;
}
.modal-header-icon {
    width: 38px; height: 38px; border-radius: 9px;
    background: rgba(102,126,234,.25);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05em; color: #a78bfa; flex-shrink: 0;
}
.modal-header-title { flex: 1; }
.modal-header-title h3 { margin: 0; font-size: 1em; font-weight: 700; }
.modal-header-title p  { margin: 2px 0 0; font-size: .74em; color: #a0aec0; }
.modal-header .close {
    color: #a0aec0; font-size: 1.3em; cursor: pointer;
    width: 28px; height: 28px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s; line-height: 1;
}
.modal-header .close:hover { background: rgba(255,255,255,.1); color: #fff; }
#modalTitle { display: none; }

/* Modal body */
.modal-body {
    padding: 20px 22px;
    overflow-y: auto; flex: 1;
    display: flex; flex-direction: column; gap: 14px;
}
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 4px; }

/* Champs formulaire */
.form-group.form, .form-field {
    display: flex; flex-direction: column; gap: 5px;
}
.form-group.form label, .form-field label {
    font-size: .78em; font-weight: 600; color: #4a5568;
    text-transform: uppercase; letter-spacing: .05em;
}
.form-group.form input[type="text"],
.form-group.form input[type="email"],
.form-group.form input[type="number"],
.form-group.form input[type="password"],
.form-group.form select,
.form-group.form textarea {
    padding: 9px 11px;
    border: 1.5px solid #e2e8f0; border-radius: 8px;
    font-size: .88em; color: #2d3748;
    background: #f7fafc; outline: none;
    transition: border-color .2s, box-shadow .2s;
    width: 100%; box-sizing: border-box;
}
.form-group.form input:focus,
.form-group.form select:focus,
.form-group.form textarea:focus {
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(102,126,234,.15);
}
.form-group.form input[disabled] {
    background: #f0f4f8; color: #a0aec0; cursor: not-allowed;
}
.form-group.form select {
    appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23718096' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center;
    padding-right: 30px;
}
.form-group.form input[type="checkbox"] {
    width: 16px; height: 16px; cursor: pointer;
    accent-color: #667eea;
}
.form-group.form br { display: none; }

/* Modal footer */
.form-actions {
    padding: 14px 22px;
    border-top: 1px solid #e2e8f0;
    background: #f7fafc; flex-shrink: 0;
}
.form-actions table { width: 100%; }
.form-actions td { padding: 0 4px; text-align: center; }
.submit-btn.form {
    width: 100%; padding: 10px;
    background: linear-gradient(135deg, #667eea, #5a67d8);
    color: #fff; border: none; border-radius: 9px;
    font-size: .85em; font-weight: 700; cursor: pointer;
    transition: all .18s;
    box-shadow: 0 3px 10px rgba(102,126,234,.35);
}
.submit-btn.form:hover {
    background: linear-gradient(135deg, #5a67d8, #4c51bf);
    transform: translateY(-1px);
}
.cancel-btn.form {
    width: 100%; padding: 10px;
    background: #fff; color: #718096;
    border: 1.5px solid #e2e8f0; border-radius: 9px;
    font-size: .85em; font-weight: 600; cursor: pointer;
    transition: all .15s;
}
.cancel-btn.form:hover { background: #f7fafc; border-color: #cbd5e0; }

/* Pagination & misc — h2 par défaut masqué (remplacé par .page-header h2) */
.content > h2:not(.page-header h2) { display: none; }
