/* ================================================================
   Merics BO v2 — Design System
   Stack : Bootstrap 5 + Bootstrap Icons + CSS custom
================================================================ */

:root {
  --green-main:    #0d3d2a;
  --green-light:   #1a6644;
  --green-hover:   #0a3022;
  --green-muted:   #9fd4be;
  --sidebar-w:     210px;
  --topbar-h:      50px;
  --border:        #e4e8e4;
  --border-strong: #d0ddd0;
  --bg-page:       #f4f6f4;
  --bg-card:       #ffffff;
  --text-main:     #1a1a1a;
  --text-muted:    #7a8a7a;
  --text-sub:      #9aaa9a;
  --radius-sm:     6px;
  --radius:        8px;
  --radius-card:   10px;
  --success-bg:    #e6f5ec;
  --success-text:  #1a7a44;
  --warning-bg:    #fff8e6;
  --warning-text:  #a06000;
  --danger-bg:     #fdecea;
  --danger-text:   #c0392b;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--text-main); background: var(--bg-page); }

/* ── LAYOUT APP ─────────────────────────────────────────────── */
.m-app        { display: flex; height: 100vh; overflow: hidden; }
.m-main       { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.m-content    { flex: 1; overflow-y: auto; padding: 24px; }

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.m-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--green-main);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.25s ease;
  z-index: 100;
}
.m-sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }
@media (max-width: 991px) {
  .m-sidebar { position: fixed; top: 0; left: 0; height: 100%; transform: translateX(-100%); }
  .m-sidebar.open { transform: translateX(0); }
  .m-sidebar-overlay.open { display: block; }
}
.m-sidebar-logo {
  padding: 15px 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex-shrink: 0;
}
.m-logo-icon { width: 30px; height: 30px; background: #fff; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: var(--green-main); flex-shrink: 0; }
.m-logo-text  { color: #fff; font-size: 13px; font-weight: 500; }
.m-sidebar-close { margin-left: auto; background: none; border: none; color: rgba(255,255,255,.5); font-size: 16px; cursor: pointer; }
.m-sidebar-user  { padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.m-avatar-sm  { width: 28px; height: 28px; border-radius: 50%; background: var(--green-light); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--green-muted); flex-shrink: 0; }
.m-user-name  { font-size: 12px; font-weight: 500; color: rgba(255,255,255,.9); line-height: 1.3; }
.m-user-role  { font-size: 11px; color: rgba(255,255,255,.4); }
.m-nav        { flex: 1; padding: 6px 0; }
.m-nav-section { padding: 10px 14px 3px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.3); font-weight: 600; }
.m-nav-link-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 14px; color: rgba(255,255,255,.65); font-size: 13px;
  text-decoration: none; cursor: pointer; border: none; background: none; width: 100%; text-align: left;
}
.m-nav-link-item:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.9); }
.m-nav-link-item.active { background: rgba(255,255,255,.14); color: #fff; }
.m-nav-link-item i { font-size: 15px; width: 16px; text-align: center; flex-shrink: 0; }
.m-nav-badge  { margin-left: auto; background: #dc3545; color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 10px; font-weight: 600; }
.m-sidebar-footer { margin-top: auto; padding: 10px 0; border-top: 1px solid rgba(255,255,255,.08); flex-shrink: 0; }

/* ── TOPBAR ──────────────────────────────────────────────────── */
.m-topbar { height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; gap: 12px; flex-shrink: 0; }
.m-burger   { background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; padding: 0 4px; }
.m-topbar-search { position: relative; flex: 1; max-width: 280px; }
.m-topbar-search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-sub); font-size: 14px; }
.m-topbar-search input { width: 100%; background: var(--bg-page); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 10px 0 32px; height: 32px; font-size: 13px; color: var(--text-main); }
.m-topbar-search input:focus { outline: none; border-color: var(--green-main); }
.m-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.m-icon-btn  { width: 32px; height: 32px; border-radius: var(--radius); background: none; border: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted); position: relative; }
.m-icon-btn:hover { background: var(--bg-page); }
.m-avatar-top { width: 32px; height: 32px; border-radius: 50%; background: var(--green-main); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--green-muted); cursor: pointer; user-select: none; }

/* ── PAGE HEADER ────────────────────────────────────────────── */
.m-page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.m-page-title  { font-size: 18px; font-weight: 600; margin: 0 0 2px; }
.m-page-sub    { font-size: 12px; color: var(--text-sub); margin: 0; }
.m-breadcrumb  { margin: 0; padding: 0; background: none; font-size: 12px; }
.m-breadcrumb .breadcrumb-item a { color: var(--green-main); text-decoration: none; }
.m-breadcrumb .breadcrumb-item.active { color: var(--text-muted); }
.m-breadcrumb .breadcrumb-item + .breadcrumb-item::before { color: var(--border-strong); }

/* ── KPI GRID ───────────────────────────────────────────────── */
.m-kpi-grid  { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.m-kpi       { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 18px; }
.m-kpi-label { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; display: flex; align-items: center; gap: 5px; }
.m-kpi-value { font-size: 24px; font-weight: 600; line-height: 1; }
.m-kpi-danger .m-kpi-value { color: var(--danger-text); }
.m-kpi-warning .m-kpi-value { color: var(--warning-text); }

/* ── CARDS ──────────────────────────────────────────────────── */
.m-card       { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.m-card-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg-card); }
.m-card-title  { font-size: 13px; font-weight: 600; color: var(--text-main); }
.m-card-body   { padding: 16px; }
.m-card-body.p-0 { padding: 0; }
.m-badge-count { background: var(--green-main); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600; }
.m-link-sm    { font-size: 12px; color: var(--green-main); text-decoration: none; font-weight: 500; }
.m-link-sm:hover { text-decoration: underline; }

