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

:root {
  --wifi-on: #22c55e;
  --wifi-off: #ef4444;
  --accent: #0ea5e9;
  --accent-dark: #0284c7;
  --bg-glass: rgba(8, 12, 28, 0.82);
  --bg-card: rgba(15, 23, 42, 0.90);
  --border: rgba(255,255,255,0.10);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: 'Inter', sans-serif; color: var(--text); }

/* ── Auth / Login ─────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0c1a3a 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%; max-width: 420px;
  backdrop-filter: blur(20px);
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .product-name { font-size: 13px; color: var(--text-muted); margin-top: 6px; letter-spacing: 1px; text-transform: uppercase; }
.auth-logo .brand { font-size: 22px; font-weight: 700; color: var(--accent); }

.auth-card h2 { font-size: 20px; font-weight: 600; margin-bottom: 6px; text-align: center; }
.auth-card p.subtitle { color: var(--text-muted); font-size: 14px; text-align: center; margin-bottom: 28px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.form-group input {
  width: 100%; padding: 12px 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-size: 15px; font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,165,233,0.15); }
.form-group input.otp-input { letter-spacing: 8px; font-size: 22px; font-weight: 700; text-align: center; }

.btn {
  width: 100%; padding: 13px;
  border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all .2s;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(14,165,233,0.3); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.auth-error {
  background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5; padding: 10px 14px; border-radius: 8px;
  font-size: 13px; text-align: center; margin-bottom: 16px;
}
.auth-back { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; margin-top: 14px; width: 100%; text-align: center; font-family: inherit; }
.auth-back:hover { color: var(--text); }
.hidden { display: none !important; }

/* ── Control WiFi page ───────────────────────── */
.wifi-page {
  min-height: 100vh;
  background-image: url('assets/aqua-bg.jpg');
  background-size: cover; background-position: center;
  background-attachment: fixed;
  display: flex; flex-direction: column;
}
.wifi-overlay {
  flex: 1; display: flex; flex-direction: column;
  background: linear-gradient(to bottom, rgba(0,0,0,.45) 0%, rgba(0,0,0,.65) 100%);
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  background: rgba(0,0,0,.3); backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.topbar-brand { font-size: 15px; font-weight: 600; color: white; display: flex; align-items: center; gap: 8px; }
.topbar-brand span.badge { font-size: 11px; background: var(--accent); padding: 2px 8px; border-radius: 20px; font-weight: 500; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-user span { font-size: 13px; color: rgba(255,255,255,.7); }
.btn-logout { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15); color: white; padding: 6px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; font-family: inherit; transition: background .2s; }
.btn-logout:hover { background: rgba(255,255,255,.18); }

.wifi-center {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 32px;
}

.wifi-card {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 52px 48px;
  text-align: center;
  backdrop-filter: blur(24px);
  box-shadow: 0 32px 64px rgba(0,0,0,.5);
  max-width: 440px; width: 100%;
}

.wifi-icon-wrap {
  width: 100px; height: 100px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 24px;
  transition: all .4s;
}
.wifi-icon-wrap.on { background: rgba(34,197,94,.15); border: 3px solid var(--wifi-on); box-shadow: 0 0 40px rgba(34,197,94,.25); }
.wifi-icon-wrap.off { background: rgba(239,68,68,.15); border: 3px solid var(--wifi-off); box-shadow: 0 0 40px rgba(239,68,68,.15); }
.wifi-icon-wrap svg { width: 48px; height: 48px; transition: stroke .4s; }
.wifi-icon-wrap.on svg { stroke: var(--wifi-on); }
.wifi-icon-wrap.off svg { stroke: var(--wifi-off); }

.wifi-status-label {
  font-size: 15px; font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 2px; margin-bottom: 8px;
}
.wifi-status-text {
  font-size: 36px; font-weight: 800; margin-bottom: 8px;
  transition: color .4s;
}
.wifi-status-text.on { color: var(--wifi-on); }
.wifi-status-text.off { color: var(--wifi-off); }
.wifi-ssid-name { font-size: 13px; color: var(--text-muted); margin-bottom: 36px; }

.btn-toggle {
  width: 100%; padding: 16px;
  border: none; border-radius: 14px;
  font-size: 17px; font-weight: 700;
  cursor: pointer; transition: all .25s;
  font-family: inherit; letter-spacing: .3px;
}
.btn-toggle.btn-turn-off { background: linear-gradient(135deg, #dc2626, #ef4444); color: white; }
.btn-toggle.btn-turn-off:hover { box-shadow: 0 12px 28px rgba(239,68,68,.4); transform: translateY(-2px); }
.btn-toggle.btn-turn-on { background: linear-gradient(135deg, #16a34a, #22c55e); color: white; }
.btn-toggle.btn-turn-on:hover { box-shadow: 0 12px 28px rgba(34,197,94,.4); transform: translateY(-2px); }
.btn-toggle:active { transform: translateY(0); }
.btn-toggle:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.wifi-refresh-note { font-size: 12px; color: rgba(255,255,255,.3); margin-top: 16px; }

/* ── Confirm modal ───────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: #0f172a; border: 1px solid var(--border);
  border-radius: 20px; padding: 36px 32px; max-width: 400px; width: 100%;
  box-shadow: 0 24px 48px rgba(0,0,0,.6); text-align: center;
}
.modal-icon { font-size: 48px; margin-bottom: 16px; }
.modal-box h3 { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.modal-box p { color: var(--text-muted); font-size: 14px; line-height: 1.6; margin-bottom: 28px; }
.modal-actions { display: flex; gap: 12px; }
.btn-cancel { flex: 1; padding: 12px; background: rgba(255,255,255,.08); border: 1px solid var(--border); color: var(--text); border-radius: 10px; font-size: 15px; font-weight: 500; cursor: pointer; font-family: inherit; transition: background .2s; }
.btn-cancel:hover { background: rgba(255,255,255,.14); }
.btn-confirm { flex: 2; padding: 12px; border: none; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit; color: white; transition: all .2s; }
.btn-confirm.confirm-off { background: var(--wifi-off); }
.btn-confirm.confirm-off:hover { background: #dc2626; box-shadow: 0 6px 20px rgba(239,68,68,.4); }
.btn-confirm.confirm-on { background: var(--wifi-on); }
.btn-confirm.confirm-on:hover { background: #16a34a; box-shadow: 0 6px 20px rgba(34,197,94,.4); }

/* ── Admin Dashboard ─────────────────────────── */
.admin-page { min-height: 100vh; background: #070d1a; }

.admin-header {
  background: #0c1629; border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.admin-header-brand { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.admin-header-brand .tag { font-size: 11px; background: rgba(14,165,233,.2); color: var(--accent); padding: 2px 8px; border-radius: 20px; border: 1px solid rgba(14,165,233,.3); }
.header-wifi-status { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.on { background: var(--wifi-on); box-shadow: 0 0 6px var(--wifi-on); }
.status-dot.off { background: var(--wifi-off); }

.admin-body { display: flex; min-height: calc(100vh - 60px); }

.sidebar {
  width: 200px; background: #0c1629; border-right: 1px solid var(--border);
  padding: 20px 0; flex-shrink: 0;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: var(--text-muted);
  font-size: 14px; font-weight: 500; text-decoration: none;
  transition: all .2s; border-left: 3px solid transparent;
}
.sidebar nav a:hover { color: var(--text); background: rgba(255,255,255,.04); }
.sidebar nav a.active { color: var(--accent); border-left-color: var(--accent); background: rgba(14,165,233,.06); }

.admin-content { flex: 1; padding: 28px; max-width: 1000px; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.kpi-card {
  background: #0f1f3d; border: 1px solid var(--border);
  border-radius: 14px; padding: 20px;
}
.kpi-card .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.kpi-card .value { font-size: 28px; font-weight: 800; }
.kpi-card.primary .value { color: var(--accent); }
.kpi-card.on .value { color: var(--wifi-on); }
.kpi-card.off .value { color: var(--wifi-off); }

/* Tables */
.admin-table-wrap { background: #0c1629; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.admin-table-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.admin-table-header h3 { font-size: 15px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
thead th { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .8px; padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.02); }
tbody td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,.04); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.02); }

.badge-role { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-role.superadmin { background: rgba(168,85,247,.2); color: #c084fc; border: 1px solid rgba(168,85,247,.3); }
.badge-role.admin { background: rgba(14,165,233,.15); color: #7dd3fc; border: 1px solid rgba(14,165,233,.3); }
.badge-role.user { background: rgba(148,163,184,.1); color: var(--text-muted); border: 1px solid rgba(148,163,184,.2); }

.badge-action { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-action.wifi-on { background: rgba(34,197,94,.12); color: #86efac; border: 1px solid rgba(34,197,94,.2); }
.badge-action.wifi-off { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }

.btn-sm { padding: 5px 12px; border-radius: 7px; font-size: 12px; font-weight: 500; border: none; cursor: pointer; font-family: inherit; transition: all .15s; }
.btn-sm.danger { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }
.btn-sm.danger:hover { background: rgba(239,68,68,.25); }
.btn-sm.primary { background: rgba(14,165,233,.2); color: #7dd3fc; border: 1px solid rgba(14,165,233,.3); }
.btn-sm.primary:hover { background: rgba(14,165,233,.3); }

.btn-add { background: var(--accent); color: white; padding: 8px 18px; border: none; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all .2s; }
.btn-add:hover { background: var(--accent-dark); transform: translateY(-1px); }

/* User modal */
.user-modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.75); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.user-modal { background: #0f172a; border: 1px solid var(--border); border-radius: 18px; padding: 28px; max-width: 440px; width: 100%; }
.user-modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.user-modal .form-group { margin-bottom: 16px; }
.user-modal select { width: 100%; padding: 11px 14px; background: rgba(255,255,255,.06); border: 1px solid var(--border); border-radius: 9px; color: var(--text); font-size: 14px; font-family: inherit; outline: none; }
.user-modal select:focus { border-color: var(--accent); }
.user-modal .modal-footer { display: flex; gap: 10px; margin-top: 24px; }
.user-modal .modal-footer button { flex: 1; }

.empty-state { text-align: center; padding: 40px; color: var(--text-muted); font-size: 14px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 500;
  background: #1e293b; border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 20px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  font-size: 14px; animation: slideIn .25s ease;
  max-width: 320px;
}
.toast.success { border-color: rgba(34,197,94,.3); }
.toast.error { border-color: rgba(239,68,68,.3); }
@keyframes slideIn { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 640px) {
  .wifi-card { padding: 36px 24px; }
  .wifi-status-text { font-size: 28px; }
  .admin-body { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar nav { display: flex; overflow-x: auto; }
  .sidebar nav a { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  .sidebar nav a.active { border-bottom-color: var(--accent); border-left: none; }
}
