/* ================================================================
   ZAAG - Plateforme Nationale de Gestion Municipale - GABON
   Feuille de style principale
   ================================================================ */

/* --- Variables -------------------------------------------------- */
:root {
    --primary:      #1a3c6e;
    --primary-dark: #122b52;
    --primary-light:#2a5ba0;
    --secondary:    #d4a017;
    --accent:       #009a44;  /* vert Gabon */
    --danger:       #c0392b;
    --warning:      #e67e22;
    --success:      #27ae60;
    --info:         #2980b9;
    --dark:         #1c1c2e;
    --gray-100:     #f8f9fa;
    --gray-200:     #e9ecef;
    --gray-300:     #dee2e6;
    --gray-600:     #6c757d;
    --gray-800:     #343a40;
    --white:        #ffffff;
    --shadow-sm:    0 2px 6px rgba(0,0,0,.08);
    --shadow-md:    0 4px 20px rgba(0,0,0,.12);
    --shadow-lg:    0 8px 40px rgba(0,0,0,.16);
    --radius:       8px;
    --radius-lg:    16px;
    --transition:   all .25s ease;
    --font-main:    'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* --- Reset ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body { font-family: var(--font-main); color: var(--dark); background: var(--gray-100); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-light); }
img { max-width: 100%; height: auto; display: block; }
ul { list-style: none; }

/* --- Utilitaires ----------------------------------------------- */
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.d-flex      { display: flex; }
.align-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.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; }
.mb-3 { margin-bottom: 24px; }
.p-3 { padding: 24px; }
.hidden { display: none !important; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-success { background: #d5f5e3; color: #1e8449; }
.badge-danger  { background: #fadbd8; color: #922b21; }
.badge-warning { background: #fdebd0; color: #b7770d; }
.badge-info    { background: #d6eaf8; color: #1a5276; }
.badge-secondary { background: var(--gray-200); color: var(--gray-600); }

/* Boutons */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius); border: none; cursor: pointer;
    font-size: .9rem; font-weight: 600; transition: var(--transition); white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); transform: translateY(-1px); }
.btn-secondary{ background: var(--gray-200); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-success  { background: var(--success); color: var(--white); }
.btn-success:hover { background: #219a52; }
.btn-danger   { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #a93226; }
.btn-warning  { background: var(--warning); color: var(--white); }
.btn-outline  { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: var(--white); }
.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }

/* Cards */
.card {
    background: var(--white); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-header {
    padding: 18px 24px; border-bottom: 1px solid var(--gray-200);
    font-weight: 700; color: var(--primary);
}
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); background: var(--gray-100); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .875rem; font-weight: 600; color: var(--gray-800); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-300);
    border-radius: var(--radius); font-size: .9rem; font-family: var(--font-main);
    transition: var(--transition); background: var(--white); color: var(--dark);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,60,110,.1); }
.form-control::placeholder { color: var(--gray-600); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.table th { background: var(--primary); color: var(--white); padding: 12px 16px; text-align: left; font-weight: 600; white-space: nowrap; }
table.table td { padding: 12px 16px; border-bottom: 1px solid var(--gray-200); vertical-align: middle; }
table.table tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: #f0f4ff; }

/* Alertes */
.alert { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 16px; font-size: .9rem; display: flex; align-items: center; gap: 10px; }
.alert-success { background: #d5f5e3; color: #1e8449; border-left: 4px solid var(--success); }
.alert-danger  { background: #fadbd8; color: #922b21; border-left: 4px solid var(--danger); }
.alert-warning { background: #fdebd0; color: #b7770d; border-left: 4px solid var(--warning); }
.alert-info    { background: #d6eaf8; color: #1a5276; border-left: 4px solid var(--info); }

/* Spinner */
.spinner { width: 40px; height: 40px; border: 4px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55);
    z-index: 9999; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--white); border-radius: var(--radius-lg); width: 90%; max-width: 640px;
    max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
    animation: slideUp .3s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--gray-200); }
.modal-header h3 { color: var(--primary); font-size: 1.1rem; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--gray-600); line-height: 1; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; gap: 12px; justify-content: flex-end; }

/* Toast notifications */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--dark); color: var(--white); padding: 14px 20px; border-radius: var(--radius);
    box-shadow: var(--shadow-md); min-width: 280px; max-width: 360px;
    display: flex; align-items: center; gap: 12px; font-size: .9rem;
    animation: toastIn .3s ease;
}
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }
.toast-success { border-left: 4px solid var(--success); }
.toast-danger  { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info    { border-left: 4px solid var(--info); }

/* Pagination */
.pagination { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.page-btn { padding: 8px 14px; border: 1.5px solid var(--gray-300); border-radius: var(--radius); background: var(--white); cursor: pointer; font-size: .85rem; transition: var(--transition); }
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.page-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Stat cards */
.stat-card {
    background: var(--white); border-radius: var(--radius-lg); padding: 24px;
    box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 16px;
    transition: var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card .icon { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; flex-shrink: 0; }
.stat-card .value { font-size: 1.8rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-card .label { font-size: .82rem; color: var(--gray-600); margin-top: 4px; }

/* Grid utilitaires */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }

@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .container { padding: 0 16px; }
}

/* Progress bar */
.progress { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width .5s ease; }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }
