/* ── Reset & Variables ───────────────────────────────────────── */
:root {
  --primary:    #0D1B2A;
  --primary-lt: #1a2d42;
  --accent:     #1a73e8;
  --success:    #1e8e3e;
  --warning:    #f9ab00;
  --danger:     #d93025;
  --bg:         #f1f3f6;
  --surface:    #ffffff;
  --border:     #dadce0;
  --text:       #202124;
  --text-muted: #5f6368;
  --sidebar-w:  260px;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Open Sans', system-ui, sans-serif; background: var(--bg); color: var(--text); display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); background: var(--primary); color: #fff;
  display: flex; flex-direction: column; position: fixed; height: 100vh;
  z-index: 100; transition: transform 0.3s ease;
}
.sidebar-brand {
  padding: 20px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.brand-name { display: block; font-size: 14px; font-weight: 700; color: #fff; }
.brand-sub  { display: block; font-size: 11px; color: rgba(255,255,255,.5); }
.sidebar-user {
  padding: 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout { background: none; border: none; color: rgba(255,255,255,.5); font-size: 11px; cursor: pointer; padding: 0; margin-top: 2px; }
.btn-logout:hover { color: #fff; }
.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-section-label {
  padding: 16px 16px 6px; font-size: 10px; font-weight: 700;
  color: rgba(255,255,255,.35); letter-spacing: 1.2px; text-transform: uppercase;
}
.nav-links { list-style: none; }
.nav-links li a {
  display: block; padding: 10px 16px; color: rgba(255,255,255,.7);
  text-decoration: none; font-size: 13px; transition: all .15s;
  border-left: 3px solid transparent; margin: 1px 0;
}
.nav-links li a:hover { color: #fff; background: rgba(255,255,255,.06); border-left-color: rgba(255,255,255,.2); }
.nav-links li a.active { color: #fff; background: rgba(26,115,232,.25); border-left-color: var(--accent); font-weight: 600; }

/* Sidebar toggle (mobile) */
.sidebar-toggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 200;
  background: var(--primary); color: #fff; border: none; border-radius: 8px;
  padding: 8px 12px; font-size: 18px; cursor: pointer; box-shadow: var(--shadow);
}

/* ── Main ────────────────────────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* Header */
.header {
  background: var(--surface); padding: 16px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.header h1 { font-size: 18px; font-weight: 700; color: var(--text); }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-user { font-size: 13px; color: var(--text-muted); }

/* ── Status badge ────────────────────────────────────────────── */
.status-badge { font-size: 13px; padding: 4px 12px; border-radius: 20px; font-weight: 600; }
.status-ok      { background: #e8f8f1; color: var(--success); }
.status-error   { background: #fdecea; color: var(--danger); }
.status-checking{ background: #f0f4f8; color: var(--text-muted); }

/* ── Pages ───────────────────────────────────────────────────── */
.page { display: none; padding: 28px; }
.page.active { display: block; }

/* ── Stats ───────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 24px 20px;
  box-shadow: var(--shadow); text-align: center; transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); }

/* ✅ EVO-008 — Dashboard widgets (3 médias) */
.dashboard-widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 20px;
  margin: 0;
}

.dashboard-widget {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-top: 4px solid transparent;
}

.dashboard-widget.media-voice { border-top-color: #0077CC; }
.dashboard-widget.media-sms   { border-top-color: #27ae60; }
.dashboard-widget.media-rcs   { border-top-color: #f39c12; }

.widget-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.widget-media-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.widget-media-badge.voice { background: #e8f4fd; color: #0077CC; }
.widget-media-badge.sms   { background: #e8f8f1; color: #27ae60; }
.widget-media-badge.rcs   { background: #fef9e7; color: #f39c12; }

.widget-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.widget-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.widget-section {
  margin-bottom: 20px;
}

.widget-section:last-child {
  margin-bottom: 0;
}

.widget-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.suppliers-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 240px;
  overflow-y: auto;
}

.supplier-item {
  background: #f8fbff;
  padding: 12px;
  border-radius: 6px;
  border-left: 3px solid var(--accent);
  font-size: 13px;
}

.supplier-name {
  font-weight: 600;
  color: var(--primary);
  display: flex;
  gap: 8px;
  align-items: center;
}

.supplier-version {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(0, 119, 204, 0.1);
  border-radius: 4px;
  font-size: 11px;
  color: #0077CC;
  font-weight: 600;
}

.supplier-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  gap: 12px;
}

.supplier-count {
  background: rgba(0, 119, 204, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
}

.supplier-date {
  font-size: 11px;
  color: #999;
}

.selling-rate-info {
  background: #f8fbff;
  padding: 12px;
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.selling-rate-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.selling-rate-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}

.widget-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px;
  text-align: center;
}

/* ── Card ────────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card h2 { font-size: 16px; font-weight: 700; color: var(--primary); margin-bottom: 20px; }

/* ── Toolbar ─────────────────────────────────────────────────── */
.toolbar { margin-bottom: 16px; display: flex; gap: 10px; align-items: center; }

/* Tableaux */
th { background: #f8f9fa; color: var(--text-muted); padding: 10px 14px; text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; border-bottom: 1px solid var(--border); }
td { padding: 11px 14px; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
tr:hover td { background: #fafafa; }
tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.badge-voice   { background: #e8f4fd; color: #0077CC; }
.badge-sms     { background: #e8f8f1; color: #27ae60; }
.badge-rcs     { background: #fef9e7; color: #f39c12; }
.badge-active  { background: #e8f8f1; color: var(--success); }
.badge-inactive{ background: #fdecea; color: var(--danger); }

/* Boutons */
.btn { padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; font-weight: 500; transition: all .15s; }
.btn-primary   { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.btn-primary:hover { background: #1557b0; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f8f9fa; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c62828; }
.btn-sm        { padding: 5px 10px; font-size: 12px; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 160px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.form-group input, .form-group select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--text); background: #fff; transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--accent); }
.form-group-action { flex: 0 0 auto; }
.checkbox-group { display: flex; gap: 16px; }
.checkbox-group label { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--text); text-transform: none; font-weight: normal; }

/* ── Compare results ─────────────────────────────────────────── */
.compare-result-card {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 12px; display: flex; align-items: center; gap: 16px;
  border-left: 4px solid var(--border);
}
.compare-result-card.cheapest { border-left-color: var(--success); }
.compare-result-card .rank { font-size: 24px; font-weight: 700; color: var(--text-muted); width: 32px; }
.compare-result-card.cheapest .rank { color: var(--success); }
.compare-result-card .info { flex: 1; }
.compare-result-card .supplier-name { font-weight: 700; font-size: 15px; color: var(--primary); }
.compare-result-card .destination { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.compare-result-card .rate-value { font-size: 22px; font-weight: 700; color: var(--primary); }
.compare-result-card .rate-unit { font-size: 12px; color: var(--text-muted); }
.cheapest-badge { background: var(--success); color: #fff; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal.hidden { display: none; }
.modal-content { background: var(--surface); border-radius: var(--radius); padding: 28px; width: 500px; max-width: 95vw; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h3 { font-size: 18px; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-footer { margin-top: 24px; display: flex; justify-content: flex-end; gap: 10px; }

/* ── Media groups ────────────────────────────────────────────── */
.media-group { margin-bottom: 28px; }
.media-group h3 { font-size: 14px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.count { background: var(--border); color: var(--text-muted); padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }

/* ── Meta table ──────────────────────────────────────────────── */
.meta-table { width: auto; }
.meta-table th { background: none; color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; padding: 8px 16px 8px 0; border-bottom: none; }
.meta-table td { padding: 8px 16px 8px 0; border-bottom: none; font-size: 14px; }

/* ── Inline editing ──────────────────────────────────────────── */
.editing-row td { background: #f8fbff; }
.inline-input { padding: 5px 8px; border: 1px solid var(--accent); border-radius: 4px; font-size: 13px; width: 100%; min-width: 80px; }

/* ── Misc ────────────────────────────────────────────────────── */
.loading { color: var(--text-muted); padding: 24px; text-align: center; font-size: 14px; }
.empty   { color: var(--text-muted); padding: 40px; text-align: center; font-size: 14px; }
.alert { padding: 12px 16px; border-radius: var(--radius); margin-top: 16px; font-size: 14px; }
.alert-success { background: #e8f8f1; color: var(--success); border: 1px solid #a9dfbf; }
.alert-error   { background: #fdecea; color: var(--danger); border: 1px solid #f5b7b1; }
.import-form   { max-width: 600px; }

/* ✅ EVO-005 — Tableau consolidé */
.consolidated-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.consolidated-table thead { background: #f5f5f5; position: sticky; top: 0; }
.consolidated-table th { padding: 12px; text-align: left; font-weight: 600; border-bottom: 2px solid #ddd; color: var(--text-dark); }
.consolidated-table td { padding: 12px; border-bottom: 1px solid #eee; }
.consolidated-table tbody tr:hover { background: #f9f9f9; }
.consolidated-table td small { display: block; font-size: 11px; margin-top: 2px; }

/* Responsive Mobile */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .main { margin-left: 0 !important; }
  .header { padding: 12px 16px 12px 56px; }
  .page { padding: 16px; }
  .stats-grid, .dashboard-widgets-grid { grid-template-columns: 1fr !important; }
  .form-row { flex-direction: column; }
  .compare-result-card { flex-direction: column; gap: 8px; }
  table { font-size: 12px; }
  th, td { padding: 8px 10px; }
  .toolbar { flex-wrap: wrap; }
}

/* ── EVO-012 : Margin Analysis Table ───────────────────────────────────────── */
.margin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.margin-table th,
.margin-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #eee;
  text-align: left;
}

.margin-table th {
  background: #f5f5f5;
  font-weight: 600;
  position: sticky;
  top: 0;
}

.margin-table tbody tr:hover {
  background: #fafafa;
}

.rate-cell {
  font-family: monospace;
}

.margin-ok {
  color: #2e7d32;
  font-weight: 600;
}

.margin-mid {
  color: #e65100;
  font-weight: 600;
}

.margin-low {
  color: #c62828;
  font-weight: 700;
}

.margin-negative {
  color: #fff;
  background: #c62828;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
}

.margin-none {
  color: #aaa;
}

/* ── EVO-013 : TableSorter CSS ───────────────────────────────── */
thead th {
  vertical-align: top;
}

thead th input[type="text"] {
  font-weight: normal;
  max-width: 130px;
}

thead th input[type="text"]:focus {
  outline: 2px solid #1976d2;
  border-color: #1976d2;
}
