/* ==========================================================================
   MAYAH AFRIK — DESIGN SYSTEM "PRO" (v1)
   Nouvelle identité visuelle partagée par tous les modules.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --mp-bg: #0b1220;
    --mp-bg-soft: #f4f6fb;
    --mp-surface: #ffffff;
    --mp-surface-dark: #111a2e;
    --mp-border: #e4e8f1;
    --mp-border-dark: #223052;
    --mp-text: #101828;
    --mp-text-soft: #667085;
    --mp-text-invert: #f2f5fc;
    --mp-primary: #d97706;      /* ambre — chaleur du pain / du logo */
    --mp-primary-dark: #b45309;
    --mp-accent: #0ea5a0;       /* sarcelle — accent "pro" */
    --mp-success: #16a34a;
    --mp-danger: #dc2626;
    --mp-warning: #f59e0b;
    --mp-info: #2563eb;
    --mp-radius: 14px;
    --mp-radius-sm: 10px;
    --mp-shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
    --mp-shadow-lg: 0 20px 45px rgba(16, 24, 40, 0.14);
}

body.mp-body {
    background: var(--mp-bg-soft);
    color: var(--mp-text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    min-height: 100vh;
}

/* ---------- Layout ---------- */
.mp-shell { display: flex; min-height: 100vh; }
.mp-main { flex: 1; min-width: 0; padding: 24px clamp(16px, 3vw, 32px); }

.mp-topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.mp-title { font-weight: 800; font-size: 1.3rem; color: var(--mp-text); margin: 0; letter-spacing: -0.02em; }
.mp-subtitle { color: var(--mp-text-soft); font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.mp-back { color: var(--mp-text-soft); text-decoration: none; font-weight: 700; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 6px; }
.mp-back:hover { color: var(--mp-primary); }

/* ---------- Cards ---------- */
.mp-card {
    background: var(--mp-surface);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    box-shadow: var(--mp-shadow);
    padding: 20px;
}
.mp-card + .mp-card { margin-top: 16px; }

/* ---------- Toolbar / filters ---------- */
.mp-toolbar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    background: var(--mp-surface); border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius); padding: 14px; margin-bottom: 16px;
}
.mp-toolbar .form-control, .mp-toolbar .form-select {
    border-radius: var(--mp-radius-sm); border-color: var(--mp-border); font-size: 0.85rem;
}
.mp-toolbar .form-control:focus, .mp-toolbar .form-select:focus {
    border-color: var(--mp-primary); box-shadow: 0 0 0 3px rgba(217,119,6,0.12);
}

