/* ============================================================================
   CivicTrust admin dashboard — clean, responsive, mobile-first.
   ============================================================================ */

.admin-body {
    background: var(--ct-soft);
    padding: 0 !important;
    margin: 0;
    min-height: 100vh;
}

/* ---------------------------------------------------------------------------
   Lock screen
   --------------------------------------------------------------------------- */
.lock-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1e293b 0%, #2563eb 50%, #8b5cf6 100%);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.4s ease;
}
.lock-screen.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.lock-card {
    background: #fff;
    border-radius: 24px;
    padding: 44px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.35);
    text-align: center;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.lock-icon {
    width: 76px; height: 76px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ct-primary), var(--ct-purple));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 22px;
    box-shadow: 0 16px 32px rgba(37, 99, 235, 0.35);
}
.lock-card .form-control {
    border-radius: 12px;
    border: 2px solid var(--ct-border);
    padding: 14px 18px;
    transition: all 0.2s;
}
.lock-card .form-control:focus {
    border-color: var(--ct-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}
.lock-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 10px;
}
.lock-success {
    background: #d1fae5;
    color: #065f46;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 10px;
}

/* Auth tabs */
.auth-card { padding: 36px 30px; }
.auth-tabs {
    background: #f1f5f9;
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}
.auth-tabs .nav-link {
    border-radius: 9px;
    color: var(--ct-muted);
    background: transparent;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 12px;
    border: none;
}
.auth-tabs .nav-link.active {
    background: #fff;
    color: var(--ct-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.auth-form .form-control { text-align: left; }
.auth-hint {
    background: rgba(37, 99, 235, 0.08);
    color: var(--ct-primary);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    text-align: center;
}

/* User pill in sidebar footer */
.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--ct-soft);
    border-radius: 12px;
    margin-bottom: 8px;
}
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ct-primary), var(--ct-purple));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    text-transform: uppercase;
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--ct-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: 0.72rem;
    color: var(--ct-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.user-role.admin { color: var(--ct-primary); font-weight: 700; }

/* User cards in users view */
.user-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--ct-border);
    border-radius: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    transition: border-color 0.2s;
}
.user-row:hover { border-color: var(--ct-primary); }
.user-row .user-avatar { width: 44px; height: 44px; font-size: 1rem; }
.user-row .u-meta { flex: 1; min-width: 200px; }
.user-row .u-meta-name { font-weight: 700; font-size: 0.95rem; }
.user-row .u-meta-detail { font-size: 0.8rem; color: var(--ct-muted); display: flex; flex-wrap: wrap; gap: 10px; }
.user-row .u-stats { font-size: 0.8rem; color: var(--ct-muted); text-align: right; }

