/* ============================================================
   WifiManager v2 — Portal CSS
   Aesthetic: Dark-sidebar, crisp cards, professional ISP tool
   ============================================================ */

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

:root {
  /* Brand */
  --brand:        #3b82f6;
  --brand-dark:   #2563eb;
  --brand-light:  #eff6ff;
  --brand-glow:   rgba(59,130,246,.15);

  /* Sidebar */
  --sidebar-bg:   #0d1117;
  --sidebar-w:    230px;
  --sidebar-border: rgba(255,255,255,.07);

  /* Layout */
  --topbar-h:     56px;
  --radius:       10px;
  --radius-lg:    14px;

  /* Colors */
  --bg:           #f4f6fb;
  --surface:      #ffffff;
  --border:       #e5eaf3;
  --text:         #111827;
  --text-muted:   #6b7280;
  --text-faint:   #9ca3af;

  /* Shadows */
  --shadow-sm:    0 1px 2px rgba(0,0,0,.06);
  --shadow:       0 1px 4px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --shadow-md:    0 4px 20px rgba(0,0,0,.10);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.12);

  /* Status */
  --green:  #16a34a; --green-bg:  #dcfce7;
  --red:    #dc2626; --red-bg:    #fee2e2;
  --yellow: #d97706; --yellow-bg: #fef3c7;
  --blue:   #2563eb; --blue-bg:   #dbeafe;
  --purple: #7c3aed; --purple-bg: #ede9fe;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.portal-body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: .875rem;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.portal-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1000;
  transition: transform .25s ease;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.portal-sidebar::-webkit-scrollbar { display: none; }

.portal-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 14px;
  border-bottom: 1px solid var(--sidebar-border);
}

.portal-sidebar-logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(59,130,246,.2);
}
.portal-sidebar-logo i { color: #fff; font-size: .9rem; }

.portal-sidebar-title {
  color: #fff;
  font-weight: 700;
  font-size: .82rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.portal-sidebar-sub {
  color: rgba(255,255,255,.35);
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 1px;
}

.portal-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.portal-nav-section {
  color: rgba(255,255,255,.25);
  font-size: .58rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  padding: 12px 8px 4px;
}

.portal-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  color: rgba(255,255,255,.5);
  text-decoration: none;
  font-size: .79rem;
  font-weight: 500;
  transition: all .15s;
  position: relative;
}
.portal-nav-item:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.85); }
.portal-nav-item.active { background: rgba(59,130,246,.2); color: #fff; }
.portal-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--brand);
  border-radius: 0 3px 3px 0;
}
.portal-nav-icon { width: 15px; text-align: center; flex-shrink: 0; font-size: .8rem; }
.portal-nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: .58rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 99px;
  min-width: 16px;
  text-align: center;
}

.portal-sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.portal-user-chip { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.portal-user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .7rem; font-weight: 700;
  flex-shrink: 0;
}
.portal-user-info { min-width: 0; }
.portal-user-name { color: #fff; font-size: .73rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-user-role { color: rgba(255,255,255,.35); font-size: .6rem; }

.portal-signout-btn {
  color: rgba(255,255,255,.3);
  text-decoration: none;
  padding: 5px;
  border-radius: 6px;
  transition: all .15s;
  flex-shrink: 0;
  font-size: .85rem;
}
.portal-signout-btn:hover { color: #f87171; background: rgba(255,255,255,.06); }

/* ── Main Content ──────────────────────────────────────────── */
.portal-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .25s ease;
}

/* ── Top Bar ───────────────────────────────────────────────── */
.portal-topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}

.portal-menu-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 9px;
  cursor: pointer;
  color: var(--text-muted);
  display: none;
  font-size: .85rem;
  transition: all .15s;
}
.portal-menu-toggle:hover { background: var(--bg); }

.portal-topbar-search {
  flex: 1;
  max-width: 300px;
  position: relative;
}
.portal-topbar-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px 6px 32px;
  font-size: .8rem;
  outline: none;
  color: var(--text);
  transition: border-color .15s;
}
.portal-topbar-search input:focus { border-color: var(--brand); }
.portal-topbar-search i {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: .75rem;
}