/* ---------- Buttons ---------- */
.mp-btn {
    display: inline-flex; align-items: center; gap: 8px;
    border-radius: var(--mp-radius-sm); font-weight: 700; font-size: 0.85rem;
    padding: 9px 16px; border: 1px solid transparent; cursor: pointer;
    transition: 0.15s ease; text-decoration: none;
}
.mp-btn-primary { background: var(--mp-primary); color: #fff; }
.mp-btn-primary:hover { background: var(--mp-primary-dark); color: #fff; }
.mp-btn-outline { background: var(--mp-surface); color: var(--mp-text); border-color: var(--mp-border); }
.mp-btn-outline:hover { border-color: var(--mp-primary); color: var(--mp-primary); }
.mp-btn-danger { background: #fef2f2; color: var(--mp-danger); border-color: #fecaca; }
.mp-btn-danger:hover { background: var(--mp-danger); color: #fff; }
.mp-btn-sm { padding: 6px 12px; font-size: 0.78rem; }

/* ---------- Table "pro" ---------- */
.mp-table-wrap { background: var(--mp-surface); border: 1px solid var(--mp-border); border-radius: var(--mp-radius); overflow: hidden; box-shadow: var(--mp-shadow); }
.mp-table-scroll { overflow-x: auto; }
table.mp-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.mp-table thead th {
    background: var(--mp-surface-dark); color: var(--mp-text-invert);
    text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.72rem; font-weight: 700;
    padding: 12px 14px; text-align: left; white-space: nowrap; position: sticky; top: 0;
}
table.mp-table tbody td { padding: 10px 14px; border-bottom: 1px solid var(--mp-border); vertical-align: middle; }
table.mp-table tbody tr:hover { background: #fff7ed; cursor: pointer; }
table.mp-table tbody tr.mp-selected, table.mp-table tbody tr.mp-selected td { background: var(--mp-primary) !important; color: #fff !important; }
table.mp-table tbody tr:last-child td { border-bottom: none; }
.mp-cell-strong { font-weight: 700; }
.mp-cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.mp-text-pos { color: var(--mp-success); font-weight: 700; }
.mp-text-neg { color: var(--mp-danger); font-weight: 700; }
.mp-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 800; }
.mp-badge-ok { background: #ecfdf3; color: var(--mp-success); }
.mp-badge-warn { background: #fffbeb; color: var(--mp-warning); }
.mp-badge-danger { background: #fef2f2; color: var(--mp-danger); }
.mp-badge-info { background: #eff6ff; color: var(--mp-info); }
.mp-empty { padding: 40px 20px; text-align: center; color: var(--mp-text-soft); }

/* ---------- Pagination ---------- */
.mp-pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 14px; border-top: 1px solid var(--mp-border); font-size: 0.82rem; color: var(--mp-text-soft); }
.mp-pagination .mp-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.mp-pagination a.mp-page-link {
    min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; border: 1px solid var(--mp-border); color: var(--mp-text); text-decoration: none; font-weight: 600;
}
.mp-pagination a.mp-page-link.active { background: var(--mp-primary); border-color: var(--mp-primary); color: #fff; }
.mp-pagination a.mp-page-link:hover { border-color: var(--mp-primary); color: var(--mp-primary); }
.mp-pagination a.mp-page-link.active:hover { color: #fff; }

/* ---------- KPI tiles ---------- */
.mp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.mp-kpi { background: var(--mp-surface); border: 1px solid var(--mp-border); border-radius: var(--mp-radius); padding: 16px; }
.mp-kpi-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--mp-text-soft); font-weight: 700; }
.mp-kpi-value { font-size: 1.5rem; font-weight: 800; margin-top: 4px; }

@media (max-width: 768px) {
    .mp-main { padding: 16px; }
    table.mp-table thead th, table.mp-table tbody td { padding: 8px 10px; font-size: 0.78rem; }
}

@media print {
    .no-print { display: none !important; }
}

/* ---------- Toasts (remplace alert()) ---------- */
#mp-toast-container {
    position: fixed; bottom: 20px; right: 20px; z-index: 3000;
    display: flex; flex-direction: column; gap: 10px; max-width: min(360px, calc(100vw - 32px));
}
.mp-toast {
    display: flex; align-items: flex-start; gap: 10px;
    background: var(--mp-surface-dark); color: var(--mp-text-invert);
    border-radius: var(--mp-radius-sm); padding: 13px 14px; box-shadow: var(--mp-shadow-lg);
    font-size: 0.85rem; font-weight: 600; opacity: 0; transform: translateY(12px) scale(0.98);
    transition: 0.25s ease; border-left: 4px solid var(--mp-info);
}
.mp-toast-show { opacity: 1; transform: translateY(0) scale(1); }
.mp-toast i { margin-top: 1px; }
.mp-toast span { flex: 1; line-height: 1.4; }
.mp-toast-close { background: none; border: none; color: rgba(255,255,255,0.6); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0; }
.mp-toast-close:hover { color: #fff; }
.mp-toast-success { border-left-color: var(--mp-success); } .mp-toast-success i { color: var(--mp-success); }
.mp-toast-error { border-left-color: var(--mp-danger); } .mp-toast-error i { color: var(--mp-danger); }
.mp-toast-warning { border-left-color: var(--mp-warning); } .mp-toast-warning i { color: var(--mp-warning); }
.mp-toast-info { border-left-color: var(--mp-info); } .mp-toast-info i { color: var(--mp-info); }

/* ---------- Modale de confirmation "pro" (remplace confirm()) ---------- */
.mp-modal-overlay {
    position: fixed; inset: 0; background: rgba(11,18,32,0.55); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center; z-index: 3100;
    opacity: 0; transition: opacity 0.2s ease; padding: 16px;
}
.mp-modal-show { opacity: 1; }
.mp-modal-box {
    background: var(--mp-surface); border-radius: var(--mp-radius); padding: 28px 26px;
    width: 100%; max-width: 380px; text-align: center; box-shadow: var(--mp-shadow-lg);
    transform: scale(0.94); transition: transform 0.2s ease;
}
.mp-modal-show .mp-modal-box { transform: scale(1); }
.mp-modal-icon {
    width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; margin: 0 auto 14px;
}
.mp-modal-icon-danger { background: #fef2f2; color: var(--mp-danger); }
.mp-modal-icon-info { background: #eff6ff; color: var(--mp-info); }
.mp-modal-icon-success { background: #ecfdf3; color: var(--mp-success); }
.mp-modal-icon-warning { background: #fffbeb; color: var(--mp-warning); }
.mp-modal-title { font-weight: 800; font-size: 1.05rem; margin: 0 0 6px; color: var(--mp-text); }
.mp-modal-text { color: var(--mp-text-soft); font-size: 0.88rem; margin: 0 0 16px; line-height: 1.5; }
.mp-modal-input { text-align: center; font-weight: 700; font-size: 1rem; margin-bottom: 20px; border-radius: var(--mp-radius-sm); border: 1px solid var(--mp-border); padding: 10px; }
.mp-modal-input:focus { outline: none; border-color: var(--mp-primary); box-shadow: 0 0 0 3px rgba(217,119,6,0.12); }
.mp-modal-actions { display: flex; gap: 10px; justify-content: center; }
.mp-modal-actions-center { justify-content: center; }
.mp-btn-danger-solid { background: var(--mp-danger); color: #fff; }
.mp-btn-danger-solid:hover { background: #b91c1c; color: #fff; }
