/* =========================================
   SMS PANEL — Global Styles (self-contained)
   ========================================= */

:root {
  --bg:        #0d0f14;
  --surface:   #13161d;
  --surface2:  #1a1e28;
  --surface3:  #222636;
  --border:    #2a2f3d;
  --border2:   #333849;
  --accent:    #4f8ef7;
  --accent2:   #7c6af5;
  --success:   #22c55e;
  --danger:    #f43f5e;
  --warning:   #f59e0b;
  --text:      #e2e8f0;
  --text2:     #8892a4;
  --text3:     #3d4558;
  --radius:    12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Fira Mono", monospace;
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ---- TOPBAR ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 56px;
  background: #0d0f14;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.brand-logo {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #4f8ef7, #7c6af5);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  line-height: 1;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 0;
  margin-right: 6px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-user-avatar {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #4f8ef7, #7c6af5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
}

.topbar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
}

.topbar-user-role {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
  background: rgba(79,142,247,.12);
  border-radius: 99px;
  padding: 2px 8px;
  white-space: nowrap;
}

.nav-link {
  color: var(--text2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all .15s;
  white-space: nowrap;
}

.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active { background: rgba(79,142,247,.1); color: var(--accent); }
.nav-link.danger { color: #f87171; }
.nav-link.danger:hover { background: rgba(244,63,94,.1); color: var(--danger); }

/* ---- PAGE ---- */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 72px;
}

@media (min-width: 640px) {
  .page { padding: 32px 24px 72px; }
}

.page-sm {
  max-width: 480px;
  margin: 0 auto;
  padding: 64px 24px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}

.page-sub {
  font-size: 12px;
  color: var(--text2);
  margin-top: 3px;
}

/* ---- CARDS ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.card + .card { margin-top: 20px; }

.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-icon {
  width: 30px;
  height: 30px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  line-height: 1;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.card-body { padding: 20px; }

.card-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text3);
}

/* ---- GRID ---- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

.grid-sidebar {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 820px) {
  .grid-2, .grid-3, .grid-sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; gap: 12px; }
  .grid-3 { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* ---- STAT CARDS ---- */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text3);
  margin-bottom: 8px;
}

.stat-val {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
  line-height: 1;
}

.stat-sub {
  font-size: 11px;
  color: var(--text2);
  margin-top: 6px;
}

/* ---- FORMS ---- */
.field { margin-bottom: 14px; }

.field label,
label.lbl {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text2);
  margin-bottom: 6px;
}

input,
textarea,
select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,142,247,.1);
}

input::placeholder, textarea::placeholder { color: var(--text3); }
select option { background: #1a1e28; color: var(--text); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn-full { width: 100%; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #3a7de0; }

.btn-secondary { background: var(--surface2); border: 1px solid var(--border); color: var(--text2); }
.btn-secondary:hover { background: var(--surface3); color: var(--text); }

.btn-danger { background: rgba(244,63,94,.15); border: 1px solid rgba(244,63,94,.3); color: #fb7185; }
.btn-danger:hover { background: rgba(244,63,94,.25); }

.btn-success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.25); color: #4ade80; }
.btn-success:hover { background: rgba(34,197,94,.2); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 10px; font-size: 11px; border-radius: var(--radius-xs); }

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.badge-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }

