@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #070b14;
  --bg-soft: #0d1424;
  --panel: rgba(17, 24, 39, 0.82);
  --panel-solid: #111827;
  --panel-2: #162033;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f8fafc;
  --muted: #94a3b8;
  --faint: #64748b;
  --green: #22c55e;
  --green-2: #16a34a;
  --teal: #14b8a6;
  --gold: #d4a853;
  --blue: #60a5fa;
  --danger: #f87171;
  --warning: #fbbf24;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --sidebar: 280px;
  --radius: 18px;
}

html.light {
  --bg: #eef2f7;
  --bg-soft: #f8fafc;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --panel-2: #f1f5f9;
  --line: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #475569;
  --faint: #94a3b8;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

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

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background:
    radial-gradient(circle at 10% 10%, rgba(34, 197, 94, 0.12), transparent 28%),
    radial-gradient(circle at 90% 0%, rgba(20, 184, 166, 0.1), transparent 24%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

body.app-shell {
  background-attachment: fixed;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar);
  position: fixed;
  inset: 0 auto 0 0;
  padding: 1.4rem 1.1rem;
  background: linear-gradient(180deg, rgba(13, 20, 36, 0.96), rgba(7, 11, 20, 0.98));
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(18px);
  z-index: 30;
}

html.light .sidebar {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.4rem 0.5rem 1.4rem;
}

.brand img {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.28);
}

.brand-text strong {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-text span {
  display: block;
  font-size: 0.74rem;
  color: var(--faint);
  font-weight: 600;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
  transition: 0.2s ease;
}

.nav-links a .nav-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  font-size: 1rem;
}

.nav-links a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
}

.nav-links a.active {
  color: #fff;
  background: linear-gradient(135deg, #22c55e, #0f766e);
  box-shadow: 0 12px 28px rgba(34, 197, 94, 0.25);
}

.nav-links a.active .nav-icon {
  background: rgba(255, 255, 255, 0.16);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.copyright {
  font-size: 0.72rem;
  color: var(--faint);
  line-height: 1.45;
  margin-bottom: 0.85rem;
  padding: 0 0.35rem;
}

.copyright strong {
  color: var(--gold);
  font-weight: 700;
}

/* Main */
.content {
  margin-left: var(--sidebar);
  flex: 1;
  padding: 1.6rem 1.8rem 2.5rem;
  max-width: 1220px;
}

.hero-banner {
  height: 120px;
  border-radius: 22px;
  background:
    linear-gradient(90deg, rgba(7, 11, 20, 0.55), rgba(7, 11, 20, 0.15)),
    url('/public/images/header-banner.png') center/cover no-repeat;
  border: 1px solid var(--line);
  margin-bottom: 1.4rem;
  display: flex;
  align-items: flex-end;
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

html.light .hero-banner {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.2)),
    url('/public/images/header-banner.png') center/cover no-repeat;
}

.hero-banner h1 {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.hero-banner p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.3rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.page-subtitle {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 0.25rem;
}

/* Cards */
.card {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.card-header h2,
.card h2 {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card-desc,
.card-header p {
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 0.2rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.15rem;
}

.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--green), var(--teal));
}

.stat-card.success::before { background: linear-gradient(90deg, #22c55e, #86efac); }
.stat-card.warning::before { background: linear-gradient(90deg, #f59e0b, #fde68a); }
.stat-card.danger::before { background: linear-gradient(90deg, #ef4444, #fca5a5); }

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(34, 197, 94, 0.12);
  margin-bottom: 0.9rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
}

.stat-label {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

/* Forms */
.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea,
.inline-form input {
  width: 100%;
  padding: 0.8rem 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  transition: 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.inline-form input:focus {
  outline: none;
  border-color: rgba(34, 197, 94, 0.55);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.checkbox-label:hover { border-color: rgba(34, 197, 94, 0.4); }
.checkbox-label input { accent-color: var(--green); width: 16px; height: 16px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: 12px;
  padding: 0.72rem 1.1rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: 0.2s ease;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #22c55e, #0f766e);
  box-shadow: 0 12px 24px rgba(34, 197, 94, 0.22);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(34, 197, 94, 0.3);
}

.btn-secondary {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.btn-ghost {
  width: 100%;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--panel-2);
}

.btn-sm { padding: 0.42rem 0.75rem; font-size: 0.78rem; border-radius: 10px; }
.btn-lg { padding: 0.9rem 1.5rem; font-size: 0.95rem; }
.btn-block { width: 100%; }

.inline-form {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.inline-form input { flex: 1; min-width: 220px; }

/* Table */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  padding: 0.9rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.data-table th {
  background: var(--panel-2);
  color: var(--faint);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.data-table tbody tr:hover { background: rgba(34, 197, 94, 0.04); }
.data-table tbody tr:last-child td { border-bottom: none; }
.empty { text-align: center; color: var(--muted); padding: 2.4rem !important; }

.status,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status { padding: 0.3rem 0.7rem; }
.badge { padding: 0.42rem 0.85rem; }

.status-sent, .badge-success {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.22);
}

.status-failed {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.22);
}

.status-pending,
.status-processing,
.status-retry_pending,
.badge-warning {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.22);
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.alert {
  padding: 0.9rem 1rem;
  border-radius: 12px;
  margin-bottom: 1.1rem;
  font-weight: 600;
}

.alert-success {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.22);
}

.alert-error {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.22);
}

.hint {
  color: var(--faint);
  font-size: 0.8rem;
  margin-top: 0.45rem;
  line-height: 1.45;
}

.wa-connect-box {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.2rem;
}

.wa-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
  font-weight: 700;
}

.qr-container {
  background: #fff;
  border-radius: 16px;
  padding: 1rem;
  display: inline-block;
  margin: 1rem 0;
  min-width: 220px;
  min-height: 220px;
  text-align: center;
}

.qr-container img { width: 200px; height: 200px; }

.test-result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  overflow: auto;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1rem;
  color: var(--muted);
}

.actions { display: flex; gap: 0.4rem; align-items: center; white-space: nowrap; }
.error-cell { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-actions { display: flex; justify-content: flex-end; }

.footer-credit {
  margin-top: 1.5rem;
  color: var(--faint);
  font-size: 0.75rem;
  text-align: center;
}

.footer-credit strong { color: var(--gold); }

/* Login */
.login-page {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(120deg, rgba(7, 11, 20, 0.82), rgba(7, 11, 20, 0.55)),
    url('/public/images/login-bg.png') center/cover no-repeat;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(10, 16, 28, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 2.2rem 2rem;
  text-align: center;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-card img.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  object-fit: cover;
  margin: 0 auto 1rem;
  box-shadow: 0 14px 30px rgba(34, 197, 94, 0.3);
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.subtitle {
  color: var(--muted);
  margin: 0.3rem 0 1.5rem;
}

.login-card .form-group { text-align: left; }

.login-credit {
  margin-top: 1.2rem;
  font-size: 0.75rem;
  color: var(--faint);
}

.login-credit strong { color: var(--gold); }

@media (max-width: 980px) {
  .stats-grid, .grid-2 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding: 1rem; }
  .stats-grid, .grid-2, .form-row { grid-template-columns: 1fr; }
  .hero-banner { height: 100px; }
}
