/* =========================================================
   Design system - Gestion Documents
   ========================================================= */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --accent: #06b6d4;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #e11d48;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --ink: #1e293b;
    --ink-soft: #64748b;
    --border: #e2e8f0;
    --surface: #ffffff;
    --bg: #f1f5f9;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    margin: 0;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

/* ---------- Navbar ---------- */

.navbar {
    background: linear-gradient(120deg, #1e1b4b 0%, #312e81 55%, #4338ca 100%);
    color: #fff;
    padding: 16px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(30, 27, 75, 0.25);
    position: sticky;
    top: 0;
    z-index: 20;
}

.navbar a {
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    margin-right: 22px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.2px;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.navbar a:hover {
    color: #fff;
    border-bottom-color: var(--accent);
}

.navbar .brand {
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    margin-right: 36px;
    letter-spacing: 0.2px;
}

.navbar > div:last-child {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
}

.navbar > div:last-child a {
    margin-right: 0;
    background: rgba(255, 255, 255, 0.12);
    padding: 7px 14px;
    border-radius: 20px;
}

.navbar > div:last-child a:hover {
    background: rgba(255, 255, 255, 0.22);
    border-bottom-color: transparent;
}

/* ---------- Layout ---------- */

.container {
    max-width: 1100px;
    margin: 32px auto;
    background: var(--surface);
    padding: 32px 36px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

h1 {
    color: var(--ink);
    font-size: 24px;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 22px;
    letter-spacing: -0.3px;
}

h2 {
    color: var(--ink);
    font-size: 16px;
    font-weight: 700;
    margin-top: 28px;
    margin-bottom: 6px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

h3 {
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

/* ---------- Forms ---------- */

label {
    display: block;
    margin-top: 14px;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--ink-soft);
}

input[type=text], input[type=date], input[type=number], input[type=tel],
input[type=email], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: #fbfcfe;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:hover, select:hover, textarea:hover {
    border-color: #cbd5e1;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3.5px var(--primary-light);
}

textarea { resize: vertical; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.btn:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25); }
.btn:active { transform: translateY(1px); }

.btn-secondary { background: #fff; color: var(--ink); border: 1.5px solid var(--border); box-shadow: none; }
.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; box-shadow: none; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #be123c; box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25); }

.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }

/* ---------- Table ---------- */

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 18px;
    font-size: 14px;
}

th, td {
    padding: 13px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: #f8fafc;
    color: var(--ink-soft);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

th:first-child { border-top-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); }

tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges ---------- */

.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.badge-devis { background: #7c3aed; }
.badge-bon_commande { background: #2563eb; }
.badge-bon_livraison { background: #d97706; }
.badge-facture { background: #16a34a; }

/* ---------- Login ---------- */

.login-box {
    max-width: 380px;
    margin: 110px auto;
    background: var(--surface);
    padding: 40px 36px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-align: center;
}

.login-box h1 {
    margin-bottom: 6px;
    font-size: 22px;
}

.login-box p {
    color: var(--ink-soft);
    font-size: 14px;
    margin-top: 0;
    margin-bottom: 4px;
}

.login-box .btn { width: 100%; margin-top: 18px; padding: 12px; font-size: 15px; }

/* ---------- Actions / misc ---------- */

.actions { white-space: nowrap; }
.actions a, .actions button { margin-right: 6px; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-error { background: var(--danger-light); color: #9f1239; border-color: #fecdd3; }
.alert-success { background: var(--success-light); color: #166534; border-color: #bbf7d0; }

.filters {
    display: flex;
    gap: 16px;
    margin-bottom: 6px;
    align-items: end;
    flex-wrap: wrap;
    background: #f8fafc;
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.filters div { flex: 1; min-width: 180px; }
.filters label { margin-top: 0; }

.items-table input { padding: 8px 10px; }
.items-table th { background: transparent; border-bottom: 1.5px solid var(--border); }

.total-row td {
    font-weight: 700;
    background: var(--primary-light);
    color: var(--primary-dark);
}

.total-row:last-child td {
    font-size: 15.5px;
    background: var(--ink);
    color: #fff;
}

/* ---------- Print ---------- */

@media print {
    .navbar, .no-print { display: none !important; }
    body { background: #fff; }
    .container {
        box-shadow: none;
        border: none;
        margin: 0;
        max-width: 100%;
        padding: 0;
    }
}

/* ---------- Responsive ---------- */

@media (max-width: 700px) {
    .container { margin: 12px; padding: 20px; }
    .navbar { flex-direction: column; align-items: flex-start; gap: 10px; }
    .navbar > div:last-child { flex-wrap: wrap; }
}