.badge-admin   { background: rgba(79,142,247,.12); color: var(--accent); }
.badge-user    { background: rgba(124,106,245,.1); color: #a78bfa; }
.badge-active  { background: rgba(34,197,94,.1);   color: #4ade80; }
.badge-inactive{ background: rgba(244,63,94,.1);   color: #fb7185; }
.badge-sent    { background: rgba(34,197,94,.1);   color: #4ade80; }
.badge-failed  { background: rgba(244,63,94,.1);   color: #fb7185; }
.badge-pending { background: rgba(245,158,11,.1);  color: #fbbf24; }
.badge-neutral { background: var(--surface2); color: var(--text2); border: 1px solid var(--border); }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.015); }

tbody td {
  padding: 12px 14px;
  vertical-align: middle;
  color: var(--text2);
}

.td-mono  { font-family: var(--font-mono); font-size: 12px; }
.td-strong { font-weight: 600; color: var(--text); }

/* ---- ALERT / FLASH ---- */
.alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 18px;
}

.alert.success { background: rgba(34,197,94,.08); border: 1px solid rgba(34,197,94,.2); color: #4ade80; }
.alert.error   { background: rgba(244,63,94,.08); border: 1px solid rgba(244,63,94,.2); color: #fb7185; }

/* ---- QUOTA BAR ---- */
.quota-bar-wrap { margin-top: 6px; }

.quota-bar-track {
  height: 4px;
  background: var(--surface3);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 6px;
}

.quota-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

/* ---- AVATAR ---- */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f8ef7, #7c6af5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
}

.avatar-sm { width: 26px; height: 26px; font-size: 10px; }

/* ---- USER CELL ---- */
.user-cell  { display: flex; align-items: center; gap: 10px; }
.user-name  { font-weight: 600; color: var(--text); font-size: 13px; }
.user-meta  { font-size: 11px; color: var(--text3); font-family: var(--font-mono); }

/* ---- INLINE FORM ---- */
.inline-form { display: flex; align-items: center; gap: 6px; }

.inline-form input,
.inline-form select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 9px;
  width: auto;
}

.inline-form input[type="number"]   { width: 78px; }
.inline-form select                 { width: 72px; }
.inline-form input[type="password"] { width: 108px; }
.inline-form input:focus,
.inline-form select:focus { border-color: var(--accent); }

/* ---- MISC ---- */
.hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: 8px;
}

.tag-you {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
  background: rgba(79,142,247,.1);
  border: 1px solid rgba(79,142,247,.15);
  border-radius: 99px;
  padding: 2px 7px;
}

.empty-state { text-align: center; padding: 48px 24px; color: var(--text3); }
.empty-state-icon { font-size: 32px; margin-bottom: 10px; }
.empty-state-text { font-size: 13px; }

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text2);
}

/* ---- LOGIN ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}

.login-logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #4f8ef7, #7c6af5);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 20px;
  line-height: 1;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 28px;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* ---- Short aliases for new pages ---- */
:root {
  --sur:  var(--surface);
  --sur2: var(--surface2);
  --sur3: var(--surface3);
  --bdr:  var(--border);
  --acc:  var(--accent);
  --ok:   var(--success);
  --err:  var(--danger);
  --warn: var(--warning);
  --t:    var(--text);
  --t2:   var(--text2);
  --t3:   var(--text3);
  --f:    var(--font);
  --fm:   var(--font-mono);
  --rs:   var(--radius-sm);
  --rx:   var(--radius-xs);
}

/* =========================================
   RESPONSIVE — Mobile & Tablette
   ========================================= */

/* Topbar : sur mobile, la nav passe en dessous sur une 2e ligne */
@media (max-width: 640px) {
  .topbar {
    padding: 8px 14px;
    gap: 6px;
  }

  .topbar-brand { font-size: 13px; }
  .brand-logo   { width: 26px; height: 26px; font-size: 12px; }

  .topbar-nav {
    width: 100%;
    padding-bottom: 6px;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .topbar-nav::-webkit-scrollbar { display: none; }

  /* Masquer le nom utilisateur + rôle sur très petit écran */
  .topbar-user-name,
  .topbar-user-role { display: none; }

  .topbar-user {
    padding-right: 8px;
    margin-right: 4px;
  }

  .nav-link {
    font-size: 11px;
    padding: 5px 9px;
  }
}

/* Dashboard : grille de stats (4 colonnes inline) */
@media (max-width: 820px) {
  /* Cibler les grilles inline du dashboard */
  .page > div[style*="grid-template-columns:repeat(4"] {
    grid-template-columns: 1fr 1fr !important;
  }
  .page > div[style*="grid-template-columns:1fr 360px"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  .page > div[style*="grid-template-columns:repeat(4"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  /* Cards : réduire le padding */
  .card-body { padding: 14px; }
  .card-head { padding: 12px 14px; }
  .card-foot { padding: 10px 14px; }

  /* Tableaux : réduire le padding des cellules */
  thead th { padding: 8px 10px; font-size: 9px; }
  tbody td { padding: 10px 10px; }

  /* Stat cards */
  .stat-card { padding: 14px; }
  .stat-val  { font-size: 22px; }

  /* Inline forms dans users.php : empiler verticalement */
  .inline-form { flex-wrap: wrap; }
  .inline-form input[type="number"]   { width: 64px; }
  .inline-form input[type="password"] { width: 90px; }

  /* Actions dans le tableau users : empiler */
  tbody td > div[style*="flex-wrap:wrap"] {
    gap: 4px;
  }

  /* Login card */
  .login-card { padding: 24px 18px; }

  /* Page header */
  .page-header { margin-bottom: 18px; }
  .page-title  { font-size: 17px; }
}

/* Tablette intermédiaire */
@media (max-width: 960px) {
  .page > div[style*="grid-template-columns:1fr 360px"] {
    grid-template-columns: 1fr !important;
  }
}