/* ─────────────────────────────────────────────────────────
   Message-API  –  Shared Styles
   ───────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #222638;
  --border:    #2e3248;
  --primary:   #4f8ef7;
  --primary-d: #3a78e3;
  --success:   #29c76f;
  --danger:    #ea5455;
  --warning:   #ff9f43;
  --text:      #e4e6f0;
  --text-muted:#8891a8;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
  --font:      'Inter', system-ui, -apple-system, sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.6; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; position: fixed;
  top: 0; left: 0; bottom: 0; z-index: 100; padding: 0;
}

.sidebar-brand {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand .logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff;
}
.sidebar-brand .brand-name { font-size: 15px; font-weight: 700; letter-spacing: .3px; }
.sidebar-brand .brand-sub  { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: var(--text-muted);
  transition: all .15s; font-size: 13.5px; font-weight: 500;
}
.sidebar-nav a:hover { color: var(--text); background: var(--surface2); text-decoration: none; }
.sidebar-nav a.active { color: var(--primary); background: rgba(79,142,247,.1); border-right: 3px solid var(--primary); }
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-section-title {
  font-size: 10px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-muted); padding: 16px 20px 4px;
}

.sidebar-footer { padding: 14px 20px; border-top: 1px solid var(--border); }
.sidebar-footer a { color: var(--text-muted); display: flex; align-items: center; gap: 8px; font-size: 13px; }
.sidebar-footer a:hover { color: var(--danger); text-decoration: none; }

.main-wrap { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { padding: 28px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 15px; font-weight: 600; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 7px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; transition: all .15s; white-space: nowrap;
}
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-success   { background: var(--success);  color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-danger:hover  { filter: brightness(1.1); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-warning   { background: var(--warning);  color: #1a1d27; }
.btn:disabled  { opacity: .45; cursor: not-allowed; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.form-control {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 7px; padding: 9px 13px; color: var(--text); font-size: 13.5px;
  transition: border-color .15s; outline: none; font-family: var(--font);
}
.form-control:focus { border-color: var(--primary); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 14px; color: var(--text-muted); font-size: 11.5px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 50px;
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
}
.badge-success { background: rgba(41,199,111,.15); color: var(--success); }
.badge-danger  { background: rgba(234,84,85,.15);  color: var(--danger); }
.badge-warning { background: rgba(255,159,67,.15); color: var(--warning); }
.badge-primary { background: rgba(79,142,247,.15); color: var(--primary); }
.badge-muted   { background: var(--surface2);      color: var(--text-muted); }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; display: flex; gap: 8px; }
.alert-danger  { background: rgba(234,84,85,.12); border: 1px solid rgba(234,84,85,.3); color: #f88; }
.alert-success { background: rgba(41,199,111,.12); border: 1px solid rgba(41,199,111,.3); color: #6ef7a6; }
.alert-info    { background: rgba(79,142,247,.12); border: 1px solid rgba(79,142,247,.3); color: #9fc4ff; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7);
  z-index: 200; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; width: 100%; max-width: 500px;
  box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-size: 16px; margin-bottom: 20px; font-weight: 600; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Stats grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.stat-card .stat-label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* ── QR code ── */
.qr-wrap {
  text-align: center; padding: 20px;
}
.qr-wrap img { width: 220px; height: 220px; border-radius: 10px; border: 4px solid var(--border); }
.qr-wrap p { color: var(--text-muted); font-size: 12.5px; margin-top: 10px; }

/* ── Spinner ── */
.spinner {
  width: 22px; height: 22px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px 18px; font-size: 13px;
  box-shadow: var(--shadow); animation: slideIn .25s ease;
  max-width: 300px;
}
.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-error   { border-left: 4px solid var(--danger); }
.toast.toast-info    { border-left: 4px solid var(--primary); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

/* ── Utilities ── */
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-center  { text-align: center; }
.mt-0 { margin-top: 0; }
.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; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
