/* =========================================================
   APPLICATION INVENTAIRE — Feuille de styles
   Cabinet d'expertise comptable
   ========================================================= */
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: #f4f6f9;
    color: #1f2937;
}

/* ===== LOGIN ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2e5aac 0%, #1e3a8a 100%);
    padding: 20px;
}
.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-logo { font-size: 3em; }
.login-box h1 { margin: 8px 0 4px; color: #1e3a8a; }
.login-subtitle { color: #6b7280; margin-bottom: 30px; font-size: 0.9em; }
.login-box form { text-align: left; }

/* ===== LAYOUT ===== */
#app {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas: "sidebar topbar" "sidebar content";
    min-height: 100vh;
}
.sidebar {
    grid-area: sidebar;
    background: #1e3a8a;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo { font-size: 1.6em; }
.sidebar-title { font-weight: bold; font-size: 1.1em; }
.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-link {
    display: block;
    padding: 12px 20px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.95em;
    transition: background 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left: 3px solid #fbbf24;
}
.nav-admin { display: none; }
body.is-admin .nav-admin { display: block; }
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info { margin-bottom: 8px; }
.user-name { font-weight: 600; font-size: 0.95em; }
.user-role { font-size: 0.8em; color: #cbd5e1; text-transform: capitalize; }

.topbar {
    grid-area: topbar;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 10;
}
.topbar h2 { margin: 0; font-size: 1.15em; color: #1f2937; }
.menu-toggle { display: none; background: none; border: none; font-size: 1.5em; cursor: pointer; }

.page-content { grid-area: content; padding: 24px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95em;
    background: #fff;
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #2e5aac;
    box-shadow: 0 0 0 3px rgba(46,90,172,0.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.15s;
}
.btn-primary   { background: #2e5aac; color: #fff; }
.btn-primary:hover   { background: #1e3a8a; }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-danger:hover    { background: #b91c1c; }
.btn-success   { background: #16a34a; color: #fff; }
.btn-success:hover   { background: #15803d; }
.btn-ghost     { background: transparent; color: inherit; border: 1px solid currentColor; }
.btn-block     { width: 100%; }
.btn-sm        { padding: 6px 12px; font-size: 0.85em; }

/* ===== CARDS / TABLES ===== */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    padding: 20px;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}
.card-header h3 { margin: 0; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}
.table th { background: #f9fafb; font-weight: 600; font-size: 0.85em; color: #4b5563; text-transform: uppercase; }
.table tr:hover { background: #f9fafb; }

/* ===== STATS GRID (dashboard) ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.stat-value { font-size: 2em; font-weight: bold; color: #1e3a8a; }
.stat-label { font-size: 0.85em; color: #6b7280; margin-top: 4px; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 0.75em; font-weight: 600; }
.badge-brouillon { background: #e5e7eb; color: #4b5563; }
.badge-en_cours  { background: #dbeafe; color: #1e3a8a; }
.badge-termine   { background: #fef3c7; color: #92400e; }
.badge-valide    { background: #d1fae5; color: #065f46; }
.badge-ouverte       { background: #fee2e2; color: #991b1b; }
.badge-en_traitement { background: #fef3c7; color: #92400e; }
.badge-resolue       { background: #d1fae5; color: #065f46; }
.badge-ignoree       { background: #e5e7eb; color: #4b5563; }

/* ===== ALERTS ===== */
.alert { padding: 12px; border-radius: 6px; margin-top: 12px; font-size: 0.9em; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal {
    background: #fff;
    border-radius: 10px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header { padding: 20px; border-bottom: 1px solid #e5e7eb; display:flex; justify-content:space-between; align-items:center; }
.modal-header h3 { margin: 0; }
.modal-close { background: none; border: none; font-size: 1.5em; cursor: pointer; color: #6b7280; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid #e5e7eb; display: flex; gap: 8px; justify-content: flex-end; }

/* ===== TOAST ===== */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 200; }
.toast {
    background: #1f2937; color: #fff;
    padding: 12px 18px; border-radius: 6px;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: slideIn 0.2s ease-out;
    max-width: 320px;
}
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== UTILS ===== */
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.text-muted { color: #6b7280; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
img.thumb { width: 50px; height: 50px; object-fit: cover; border-radius: 4px; }

/* ===== RESPONSIVE (mobile) ===== */
@media (max-width: 768px) {
    #app {
        grid-template-columns: 1fr;
        grid-template-areas: "topbar" "content";
    }
    .sidebar {
        position: fixed;
        left: -240px;
        width: 240px;
        z-index: 50;
        transition: left 0.2s;
    }
    body.menu-open .sidebar { left: 0; }
    body.menu-open::after {
        content: "";
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 40;
    }
    .menu-toggle { display: block; }
    .form-row { grid-template-columns: 1fr; }
    .table { font-size: 0.85em; }
    .page-content { padding: 16px; }
}
