/* ============================================
   INTRANET MIRVAL — Feuille de style principale
   ============================================ */

/* ---- Variables ---- */
:root {
    --primary:      #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light:#eff6ff;
    --success:      #16a34a;
    --warning:      #d97706;
    --danger:       #dc2626;
    --purple:       #7c3aed;
    --sidebar-bg:   #0f172a;
    --sidebar-w:    260px;
    --topbar-h:     64px;
    --bg:           #f1f5f9;
    --card-bg:      #ffffff;
    --border:       #e2e8f0;
    --text:         #1e293b;
    --text-muted:   #64748b;
    --radius:       10px;
    --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
    --transition:   .2s ease;
}

/* ---- Reset / Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ============================================
   LAYOUT
   ============================================ */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-logo {
    width: 40px; height: 40px;
    background: var(--primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; color: #fff;
    flex-shrink: 0;
}
.brand-name  { display: block; font-weight: 700; color: #f1f5f9; font-size: .95rem; }
.brand-version { font-size: .7rem; color: #64748b; }

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 1rem .75rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.nav-section-label {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #475569;
    padding: .5rem .5rem .25rem;
    margin-top: .25rem;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .75rem;
    border-radius: 7px;
    color: #94a3b8;
    font-size: .875rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    position: relative;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #f1f5f9; text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link i { width: 18px; text-align: center; font-size: .9rem; }
.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: .15rem .4rem;
    border-radius: 20px;
    min-width: 18px;
    text-align: center;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 1rem .75rem;
    border-top: 1px solid rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    gap: .75rem;
}
.user-info { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.user-avatar {
    width: 34px; height: 34px;
    background: var(--primary);
    color: #fff; font-size: .75rem; font-weight: 700;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.user-details { min-width: 0; }
.user-name  { display: block; font-size: .8rem; font-weight: 600; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { display: block; font-size: .7rem; color: #64748b; }
.btn-logout {
    color: #64748b; padding: .4rem; border-radius: 6px;
    transition: color var(--transition), background var(--transition);
}
.btn-logout:hover { color: var(--danger); background: rgba(220,38,38,.1); text-decoration: none; }

/* ---- Main content ---- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.sidebar-toggle {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 1.1rem; padding: .4rem;
    border-radius: 6px;
    display: none;
}
.topbar-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    flex: 1;
}
.topbar-actions { display: flex; gap: .5rem; }
.notif-btn {
    position: relative;
    color: var(--text-muted);
    font-size: 1rem;
    padding: .5rem;
    border-radius: 8px;
    transition: background var(--transition), color var(--transition);
}
.notif-btn:hover { background: var(--bg); color: var(--primary); text-decoration: none; }
.notif-count {
    position: absolute; top: 0; right: 0;
    background: var(--danger); color: #fff;
    font-size: .6rem; font-weight: 700;
    width: 16px; height: 16px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

/* Page content */
.page-content {
    flex: 1;
    padding: 1.75rem;
    max-width: 1400px;
    width: 100%;
}
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header h2 { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.text-muted { color: var(--text-muted); font-size: .875rem; }

/* ============================================
   CARTES
   ============================================ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-full { grid-column: 1 / -1; }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}
.card-header h3 { font-size: .95rem; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.card-body { padding: 1.25rem; }
.card-danger  { border-left: 4px solid var(--danger); }
.card-success { border-left: 4px solid var(--success); }

/* ============================================
   STATS CARDS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stats-grid-5 { grid-template-columns: repeat(5, 1fr); }
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    border-left: 4px solid transparent;
}
.stat-card-blue   { border-left-color: var(--primary); }
.stat-card-green  { border-left-color: var(--success); }
.stat-card-orange { border-left-color: var(--warning); }
.stat-card-red    { border-left-color: var(--danger); }
.stat-card-purple { border-left-color: var(--purple); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.stat-card-blue   .stat-icon { background: #eff6ff; color: var(--primary); }
.stat-card-green  .stat-icon { background: #f0fdf4; color: var(--success); }
.stat-card-orange .stat-icon { background: #fffbeb; color: var(--warning); }
.stat-card-red    .stat-icon { background: #fef2f2; color: var(--danger); }
.stat-card-purple .stat-icon { background: #f5f3ff; color: var(--purple); }
.stat-number { font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label  { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }

/* ============================================
   TABLEAUX
   ============================================ */
.table-responsive { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.table th {
    text-align: left;
    padding: .65rem 1rem;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table.table-hover tbody tr:hover { background: var(--bg); }
.row-critique { background: #fff5f5 !important; }
.row-urgente  { background: #fffbeb !important; }

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex; align-items: center;
    padding: .25rem .65rem;
    border-radius: 20px;
    font-size: .7rem; font-weight: 600;
    white-space: nowrap;
}
.badge-normale   { background: #f0f9ff; color: #0369a1; }
.badge-urgente   { background: #fffbeb; color: #92400e; }
.badge-critique  { background: #fef2f2; color: #991b1b; }
.badge-attente   { background: #fffbeb; color: #92400e; }
.badge-approuvee { background: #f0fdf4; color: #166534; }
.badge-refusee   { background: #fef2f2; color: #991b1b; }
.badge-commandee { background: #eff6ff; color: #1e40af; }
.badge-livree    { background: #f5f3ff; color: #5b21b6; }

/* ============================================
   BOUTONS
   ============================================ */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .55rem 1.1rem;
    border-radius: 7px;
    font-size: .875rem; font-weight: 500;
    border: none; cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .92; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); opacity: 1; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: .35rem .75rem; font-size: .78rem; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================
   FORMULAIRES
   ============================================ */
.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .75rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
label { font-size: .82rem; font-weight: 500; color: var(--text); }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: .6rem .85rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: .875rem;
    color: var(--text);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
input:disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }
.form-hint { font-size: .75rem; color: var(--text-muted); }
.required { color: var(--danger); }

.input-password { position: relative; }
.input-password input { padding-right: 2.75rem; }
.toggle-password {
    position: absolute; right: .75rem; top: 50%;
    transform: translateY(-50%);
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: .9rem;
}
.form-actions {
    display: flex; gap: .75rem; justify-content: flex-end;
    margin-top: 1.25rem; padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

/* Prix total display */
.prix-total-display {
    padding: .65rem .85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: .875rem;
    color: var(--text-muted);
    min-height: 2.5rem;
    display: flex; align-items: center;
}
.prix-total-display.has-value { color: var(--success); font-weight: 600; }

/* Jauge force mot de passe */
.password-strength { margin-top: .25rem; }
.strength-bar {
    height: 4px; width: 0;
    background: #ddd;
    border-radius: 2px;
    transition: width .3s, background .3s;
}
.strength-label { font-size: .72rem; color: var(--text-muted); }

/* ============================================
   FILTRES
   ============================================ */
.filter-card { margin-bottom: 1rem; }
.filter-card .card-body { display: none; }
.filter-form {
    display: flex; flex-wrap: wrap; gap: .75rem;
    align-items: flex-end;
    padding: 1rem 1.25rem;
}
.filter-form .form-group { margin-bottom: 0; min-width: 150px; }

/* ============================================
   ALERTES
   ============================================ */
.alert {
    display: flex; align-items: flex-start; gap: .75rem;
    padding: .9rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: .875rem;
    border: 1px solid transparent;
}
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: .4; display: block; }
.empty-state p { margin-bottom: 1rem; }

/* ============================================
   PAGINATION
   ============================================ */
.pagination { display: flex; gap: .35rem; justify-content: center; margin-top: 1.25rem; }
.page-btn {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border-radius: 7px;
    font-size: .82rem; font-weight: 500;
    color: var(--text);
    border: 1px solid var(--border);
    transition: background var(--transition), color var(--transition);
}
.page-btn:hover { background: var(--primary-light); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============================================
   DETAIL GRID
   ============================================ */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
.detail-list { display: grid; grid-template-columns: 130px 1fr; gap: .5rem .75rem; align-items: start; }
.detail-list dt { font-size: .78rem; font-weight: 600; color: var(--text-muted); padding-top: .15rem; }
.detail-list dd { font-size: .875rem; color: var(--text); }
.detail-list dd.desc { white-space: pre-line; }
.price-big { font-size: 1.15rem; font-weight: 700; color: var(--success); }

/* ============================================
   DASHBOARD GRID
   ============================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.chart-container { min-height: 260px; display: flex; align-items: center; justify-content: center; }

/* ============================================
   CATÉGORIES BAR
   ============================================ */
.category-bars { display: flex; flex-direction: column; gap: .85rem; }
.cat-bar-row { display: grid; grid-template-columns: 180px 1fr 200px; gap: .75rem; align-items: center; }
.cat-bar-label { font-size: .82rem; font-weight: 500; color: var(--text); }
.cat-bar-track { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.cat-bar-fill  { height: 100%; background: var(--primary); border-radius: 4px; transition: width .6s ease; }
.cat-bar-stats { display: flex; justify-content: space-between; font-size: .78rem; color: var(--text-muted); }

/* ============================================
   USER CELL
   ============================================ */
.user-cell { display: flex; align-items: center; gap: .6rem; }
.user-avatar-sm {
    width: 28px; height: 28px;
    background: var(--primary);
    color: #fff; font-size: .65rem; font-weight: 700;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ============================================
   NOTIFICATIONS
   ============================================ */
.notif-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.notif-item {
    display: flex; align-items: flex-start; gap: .75rem;
    padding: .85rem 1rem;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
}
.notif-item.unread { background: var(--primary-light); border-color: #bfdbfe; }
.notif-icon { color: var(--primary); margin-top: .15rem; flex-shrink: 0; }
.notif-body { flex: 1; }
.notif-body p { font-size: .875rem; color: var(--text); }
.notif-body small { color: var(--text-muted); font-size: .75rem; }

/* ============================================
   ACTIONS CELL
   ============================================ */
.actions-cell { display: flex; gap: .5rem; flex-wrap: wrap; }
.link-icon { margin-left: .25rem; color: var(--text-muted); font-size: .75rem; }
.link-icon:hover { color: var(--primary); }

/* ============================================
   AUTH (login / register)
   ============================================ */
.auth-body { background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%); min-height: 100vh; }
.auth-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 2rem 1rem;
}
.auth-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    padding: 2.5rem;
    width: 100%; max-width: 420px;
}
.auth-card-wide { max-width: 640px; }
.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-logo {
    width: 60px; height: 60px;
    background: var(--primary);
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.5rem; color: #fff;
    margin-bottom: .75rem;
}
.auth-brand h1 { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.auth-brand p  { color: var(--text-muted); font-size: .875rem; }
.auth-form { display: flex; flex-direction: column; gap: .25rem; }
.auth-links { text-align: center; margin-top: 1.25rem; font-size: .85rem; color: var(--text-muted); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .stats-grid-5 { grid-template-columns: repeat(3, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .cat-bar-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }

    .sidebar {
        transform: translateX(-260px);
        width: 260px;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-grid-5 { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .filter-form { flex-direction: column; }
    .filter-form .form-group { min-width: 100%; }
    .page-content { padding: 1rem; }
}

@media (max-width: 480px) {
    .stats-grid, .stats-grid-5 { grid-template-columns: 1fr; }
    .auth-card { padding: 1.5rem; }
    .table th, .table td { padding: .5rem .65rem; font-size: .8rem; }
}

/* Overlay sidebar mobile */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}
.sidebar-overlay.active { display: block; }