.portal-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.portal-topbar-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .82rem;
  transition: all .15s;
  position: relative;
}
.portal-topbar-icon:hover { background: var(--bg); color: var(--text); }
.portal-topbar-icon .dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ── Page Content ──────────────────────────────────────────── */
.portal-content {
  padding: 24px 20px;
  flex: 1;
}

/* ── Page Header ───────────────────────────────────────────── */
.portal-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.portal-page-title { font-size: 1.3rem; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.portal-page-sub { color: var(--text-muted); font-size: .78rem; margin-top: 2px; }

/* ── Cards ─────────────────────────────────────────────────── */
.portal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.portal-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.portal-card-title {
  font-size: .85rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.portal-card-body { padding: 16px; }

/* ── Stat Cards ────────────────────────────────────────────── */
.portal-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  transition: all .15s;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.portal-stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); color: var(--text); }
.portal-stat::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: transparent;
  transition: background .15s;
}
.portal-stat:hover::after { background: var(--brand); }

.portal-stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: .9rem;
}
.portal-stat-val { font-size: 1.35rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.portal-stat-label { font-size: .72rem; font-weight: 600; color: var(--text-muted); margin-top: 3px; }
.portal-stat-sub { font-size: .66rem; color: var(--text-faint); margin-top: 1px; }
.portal-stat-trend {
  margin-left: auto;
  font-size: .68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 99px;
}
.portal-stat-trend.up { color: var(--green); background: var(--green-bg); }
.portal-stat-trend.down { color: var(--red); background: var(--red-bg); }

/* ── Tables ────────────────────────────────────────────────── */
.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .815rem;
}
.portal-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.portal-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.portal-table tbody tr:last-child td { border-bottom: none; }
.portal-table tbody tr:hover td { background: #f9fafb; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-brand {
  background: var(--brand);
  color: #fff;
  border: none;
  font-weight: 600;
  letter-spacing: -.01em;
  transition: all .15s;
}
.btn-brand:hover { background: var(--brand-dark); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,.35); }
.btn-brand:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: .8rem;
  transition: all .15s;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); border-color: #c9d0de; }

/* ── Form Controls ─────────────────────────────────────────── */
.form-control, .form-select {
  border-color: var(--border);
  font-size: .83rem;
  border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-label { font-weight: 600; font-size: .78rem; color: var(--text); margin-bottom: 5px; }
.form-text { font-size: .72rem; }

/* ── Badges ────────────────────────────────────────────────── */
.badge { font-weight: 600; font-size: .67rem; letter-spacing: .02em; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert { border-radius: var(--radius); border: none; font-size: .82rem; }
.alert-success { background: #f0fdf4; color: #166534; }
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info    { background: #eff6ff; color: #1e40af; }

/* ── Online indicator ──────────────────────────────────────── */
.online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  box-shadow: 0 0 0 2px var(--green-bg);
  animation: pulse-dot 2s infinite;
}
.offline-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  display: inline-block;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px var(--green-bg); }
  50% { box-shadow: 0 0 0 4px var(--green-bg); }
}

/* ── Router card ───────────────────────────────────────────── */
.router-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: all .15s;
}
.router-card:hover { box-shadow: var(--shadow-md); }
.router-card.online { border-left: 3px solid var(--green); }
.router-card.offline { border-left: 3px solid var(--red); }

/* ── Mikrotik info chip ────────────────────────────────────── */
.mt-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #0d1117;
  color: #7dd3fc;
  font-family: 'JetBrains Mono', monospace;
  font-size: .68rem;
  padding: 3px 8px;
  border-radius: 5px;
  font-weight: 500;
}

/* ── Action bar ────────────────────────────────────────────── */
.portal-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.portal-action-bar .search-box {
  position: relative;
  flex: 1;
  min-width: 180px;
}
.portal-action-bar .search-box input {
  padding-left: 30px;
  font-size: .8rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  width: 100%;
  height: 34px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s;
}
.portal-action-bar .search-box input:focus { border-color: var(--brand); }
.portal-action-bar .search-box i {
  position: absolute; left: 9px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: .72rem;
}