/* ── TABLES ─────────────────────────────────────────────────── */
.m-table       { width: 100%; border-collapse: collapse; font-size: 13px; }
.m-table thead th { font-size: 11px; font-weight: 600; color: var(--text-muted); background: #f9faf9; padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.m-table tbody td { padding: 10px 14px; vertical-align: middle; border-bottom: 1px solid #f0f4f0; }
.m-table tbody tr:last-child td { border-bottom: none; }
.m-table tbody tr:hover { background: #f9faf9; }
.m-td-muted  { color: var(--text-muted); }

/* ── PILLS / STATUS ─────────────────────────────────────────── */
.m-pill          { display: inline-flex; align-items: center; font-size: 11px; padding: 2px 9px; border-radius: 10px; font-weight: 500; white-space: nowrap; }
.m-pill-active   { background: var(--success-bg); color: var(--success-text); }
.m-pill-pending  { background: var(--warning-bg); color: var(--warning-text); }
.m-pill-suspended{ background: var(--danger-bg);  color: var(--danger-text); }
.m-pill-draft    { background: #f0f0f0; color: #6c7a6c; border: 1px solid #ddd; }

/* ── TASKS ──────────────────────────────────────────────────── */
.m-task-item  { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f0f4f0; }
.m-task-item:last-child { border-bottom: none; }
.m-task-dot   { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.m-task-high  { background: #dc3545; }
.m-task-med   { background: #f0a500; }
.m-task-low   { background: #1d9e75; }
.m-task-title { font-size: 12px; line-height: 1.45; color: var(--text-main); }
.m-task-title a { color: var(--green-main); text-decoration: none; }
.m-task-title a:hover { text-decoration: underline; }
.m-task-meta  { font-size: 11px; color: var(--text-sub); margin-top: 2px; }

/* ── FORMS ──────────────────────────────────────────────────── */
.m-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
.m-input  { width: 100%; background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 10px; height: 36px; font-size: 13px; color: var(--text-main); transition: border-color .15s; }
.m-input:focus { outline: none; border-color: var(--green-main); box-shadow: 0 0 0 3px rgba(13,61,42,.08); }
.m-input:disabled { background: var(--bg-page); color: var(--text-muted); cursor: not-allowed; }

/* ── BUTTONS ────────────────────────────────────────────────── */
.m-btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--green-main); color: #fff; border: none; border-radius: var(--radius); padding: 0 18px; height: 36px; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .15s; text-decoration: none; }
.m-btn-primary:hover { background: var(--green-hover); color: #fff; }
.m-btn-secondary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: #fff; color: var(--text-main); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 14px; height: 36px; font-size: 13px; cursor: pointer; transition: background .15s; text-decoration: none; }
.m-btn-secondary:hover { background: var(--bg-page); }
.m-btn-danger { background: var(--danger-bg); color: var(--danger-text); border: 1px solid #f7c1c1; border-radius: var(--radius); padding: 0 14px; height: 36px; font-size: 13px; cursor: pointer; }
.m-btn-ghost  { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: none; color: var(--text-sub); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px; height: 36px; font-size: 13px; cursor: pointer; text-decoration: none; transition: background .15s, color .15s; }
.m-btn-ghost:hover { background: var(--bg-page); color: var(--text-main); }
.w-100 { width: 100%; }
.btn-sm { height: 28px; padding: 0 8px; font-size: 12px; }

/* ── ALERTS ─────────────────────────────────────────────────── */
.m-alert        { display: flex; align-items: flex-start; gap: 8px; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; }
.m-alert-success { background: var(--success-bg); color: var(--success-text); border: 1px solid #b8e2c8; }
.m-alert-error  { background: var(--danger-bg);  color: var(--danger-text);  border: 1px solid #f7c1c1; }
.m-alert-warning { background: var(--warning-bg); color: var(--warning-text); border: 1px solid #ffe08a; }

/* ── AVATAR large ───────────────────────────────────────────── */
.m-avatar-lg { width: 64px; height: 64px; border-radius: 50%; background: var(--green-main); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 600; color: var(--green-muted); }

/* ── PAGINATION ─────────────────────────────────────────────── */
.m-pagination { display: flex; align-items: center; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); gap: 4px; }
.m-page-btn   { width: 28px; height: 28px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: none; cursor: pointer; font-size: 12px; color: var(--text-muted); display: flex; align-items: center; justify-content: center; }
.m-page-btn.active { background: var(--green-main); color: #fff; border-color: var(--green-main); }
.m-page-btn:hover:not(.active) { background: var(--bg-page); }

/* ── TOOLBAR (liste) ────────────────────────────────────────── */
.m-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.m-toolbar-input  { background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 10px; height: 34px; font-size: 13px; color: var(--text-main); }
.m-toolbar-input:focus { outline: none; border-color: var(--green-main); }
.m-toolbar-select { background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 8px; height: 34px; font-size: 13px; color: var(--text-main); }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .m-content { padding: 16px; }
  .m-kpi-grid { grid-template-columns: 1fr 1fr; }
  .m-table thead th:nth-child(n+4), .m-table tbody td:nth-child(n+4) { display: none; }
}

/* ── TOOLBAR SEARCH wrapper ──────────────────────────────────── */
.m-toolbar-search { position: relative; display: flex; align-items: center; flex: 1; min-width: 200px; max-width: 360px; }
.m-toolbar-search > .bi { position: absolute; left: 10px; color: var(--text-muted); font-size: 13px; pointer-events: none; }
.m-toolbar-search > .m-input { padding-left: 30px; height: 34px; }

/* ── m-select (toolbar selects) ──────────────────────────────── */
.m-select { background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 8px; height: 34px; font-size: 13px; color: var(--text-main); cursor: pointer; }
.m-select:focus { outline: none; border-color: var(--green-main); }

/* ── Badges (status pills) ───────────────────────────────────── */
.m-badge           { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.m-badge-success   { background: var(--success-bg);  color: var(--success-text); }
.m-badge-danger    { background: var(--danger-bg);   color: var(--danger-text);  }
.m-badge-warning   { background: var(--warning-bg);  color: var(--warning-text); }
.m-badge-info      { background: #dbeafe; color: #1e40af; }
.m-badge-secondary { background: var(--bg-page); color: var(--text-muted); border: 1px solid var(--border); }
.m-badge-dark      { background: #374151; color: #fff; }

/* ── Pagination page info ────────────────────────────────────── */
.m-page-info { margin-left: auto; font-size: 12px; color: var(--text-muted); }

/* ── Disable browser autofill yellow highlight ───────────────── */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #fff inset !important;
  -webkit-text-fill-color: var(--text-main) !important;
  transition: background-color 5000s ease-in-out 0s;
}
