/* =====================================================
   SACOTEC — Console d'administration
   ===================================================== */

.admin-body {
    background: #F4F6FB;
    color: var(--gray-900);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
}

.admin-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

/* =========== SIDEBAR =========== */
.admin-sidebar {
    background: linear-gradient(180deg, #050B1F 0%, #0B1A3A 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.admin-brand {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.admin-brand .nav-logo { color: var(--white); font-size: var(--text-lg); }
.admin-brand-sub {
    font-size: var(--text-xs);
    color: rgba(255,255,255,0.45);
    margin-top: 0.25rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.admin-nav {
    flex: 1;
    padding: 1rem 0.5rem;
    overflow-y: auto;
}

.admin-nav-section {
    padding: 1rem 1rem 0.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255,255,255,0.4);
    font-weight: 700;
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    margin: 0.125rem 0;
    border-radius: 8px;
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    position: relative;
}
.admin-nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: var(--white);
}
.admin-nav-link.active {
    background: linear-gradient(135deg, rgba(37,99,235,0.20), rgba(6,182,212,0.15));
    color: var(--white);
    box-shadow: inset 3px 0 0 var(--blue-400);
}
.admin-nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.admin-badge {
    margin-left: auto;
    padding: 0.125rem 0.5rem;
    background: var(--red-500);
    color: var(--white);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
}

.admin-user {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.admin-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
}
.admin-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--grad-accent);
    color: var(--white);
    display: grid;
    place-items: center;
    font-weight: 700;
    flex-shrink: 0;
}
.admin-user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}
.admin-user-email {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}
.admin-logout {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(239,68,68,0.10);
    color: #FCA5A5;
    display: grid;
    place-items: center;
    transition: all 0.2s;
}
.admin-logout:hover {
    background: var(--red-500);
    color: var(--white);
}
.admin-logout svg { width: 16px; height: 16px; }

/* =========== MAIN =========== */
.admin-main {
    background: #F4F6FB;
    min-width: 0;
}

.admin-topbar {
    background: var(--white);
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}
.admin-page-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}
.admin-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.admin-content {
    padding: 2rem;
}

/* =========== STATS CARDS =========== */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.admin-stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}
.admin-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.admin-stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 3px;
    background: var(--grad-accent);
}
.admin-stat-card.stat-success::before { background: linear-gradient(90deg, #10B981, #34D399); }
.admin-stat-card.stat-warning::before { background: linear-gradient(90deg, #F59E0B, #FBBF24); }
.admin-stat-card.stat-info::before { background: linear-gradient(90deg, #06B6D4, #22D3EE); }

.admin-stat-card .stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.admin-stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(37,99,235,0.10);
    color: var(--accent);
    display: grid;
    place-items: center;
}
.admin-stat-card .stat-icon svg { width: 20px; height: 20px; }
.admin-stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}
.admin-stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.1;
}
.admin-stat-card .stat-delta {
    font-size: 0.8rem;
    margin-top: 0.5rem;
}
.admin-stat-card .stat-delta.up { color: #10B981; }
.admin-stat-card .stat-delta.down { color: #EF4444; }

/* =========== PANELS =========== */
.admin-panel {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.admin-panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.admin-panel-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.admin-panel-body { padding: 0; }
.admin-panel-body.padded { padding: 1.5rem; }

/* =========== TABLES =========== */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.admin-table th,
.admin-table td {
    padding: 0.875rem 1.5rem;
    text-align: left;
    vertical-align: middle;
}
.admin-table thead {
    background: #F8FAFC;
    border-bottom: 1px solid var(--border);
}
.admin-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
    font-weight: 700;
}
.admin-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.admin-table tbody tr:hover { background: #F8FAFC; }
.admin-table tbody tr:last-child { border-bottom: 0; }
.admin-table .nowrap { white-space: nowrap; }
.admin-table .col-actions { text-align: right; }

.admin-empty {
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-muted);
}
.admin-empty svg {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    opacity: 0.5;
}

/* =========== BADGES =========== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.status-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-nouveau   { background: rgba(37,99,235,0.10); color: #1E40AF; }
.status-traite    { background: rgba(16,185,129,0.10); color: #047857; }
.status-archive   { background: rgba(100,116,139,0.10); color: #475569; }
.status-contacte  { background: rgba(245,158,11,0.10); color: #B45309; }
.status-planifie  { background: rgba(139,92,246,0.10); color: #6D28D9; }
.status-realise   { background: rgba(16,185,129,0.10); color: #047857; }

/* =========== FORMS (admin) =========== */
.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.admin-search {
    position: relative;
    flex: 1;
    max-width: 360px;
}
.admin-search input {
    width: 100%;
    padding: 0.625rem 0.875rem 0.625rem 2.4rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    background: var(--white);
}
.admin-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}
.admin-search::before {
    content: '';
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* =========== LOGIN PAGE =========== */
.admin-login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--white);
}
@media (max-width: 900px) {
    .admin-login-page { grid-template-columns: 1fr; }
    .admin-login-illustration { display: none; }
}

.admin-login-form-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.admin-login-form {
    width: 100%;
    max-width: 420px;
}
.admin-login-form .nav-logo {
    margin-bottom: 2.5rem;
    font-size: 1.5rem;
}
.admin-login-form h1 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--gray-900);
}
.admin-login-form p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.admin-login-illustration {
    background: var(--grad-hero);
    position: relative;
    overflow: hidden;
    display: grid;
    place-items: center;
    padding: 3rem;
    color: var(--white);
}
.admin-login-illustration::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 30%, rgba(37,99,235,0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 70%, rgba(6,182,212,0.3) 0%, transparent 50%);
}
.admin-login-illustration::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}
.admin-login-illustration .content {
    position: relative;
    z-index: 2;
    text-align: center;
}
.admin-login-illustration h2 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    color: var(--white);
    line-height: 1.1;
    margin-bottom: 1rem;
}
.admin-login-illustration p {
    color: rgba(255,255,255,0.75);
    font-size: 1rem;
    max-width: 380px;
    margin: 0 auto;
}

.alert {
    padding: 0.875rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.alert-error { background: rgba(239,68,68,0.10); color: #b91c1c; border: 1px solid rgba(239,68,68,0.25); }
.alert-success { background: rgba(16,185,129,0.10); color: #047857; border: 1px solid rgba(16,185,129,0.25); }
.alert-warning { background: rgba(245,158,11,0.10); color: #B45309; border: 1px solid rgba(245,158,11,0.25); }

/* Responsive */
@media (max-width: 900px) {
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar {
        position: fixed;
        top: 0; left: -280px;
        z-index: 100;
        width: 280px;
        transition: left 0.25s;
    }
    .admin-sidebar.open { left: 0; }
    .admin-topbar { padding: 1rem; }
    .admin-content { padding: 1rem; }
    .admin-table th, .admin-table td { padding: 0.75rem; }
}
