/* =====================================================
   GLOBAL — thème repris de STOCK.html
===================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --dark: #0f172a;
    --sidebar: #111827;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
}

body {
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background .3s, color .3s;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font-family: inherit; }

/* =====================================================
   LAYOUT
===================================================== */

.app { display: flex; min-height: 100vh; }

/* SIDEBAR */

.sidebar {
    width: 250px;
    background: linear-gradient(180deg, #111827, #0f172a);
    color: white;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    transition: .3s;
    overflow-y: auto;
}

.logo { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo h2 { font-size: 20px; }
.logo span { color: #60a5fa; }
.logo small { display: block; color: #94a3b8; margin-top: 5px; }

.menu { padding: 20px 12px; }

.menu-title {
    color: #64748b;
    font-size: 11px;
    font-weight: bold;
    padding: 10px 12px;
    text-transform: uppercase;
}

.menu a {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    background: none;
    color: #cbd5e1;
    border: none;
    padding: 13px 14px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    text-align: left;
    transition: .2s;
    text-decoration: none;
}

.menu a:hover { background: #1e293b; color: white; text-decoration: none; }

.menu a.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: 13px;
    color: #94a3b8;
}

.sidebar-footer a { color: #f87171; }

/* MAIN */

.main {
    margin-left: 250px;
    width: calc(100% - 250px);
    min-height: 100vh;
    transition: .3s;
}

/* TOPBAR */

.topbar {
    height: 70px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 15px; }

.menu-toggle { display: none; background: none; border: none; font-size: 25px; cursor: pointer; }

.page-title { font-size: 20px; font-weight: 700; }
.clock { color: var(--muted); font-size: 13px; }

.top-actions { display: flex; gap: 8px; align-items: center; }

/* PROFILE MENU */

.profile-menu { position: relative; }

.icon-btn.profile-btn {
    font-weight: 700;
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    border-radius: 50%;
}

.icon-btn.profile-btn:hover { background: var(--primary-dark); }

.profile-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 250px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(15,23,42,.15);
    overflow: hidden;
    z-index: 200;
}

.profile-dropdown.show { display: block; }

.profile-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 14px 10px;
}

.profile-dropdown-header strong { display: block; font-size: 14px; color: var(--text); }
.profile-dropdown-header span { display: block; font-size: 12px; color: var(--muted); }

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-dropdown a {
    display: block;
    padding: 11px 14px;
    font-size: 13px;
    color: var(--text);
    border-top: 1px solid var(--border);
}

.profile-dropdown a:hover { background: var(--bg); text-decoration: none; }

.icon-btn {
    width: 40px; height: 40px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: .2s;
}

.icon-btn:hover { background: #f1f5f9; transform: translateY(-1px); }

/* CONTENT */

.content { padding: 25px; }

/* =====================================================
   STAT CARDS
===================================================== */

.stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: .25s;
}

.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(15,23,42,.08); }

.stat-card::after {
    content: "";
    position: absolute;
    width: 70px; height: 70px;
    border-radius: 50%;
    right: -25px; top: -25px;
    background: rgba(37,99,235,.08);
}

.stat-top { display: flex; justify-content: space-between; align-items: center; }

.stat-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
}

.stat-card.blue .stat-icon { background: #dbeafe; }
.stat-card.green .stat-icon { background: #dcfce7; }
.stat-card.red .stat-icon { background: #fee2e2; }
.stat-card.orange .stat-icon { background: #fef3c7; }
.stat-card.purple .stat-icon { background: #ede9fe; }

.stat-label { margin-top: 15px; color: var(--muted); font-size: 13px; }
.stat-value { font-size: 28px; font-weight: 800; margin-top: 5px; }

/* =====================================================
   SECTION
===================================================== */

.section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 25px;
}

.section-header {
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 10px;
}

.section-header h1, .section-header h2 { font-size: 17px; }
.section-header p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.section-body { padding: 20px; }

/* =====================================================
   BUTTONS
===================================================== */

.btn {
    border: none;
    padding: 10px 15px;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: transform .15s, opacity .15s, box-shadow .15s;
    background: var(--primary);
    color: white;
}

.btn:hover { background: var(--primary-dark); transform: translateY(-1px); text-decoration: none; }
.btn:active, button:active { transform: scale(.97); }

.btn-secondary {
    background: #475569; color: white;
    border: none; padding: 10px 15px; border-radius: 7px; cursor: pointer; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center;
}
.btn-secondary:hover { background: #334155; text-decoration: none; }

.btn-light { background: #f1f5f9; color: #334155; }

/* =====================================================
   TOOLBAR / FORMS
===================================================== */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    align-items: flex-end;
}

.form { padding: 20px; display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.form-inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; max-width: none; }

.form label, .toolbar label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
}

.form input, .form select, .form textarea,
.toolbar input, .toolbar select,
.input, .select {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    outline: none;
    background: white;
    color: var(--text);
    transition: .2s;
    font-size: 14px;
    font-weight: 400;
    text-transform: none;
}

.form input:focus, .form select:focus, .form textarea:focus,
.input:focus, .select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.form-actions { display: flex; gap: 10px; align-items: center; }

/* =====================================================
   TABLE
===================================================== */

.table-wrap { overflow: auto; }

.table { width: 100%; border-collapse: collapse; min-width: 700px; }

.table thead { background: #f8fafc; }

.table th {
    padding: 13px 12px;
    text-align: left;
    color: #475569;
    font-size: 11px;
    text-transform: uppercase;
    white-space: nowrap;
}

.table td {
    padding: 13px 12px;
    border-top: 1px solid #f1f5f9;
    font-size: 13px;
}

.table tbody tr { transition: .15s; }
.table tbody tr:hover { background: #f8fafc; }
.table tr.row-alert { background: #fef2f2; }

/* BADGES */

.badge {
    padding: 5px 9px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-ok { background: #dcfce7; color: #166534; }
.badge-low { background: #fef3c7; color: #92400e; }
.badge-out { background: #fee2e2; color: #991b1b; }
.badge-in { background: #dcfce7; color: #166534; }

/* ACTIONS */

.actions { display: flex; gap: 12px; align-items: center; }

.link-danger {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 0;
    font: inherit;
    font-weight: 600;
}
.link-danger:hover { text-decoration: underline; }

.empty { padding: 50px; text-align: center; color: #94a3b8; }

/* =====================================================
   ALERTS (fallback non-JS)
===================================================== */

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; font-weight: 600; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* =====================================================
   TOAST
===================================================== */

.toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 280px;
    max-width: 400px;
    padding: 14px 16px;
    border-radius: 9px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 25px rgba(0,0,0,.18);
    transition: opacity .3s, transform .3s;
}

.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
.toast.warning { background: #b45309; }
.toast.info { background: #1d4ed8; }

/* =====================================================
   QUICK ACTIONS (tableau de bord)
===================================================== */

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.quick-action {
    border: 1px solid var(--border);
    background: white;
    border-radius: 10px;
    padding: 18px;
    cursor: pointer;
    text-align: left;
    transition: .2s;
    display: block;
    color: inherit;
}

.quick-action:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: 0 5px 18px rgba(0,0,0,.06); text-decoration: none; }

.quick-action-icon { font-size: 25px; margin-bottom: 10px; }
.quick-action strong { display: block; color: var(--text); }
.quick-action span { color: var(--muted); font-size: 12px; display: block; margin-top: 4px; }

/* =====================================================
   AUTH PAGES
===================================================== */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(180deg, #111827, #0f172a);
}

.auth-box {
    background: var(--card);
    border-radius: 14px;
    padding: 32px;
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 25px 60px rgba(0,0,0,.25);
}

.auth-box h1 { font-size: 20px; }

.auth-box form { display: flex; flex-direction: column; gap: 14px; }

.auth-box label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
}

.auth-box input {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 14px;
}

.auth-box button {
    border: none;
    padding: 10px 15px;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 600;
    background: var(--primary);
    color: white;
}

.auth-box button:hover { background: var(--primary-dark); }

/* =====================================================
   DARK MODE
===================================================== */

body.dark {
    --bg: #020617;
    --card: #0f172a;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #1e293b;
}

body.dark .topbar,
body.dark .section,
body.dark .stat-card,
body.dark .quick-action {
    background: #0f172a;
}

body.dark .table thead { background: #111827; }
body.dark .table td { border-color: #1e293b; }
body.dark .table tbody tr:hover { background: #111827; }
body.dark .table tr.row-alert { background: #3f1d1d; }

body.dark .input,
body.dark .select,
body.dark .icon-btn,
body.dark .form input,
body.dark .form select,
body.dark .form textarea,
body.dark .toolbar input,
body.dark .toolbar select {
    background: #111827;
    color: #e2e8f0;
    border-color: #334155;
}

body.dark .quick-action strong { color: #e2e8f0; }

/* =====================================================
   MOBILE
===================================================== */

@media (max-width: 1200px) {
    .stats { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 850px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; width: 100%; }
    .menu-toggle { display: block; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .quick-actions { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 550px) {
    .content { padding: 14px; }
    .topbar { padding: 0 14px; }
    .page-title { font-size: 16px; }
    .clock { display: none; }
    .stats { grid-template-columns: 1fr; }
    .quick-actions { grid-template-columns: 1fr; }
    .form-inline { flex-direction: column; align-items: stretch; }
}
