/* ============================================================
   Base / Reset / Variables
   ============================================================ */
:root {
  --primary:       #25D366;
  --primary-dark:  #1ebe5d;
  --primary-light: #dcfce7;
  --secondary:     #128C7E;
  --accent:        #075E54;
  --danger:        #ef4444;
  --warning:       #f59e0b;
  --success:       #22c55e;
  --info:          #3b82f6;

  --bg:            #f8fafc;
  --bg-card:       #ffffff;
  --bg-sidebar:    #0f172a;
  --bg-navbar:     rgba(255,255,255,0.85);
  --border:        #e2e8f0;
  --border-light:  #f1f5f9;

  --text:          #1e293b;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;
  --text-inverse:  #ffffff;

  --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:        0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:     0 10px 40px rgba(0,0,0,.12);
  --shadow-xl:     0 20px 60px rgba(0,0,0,.15);

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;
  --radius-xl:     24px;
  --radius-full:   9999px;

  --sidebar-w:     260px;
  --navbar-h:      64px;
  --transition:    0.2s ease;
}

[data-theme="dark"] {
  --bg:            #0f172a;
  --bg-card:       #1e293b;
  --bg-sidebar:    #020617;
  --bg-navbar:     rgba(15,23,42,0.9);
  --border:        #334155;
  --border-light:  #1e293b;
  --text:          #f1f5f9;
  --text-muted:    #94a3b8;
  --text-light:    #64748b;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; display: block; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary    { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary  { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border-light); }
.btn-danger     { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline    { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm         { padding: 6px 14px; font-size: 13px; }
.btn-xs         { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-primary-sm { background: var(--primary); color: #fff; padding: 8px 18px; border-radius: var(--radius); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap:6px; transition: background var(--transition); }
.btn-primary-sm:hover { background: var(--primary-dark); color:#fff; }
.btn-outline-sm { background: transparent; border: 2px solid var(--border); color: var(--text); padding: 8px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap:6px; transition: all var(--transition); }
.btn-outline-sm:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 16px; font-weight: 700; color: var(--text); }
.card-body  { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--border-light); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,211,102,.15); }
.form-control.is-invalid { border-color: var(--danger); }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 40px; }

/* Input with icon */
.input-icon-wrap { position: relative; }
.input-icon-wrap .form-control { padding-left: 40px; }
.input-icon-wrap .input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-light); font-size: 14px; pointer-events: none; }
.input-icon-wrap .input-icon-right { left: auto; right: 12px; pointer-events: auto; cursor: pointer; }

/* Toggle password */
.toggle-password { color: var(--text-light); }
.toggle-password:hover { color: var(--primary); }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; background: var(--border-light); border-bottom: 2px solid var(--border); }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--border-light); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}
.badge-green   { background: #dcfce7; color: #15803d; }
.badge-red     { background: #fee2e2; color: #b91c1c; }
.badge-yellow  { background: #fef9c3; color: #a16207; }
.badge-blue    { background: #dbeafe; color: #1d4ed8; }
.badge-gray    { background: var(--border-light); color: var(--text-muted); }
.badge-purple  { background: #f3e8ff; color: #7c3aed; }

/* ── Flash Messages ──────────────────────────────────────── */
.flash {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  animation: slideDown 0.3s ease;
}
.flash-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.flash-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.flash-warning { background: #fffbeb; border: 1px solid #fed7aa; color: #92400e; }
.flash-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.flash-close   { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 14px; opacity: .7; }
.flash-close:hover { opacity: 1; }
.flash-errors-list { padding-left: 16px; list-style: disc; }
.flash-errors-list li { margin-bottom: 2px; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-btn {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition);
}
.page-btn.active, .page-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn.disabled { opacity: .4; pointer-events: none; }

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon-green  { background: linear-gradient(135deg,#22c55e,#16a34a); color: #fff; box-shadow: 0 8px 18px rgba(34,197,94,.25); }
.stat-icon-blue   { background: linear-gradient(135deg,#3b82f6,#2563eb); color: #fff; box-shadow: 0 8px 18px rgba(59,130,246,.25); }
.stat-icon-purple { background: linear-gradient(135deg,#a855f7,#7c3aed); color: #fff; box-shadow: 0 8px 18px rgba(168,85,247,.25); }
.stat-icon-orange { background: linear-gradient(135deg,#fb923c,#ea580c); color: #fff; box-shadow: 0 8px 18px rgba(249,115,22,.25); }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert { padding: 14px 18px; border-radius: var(--radius); font-size: 14px; display: flex; align-items: flex-start; gap: 10px; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ── Section Headers ─────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }
.page-title  { font-size: 22px; font-weight: 800; color: var(--text); }
.page-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

/* ── Settings Two-Column Grid ────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.settings-row {
  display: contents;
}
.settings-row .settings-label,
.settings-row .settings-value {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.settings-row:last-child .settings-label,
.settings-row:last-child .settings-value {
  border-bottom: none;
}
.settings-label {
  background: var(--border-light);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
}
.settings-value { background: var(--bg-card); }

/* ── Animations ──────────────────────────────────────────── */
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Utilities ───────────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-danger   { color: var(--danger); }
.text-success  { color: var(--success); }
.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-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: 8px; }
.mb-2  { margin-bottom: 16px; }
.mb-3  { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-13  { font-size: 13px; }
.fs-12  { font-size: 12px; }
.w-100  { width: 100%; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .stat-card { padding: 18px; }
  .stat-value { font-size: 22px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-row .settings-label { border-bottom: none; padding-bottom: 4px; }
  .settings-row .settings-value { border-bottom: 1px solid var(--border); }
}