.role-pill {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 50px;
    text-transform: uppercase;
}
.role-pill.admin { background: rgba(37, 99, 235, 0.12); color: var(--ct-primary); }
.role-pill.user  { background: var(--ct-soft); color: var(--ct-muted); }
.verify-pill.pending  { background: #fef3c7; color: #92400e; }
.verify-pill.verified { background: #d1fae5; color: #065f46; }

/* Color picker (settings) */
.color-input { display: flex; gap: 8px; align-items: stretch; }
.color-input input[type="color"] {
    width: 50px; height: 42px;
    border: 1px solid var(--ct-border);
    border-radius: 10px;
    cursor: pointer;
    padding: 4px;
    background: #fff;
    flex-shrink: 0;
}
.color-input .form-control {
    flex: 1;
    font-family: ui-monospace, monospace;
    text-transform: uppercase;
}

/* Settings forms */
#companyForm .form-control,
#styleForm   .form-control {
    background: #f8fafc;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 10px 14px;
    transition: all 0.2s;
}
#companyForm .form-control:focus,
#styleForm   .form-control:focus {
    background: #fff;
    border-color: var(--ct-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* BDC star button */
.star-btn {
    width: 34px; height: 34px;
    border-radius: 10px;
    border: 1px solid var(--ct-border);
    background: #fff;
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}
.star-btn:hover { border-color: #f59e0b; color: #f59e0b; }
.star-btn.active {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}
.star-btn.active i { animation: starPop 0.3s ease; }
@keyframes starPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ---------------------------------------------------------------------------
   Mobile top bar (only < lg)
   --------------------------------------------------------------------------- */
.admin-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: #fff;
    border-bottom: 1px solid var(--ct-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    z-index: 900;
    box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.topbar-toggle {
    width: 42px; height: 42px;
    border: none;
    background: transparent;
    border-radius: 10px;
    color: var(--ct-text);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.topbar-toggle:hover { background: var(--ct-soft); }
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--ct-dark);
}
.brand-mark.sm { width: 32px; height: 32px; font-size: 0.85rem; border-radius: 10px; }

/* ---------------------------------------------------------------------------
   Shell layout
   --------------------------------------------------------------------------- */
.admin-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.admin-sidebar {
    width: 260px;
    background: #fff;
    border-right: 1px solid var(--ct-border);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 18px 8px;
    border-bottom: 1px solid var(--ct-border);
    margin-bottom: 16px;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--ct-dark);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    overflow-y: auto;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--ct-text);
    font-weight: 500;
    text-align: left;
    transition: all 0.2s;
    width: 100%;
    font-size: 0.95rem;
}
.nav-btn i:first-child {
    width: 20px;
    color: var(--ct-muted);
    font-size: 1rem;
    transition: color 0.2s;
}
.nav-btn:hover { background: var(--ct-soft); }
.nav-btn:hover i:first-child { color: var(--ct-primary); }
.nav-btn.active {
    background: linear-gradient(135deg, rgba(37,99,235,0.1), rgba(139,92,246,0.06));
    color: var(--ct-primary);
    font-weight: 600;
}
.nav-btn.active i:first-child { color: var(--ct-primary); }

.bdc-badge {
    margin-left: auto;
    background: var(--ct-orange);
    color: #fff;
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 22px;
    text-align: center;
    display: none;
}
.bdc-badge.show { display: inline-block; }

/* Sidebar sub-items (e.g. Favoris under Bons de commande) */
.nav-btn.nav-sub {
    padding-left: 36px;
    font-size: 0.9rem;
    margin-bottom: 4px;
}
.nav-btn.nav-sub i:first-child { color: #f59e0b; font-size: 0.85rem; }
.nav-btn.nav-sub.active {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.04));
    color: #b45309;
}
.nav-btn.nav-sub.active i:first-child { color: #b45309; }

/* Pagination */
.bdc-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding-top: 16px;
    border-top: 1px solid var(--ct-border);
}
.bdc-pagination button {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--ct-border);
    background: #fff;
    border-radius: 9px;
    color: var(--ct-text);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}
.bdc-pagination button:hover:not(:disabled) {
    border-color: var(--ct-primary);
    color: var(--ct-primary);
}
.bdc-pagination button.active {
    background: var(--ct-primary);
    border-color: var(--ct-primary);
    color: #fff;
}
.bdc-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.bdc-pagination .page-info {
    color: var(--ct-muted);
    font-size: 0.85rem;
    padding: 0 12px;
}

.sidebar-footer {
    border-top: 1px solid var(--ct-border);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: var(--ct-muted);
    text-decoration: none;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-size: 0.9rem;
    text-align: left;
    transition: background 0.2s;
}
.sidebar-link:hover { background: var(--ct-soft); }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

/* ---------------------------------------------------------------------------
   Main content
   --------------------------------------------------------------------------- */
.admin-main {
    flex: 1;
    padding: 28px 32px;
    overflow-x: hidden;
    max-width: 100%;
    min-width: 0;
}

.view-header { margin-bottom: 24px; }
.view-title {
    font-weight: 900;
    font-size: 1.75rem;
    color: var(--ct-dark);
    margin: 0 0 4px 0;
    line-height: 1.2;
}
.view-sub {
    color: var(--ct-muted);
    font-size: 0.95rem;
    margin: 0;
}

.u-card {
    background: #fff;
    padding: 24px;
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03), 0 1px 2px rgba(0,0,0,0.02);
    border: 1px solid var(--ct-border);
}

/* ---------------------------------------------------------------------------
   Stat cards
   --------------------------------------------------------------------------- */
.stat-card {
    background: #fff;
    border: 1px solid var(--ct-border);
    border-radius: 16px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.25s;
    height: 100%;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.05); }
.stat-card.sm { padding: 12px 16px; }
.stat-ico {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.stat-val {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ct-dark);
    line-height: 1.1;
    word-break: break-word;
}
.stat-val.small { font-size: 0.95rem; font-weight: 700; }
.stat-lbl {
    font-size: 0.78rem;
    color: var(--ct-muted);
    margin-top: 2px;
    font-weight: 500;
}