/* ── Empty state ───────────────────────────────────────────── */
.portal-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.portal-empty i { font-size: 2.5rem; opacity: .18; margin-bottom: 14px; display: block; }
.portal-empty h5 { font-size: .95rem; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.portal-empty p { font-size: .8rem; max-width: 300px; margin: 0 auto 16px; }

/* ── Auth layout ───────────────────────────────────────────── */
.auth-wrap {
  display: flex;
  min-height: 100vh;
  width: 100%;
}
.auth-left {
  flex: 1;
  background: linear-gradient(145deg, #0d1117 0%, #0f2027 60%, #1a3a5c 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.auth-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 50%, rgba(59,130,246,.18) 0%, transparent 60%);
}
.auth-right {
  width: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--bg);
}
.auth-form-wrap { width: 100%; max-width: 380px; }
.auth-form-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 4px; letter-spacing: -.02em; }
.auth-form-sub { color: var(--text-muted); font-size: .83rem; margin-bottom: 24px; }
.auth-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow-md);
}
.auth-trust { display: flex; flex-direction: column; gap: 10px; }
.auth-trust-item {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.7); font-size: .82rem;
}
.auth-trust-item i { color: #34d399; font-size: .85rem; flex-shrink: 0; }
.text-brand { color: var(--brand) !important; }

/* ── Sidebar overlay (mobile) ──────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .portal-sidebar {
    transform: translateX(-100%);
  }
  .portal-sidebar.open {
    transform: translateX(0);
  }
  .portal-main {
    margin-left: 0 !important;
  }
  .portal-menu-toggle { display: flex; align-items: center; }
  .auth-left { display: none !important; }
  .auth-right { width: 100%; }
  .portal-content { padding: 16px 12px; }
}

/* ── Sidebar collapsed (desktop) ───────────────────────────── */
body.sidebar-collapsed .portal-sidebar { width: 56px; }
body.sidebar-collapsed .portal-sidebar-title,
body.sidebar-collapsed .portal-sidebar-sub,
body.sidebar-collapsed .portal-nav-item span,
body.sidebar-collapsed .portal-nav-section,
body.sidebar-collapsed .portal-nav-badge,
body.sidebar-collapsed .portal-user-info,
body.sidebar-collapsed .portal-signout-btn { display: none; }
body.sidebar-collapsed .portal-main { margin-left: 56px; }
body.sidebar-collapsed .portal-nav-item { justify-content: center; padding: 10px; }
body.sidebar-collapsed .portal-sidebar-brand { justify-content: center; padding: 16px 8px; }
body.sidebar-collapsed .portal-user-chip { justify-content: center; }

/* ── Utilities ─────────────────────────────────────────────── */
.font-mono { font-family: 'JetBrains Mono', monospace; }
.text-xs   { font-size: .72rem; }
.text-sm   { font-size: .8rem; }
.fw-700    { font-weight: 700; }
.fw-800    { font-weight: 800; }
.gap-6     { gap: 1.5rem; }
.truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Loading spinner ───────────────────────────────────────── */
.spinner-border-sm { width: 1rem; height: 1rem; }

/* ── Quick action buttons ──────────────────────────────────── */
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: .75rem;
  font-weight: 600;
  transition: all .15s;
  text-align: center;
}
.quick-action:hover { background: var(--brand-light); border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.quick-action i { font-size: 1.1rem; }

/* ── Progress bar ──────────────────────────────────────────── */
.portal-progress {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.portal-progress-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--brand);
  transition: width .4s ease;
}

/* ── Tabs ───────────────────────────────────────────────────── */
.portal-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  margin-bottom: 16px;
}
.portal-tab {
  flex: 1;
  text-align: center;
  padding: 7px 12px;
  border-radius: 7px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  transition: all .15s;
}
.portal-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ── Info row ───────────────────────────────────────────────── */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .81rem;
}
.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--text-muted); font-weight: 500; }
.info-row .value { font-weight: 600; text-align: right; }
