* { box-sizing: border-box; }

:root {
    --rouge: #c0392b;
    --bleu: #2e75b6;
    --bleu-fonce: #1c4b73;
    --vert: #2ecc71;
    --orange: #e67e22;
    --gris-fond: #eef1f5;
    --texte: #2b2f36;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    color: var(--texte);
    background: var(--gris-fond);
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

/* ============ LOGIN ============ */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1c4b73, #2e75b6 60%, #c0392b);
    padding: 16px;
}
.login-card {
    background: #fff;
    width: 100%;
    max-width: 400px;
    border-radius: 10px;
    padding: 32px 28px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.pictures{
	height:120px;
	margin-left: 110px;
	margin-bottom: 15px;
}

.login-logo {
    width: 56px; height: 56px;
    background: var(--rouge);
    color: #fff;
    font-weight: 800;
    font-size: 20px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 12px;
}
.login-logo.small { width: 36px; height: 36px; font-size: 14px; border-radius: 8px; }
.login-brand h1 { font-size: 20px; margin: 0 0 4px; color: var(--bleu-fonce); }
.login-brand p { margin: 0; color: #fff; font-size: 13px; }
.login-form .field { margin-bottom: 14px; }
.login-form label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.login-form input {
    width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px;
}
.login-hint { text-align: center; font-size: 12px; color: #888; margin-top: 18px; line-height: 1.6; }

.btn-primary {
    background: var(--bleu);
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
}
.btn-primary:hover { background: var(--bleu-fonce); }
.btn-primary.full { width: 100%; padding: 12px; font-size: 15px; }

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

.sidebar {
    width: 240px;
    background: #1a2332;
    color: #cfd7e3;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 16px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 14px;
}
.sidebar-nav { flex: 1; padding: 14px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px;
    border-radius: 6px;
    font-size: 14px;
    color: #b7c2d3;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.active { background: var(--bleu); color: #fff; }
.sidebar-nav .ico { width: 18px; text-align: center; }
.sidebar-footer { padding: 14px 8px; border-top: 1px solid rgba(255,255,255,0.08); }
.logout-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 6px; color: #e6a2a2; font-size: 14px; }
.logout-link:hover { background: rgba(192,57,43,0.15); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: #fff;
    padding: 14px 24px;
    display: flex; align-items: center; gap: 14px;
    border-bottom: 1px solid #e2e6ec;
    position: sticky; top: 0; z-index: 5;
}
.page-title { font-size: 19px; margin: 0; flex: 1; color: var(--bleu-fonce); }
.burger { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-name { font-weight: 600; }
.user-role {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: #999;
}
.user-role.role-admin { background: var(--rouge); }
.user-role.role-gestionnaire { background: var(--bleu); }
.user-role.role-lecteur { background: #7f8c8d; }

.page-content { padding: 22px; flex: 1; }

/* ============ DASHBOARD ============ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border-left: 5px solid #ccc;
}
.stat-card.blue { border-left-color: var(--bleu); }
.stat-card.green { border-left-color: var(--vert); }
.stat-card.orange { border-left-color: var(--orange); }
.stat-card.red { border-left-color: var(--rouge); }
.stat-card.purple { border-left-color: #8e44ad; }
.stat-card.teal { border-left-color: #16a085; }
.stat-icon { font-size: 26px; }
.stat-value { display: block; font-size: 24px; font-weight: 800; color: var(--bleu-fonce); }
.stat-label { display: block; font-size: 12.5px; color: #777; margin-top: 2px; }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.panel-card {
    background: #fff;
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 18px;
}
.panel-card h3 { margin: 0 0 14px; font-size: 15px; color: var(--bleu-fonce); }

.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th { text-align: left; padding: 8px; color: #888; font-weight: 600; border-bottom: 1px solid #eee; }
.mini-table td { padding: 8px; border-bottom: 1px solid #f2f2f2; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; color: #fff; display: inline-block; }
.badge-red { background: var(--rouge); }
.badge-green { background: var(--vert); }
.badge-orange { background: var(--orange); }
.badge-role-admin { background: var(--rouge); }
.badge-role-gestionnaire { background: var(--bleu); }
.badge-role-lecteur { background: #7f8c8d; }

.empty-hint { text-align: center; color: #999; padding: 20px !important; font-style: italic; }

/* ============ TOOLBAR / TABLES ============ */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input {
    margin-left: auto;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    min-width: 220px;
    font-size: 14px;
}
.btn-outline {
    background: #fff;
    border: 1px solid var(--bleu);
    color: var(--bleu);
    padding: 9px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13.5px;
}
.btn-outline:hover { background: #eaf2fa; }
.btn-outline.active-filter { background: var(--bleu); color: #fff; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    background: #f5f7fa;
    text-align: left;
    padding: 10px 12px;
    font-weight: 700;
    color: #555;
    border-bottom: 2px solid #e5e9ef;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid #eef0f3; }
.data-table tbody tr:hover { background: #fafbfc; }

.btn-mini {
    background: var(--bleu);
    color: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    margin-right: 4px;
    display: inline-block;
}
.btn-mini:hover { opacity: .9; }
.btn-mini.btn-danger { background: var(--rouge); }
.btn-mini.btn-mouvement { background: var(--vert); }

/* ============ MODAL ============ */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    align-items: center; justify-content: center;
    z-index: 100;
    padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.modal-box h3 { margin: 0 0 18px; color: var(--bleu-fonce); }
.modal-box .field { margin-bottom: 14px; }
.modal-box label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.modal-box input, .modal-box select {
    width: 100%; padding: 9px 10px; border: 1px solid #ccc; border-radius: 5px; font-size: 14px;
}
.hint-text { font-weight: 400; color: #999; font-size: 11px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---- Modale Mouvement de stock (design amélioré) ---- */
.modal-box-lg { max-width: 620px; padding: 0; overflow: hidden; }
.mvt-modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 26px;
    background: linear-gradient(120deg, var(--rouge), #a5281a);
    color: #fff;
    position: relative;
}
.mvt-modal-header-icon {
    width: 44px; height: 44px;
    background: rgba(255,255,255,0.18);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.mvt-modal-header h3 { margin: 0; font-size: 17px; color: #fff; }
.mvt-modal-subtitle { margin: 3px 0 0; font-size: 12.5px; color: rgba(255,255,255,0.85); font-family: 'Courier New', monospace; }
.mvt-close {
    position: absolute; top: 14px; right: 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.mvt-close:hover { background: rgba(255,255,255,0.3); }

.mvt-modal-body { padding: 22px 26px 4px; }
.mvt-modal-body .row { margin-bottom: 14px; }
.field.compact { padding: 8px 10px; }
.field.compact label { font-size: 12px; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .3px; }
.field.boxed.compact input { padding: 7px 8px; font-size: 13.5px; }
.field.header-box.compact label { padding: 8px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.field.header-box.compact select { padding: 8px 10px; font-size: 13.5px; }
.field.panel.compact, .field.panel-sm.compact { padding: 8px 10px; }
.field.panel.compact textarea { min-height: 64px; font-size: 13.5px; }
.field.panel-sm.compact input { padding: 7px 8px; font-size: 13.5px; }
.mvt-type-field select#mvtType { font-weight: 700; }

.mvt-actions {
    padding: 16px 26px 22px;
    margin-top: 0;
    background: #fafbfc;
    border-top: 1px solid #eef0f3;
}
.btn-mvt-valider { padding: 10px 22px; font-weight: 600; }
.btn-mvt-valider:disabled { background: #9db6c9; cursor: not-allowed; }


/* ============ FORMULAIRE MOUVEMENT (repris de la maquette) ============ */
.form-window {
    background: #fff;
    border-radius: 10px;
    padding: 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    max-width: 760px;
}
.row { display: flex; gap: 16px; margin-bottom: 16px; }
.row.two-cols > .field { flex: 1; min-width: 0; }
.field label { display: block; font-weight: 700; margin-bottom: 8px; font-size: 14px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 9px 10px; border-radius: 4px; font-size: 14px; font-family: inherit;
}
.field.boxed { border: 2px solid var(--rouge); border-radius: 4px; padding: 10px 12px; }
.field.boxed input { border: 1px solid #bbb; background: #fff; }
.field.boxed input[readonly] { background: #fafafa; text-align: right; }
.field.header-box { border: 2px solid var(--rouge); border-radius: 4px; overflow: hidden; padding: 0; display: flex; align-items: center; }
.field.header-box label { background: var(--rouge); color: #fff; margin: 0; padding: 10px 12px; white-space: nowrap; }
.field.header-box select { border: none; flex: 1; padding: 10px 12px; background: #fff; }
.field.panel { border: 1px solid var(--bleu); border-radius: 4px; padding: 10px; }
.field.panel label { color: var(--bleu-fonce); margin-bottom: 6px; }
.field.panel textarea { border: 1px solid #cfd8e3; resize: vertical; min-height: 90px; background: #fff; }
.field.panel textarea::placeholder { color: #999; font-style: italic; }
.field.panel-sm { border: 1px solid var(--bleu); border-radius: 4px; padding: 10px; }
.field.panel-sm label { color: var(--bleu-fonce); margin-bottom: 6px; }
.field.panel-sm input { border: 1px solid #cfd8e3; background: #fff; }
.validate-row { justify-content: flex-end; margin-top: 4px; }
#btnValider {
    background: var(--bleu); color: #fff; border: none; padding: 10px 28px; font-size: 15px;
    border-radius: 4px; cursor: pointer; text-decoration: underline; transition: background .15s;
}
#btnValider:hover { background: var(--bleu-fonce); }
#btnValider:disabled { background: #9db6c9; cursor: not-allowed; }

.alert-box {
    display: none;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-box.success { display: block; background: #e3f6e6; color: #1e7e34; border: 1px solid #b6e6bd; }
.alert-box.error { display: block; background: #fdecea; color: #a12626; border: 1px solid #f5c2c0; }

/* ============ IMPRESSION ============ */
.only-print { display: none; }
.print-header { text-align: center; margin-bottom: 16px; }
.print-header h2 { margin: 0 0 4px; color: #000; }
.print-header p { margin: 0; color: #555; font-size: 12px; }

@media print {
    .sidebar, .topbar, .toolbar, .no-print, .modal-overlay { display: none !important; }
    .only-print { display: block !important; }
    .app-main, .page-content { padding: 0; margin: 0; }
    body { background: #fff; }
    .panel-card { box-shadow: none; padding: 0; }
    .data-table th { background: #eee !important; -webkit-print-color-adjust: exact; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
    .burger { display: block; }
    .sidebar {
        position: fixed; left: -240px; top: 0; z-index: 50;
        transition: left .2s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,0.2);
    }
    .sidebar.open { left: 0; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .search-input { margin-left: 0; width: 100%; }
    .data-table { display: block; overflow-x: auto; white-space: nowrap; }
}
@media (max-width: 600px) {
    .row.two-cols { flex-direction: column; }
    .page-content { padding: 14px; }
    .cards-grid { grid-template-columns: 1fr 1fr; }
}