/* ---------------------------------------------------------------------------
   Lists & history items
   --------------------------------------------------------------------------- */
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--ct-border);
    margin-bottom: 8px;
    background: #fff;
    gap: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    flex-wrap: wrap;
}
.history-item:hover {
    border-color: var(--ct-primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}
.hi-info { flex: 1; min-width: 200px; cursor: pointer; }
.hi-name { font-weight: 700; color: var(--ct-text); margin-bottom: 2px; }
.hi-meta { font-size: 0.8rem; color: var(--ct-muted); }
.hi-amount { font-weight: 800; color: var(--ct-primary); font-size: 1rem; white-space: nowrap; }

.icon-btn {
    width: 34px; height: 34px;
    border-radius: 10px;
    border: 1px solid var(--ct-border);
    background: #fff;
    color: var(--ct-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.85rem;
}
.icon-btn:hover { border-color: var(--ct-primary); color: var(--ct-primary); }
.icon-btn.danger:hover { border-color: #ef4444; color: #ef4444; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--ct-muted);
}
.empty-state i { font-size: 2.4rem; opacity: 0.35; display: block; margin-bottom: 14px; }
.empty-state .fw-bold { color: var(--ct-text); margin-bottom: 4px; }

/* ---------------------------------------------------------------------------
   Status pills (invoices)
   --------------------------------------------------------------------------- */
.status-pill {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 50px;
    border: 1px solid transparent;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
}
.status-pill.draft     { background: #f1f5f9; color: #64748b; }
.status-pill.sent      { background: #fef3c7; color: #92400e; }
.status-pill.paid      { background: #d1fae5; color: #065f46; }
.status-pill.cancelled { background: #fee2e2; color: #991b1b; }

/* ---------------------------------------------------------------------------
   Invoice editor form
   --------------------------------------------------------------------------- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eff6ff;
    flex-wrap: wrap;
    gap: 10px;
}
.section-header h5 {
    font-weight: 800;
    color: var(--ct-primary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.lbl {
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--ct-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    display: block;
}

#invoiceForm .form-control,
#invoiceForm .form-select {
    background: #f8fafc;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.95rem;
    transition: all 0.2s;
}
#invoiceForm .form-control:focus,
#invoiceForm .form-select:focus {
    background: #fff;
    border-color: var(--ct-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.product-row {
    background: #fdfdfe;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    border: 1px solid #f1f5f9;
}
.product-row:hover { border-color: var(--ct-border); }
.line-total {
    font-weight: 700;
    color: var(--ct-primary);
    text-align: center;
    padding: 8px;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 8px;
    font-size: 0.95rem;
}

.sticky-summary {
    position: sticky;
    top: 20px;
}
.totals { font-size: 0.95rem; }
.t-line {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed var(--ct-border);
}
.t-line.grand {
    border-top: 2px solid var(--ct-primary);
    border-bottom: none;
    margin-top: 8px;
    padding-top: 16px;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--ct-primary);
}

/* ---------------------------------------------------------------------------
   Toast
   --------------------------------------------------------------------------- */
.toast-msg {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--ct-dark);
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 9999;
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 32px);
}
.toast-msg.show { transform: translateX(-50%) translateY(0); }
.toast-msg.success { background: var(--ct-green); }
.toast-msg.error { background: #ef4444; }

/* ---------------------------------------------------------------------------
   Responsive — mobile
   --------------------------------------------------------------------------- */
@media (max-width: 991px) {
    .admin-shell { padding-top: 60px; }
    .admin-main {
        padding: 18px 14px;
        width: 100%;
    }

    .admin-sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        height: 100vh;
        width: 280px;
        max-width: 85vw;
        transform: translateX(-100%);
        box-shadow: 0 0 40px rgba(0,0,0,0.15);
    }
    .admin-sidebar.show { transform: translateX(0); }

    .view-title { font-size: 1.4rem; }
    .view-sub { font-size: 0.875rem; }

    .u-card { padding: 18px; border-radius: 14px; }

    .stat-card { padding: 14px 16px; gap: 12px; }
    .stat-ico { width: 42px; height: 42px; font-size: 1.05rem; }
    .stat-val { font-size: 1.25rem; }
    .stat-lbl { font-size: 0.72rem; }

    .history-item { padding: 12px 14px; gap: 8px; }
    .hi-name { font-size: 0.95rem; }
    .hi-meta { font-size: 0.75rem; }

    .sticky-summary { position: static; }

    .section-header { font-size: 0.85rem; }

    body.sidebar-open { overflow: hidden; }
}

@media (min-width: 992px) {
    .admin-topbar, .sidebar-backdrop { display: none !important; }
}

@media (max-width: 575px) {
    .admin-main { padding: 14px 12px; }
    .view-title { font-size: 1.25rem; }
    .u-card { padding: 16px; border-radius: 12px; }
    .lock-card { padding: 32px 22px; border-radius: 18px; }
}
