/* ============================================================
   VPN Dashboard — main.css
   ============================================================ */

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

:root {
  --bg:        #0f1117;
  --bg2:       #1a1d27;
  --bg3:       #222638;
  --border:    rgba(255,255,255,0.08);
  --border2:   rgba(255,255,255,0.14);
  --text:      #e2e4ef;
  --text2:     #8b8fa8;
  --text3:     #555870;
  --accent:    #6366f1;
  --accent-h:  #818cf8;
  --green:     #22c55e;
  --yellow:    #f59e0b;
  --red:       #ef4444;
  --blue:      #3b82f6;
  --radius:    10px;
  --radius-sm: 6px;
  --sidebar-w: 220px;
  --header-h:  56px;
  --shadow:    0 2px 12px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; }

/* ── Layout ──────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
  grid-row: 1 / -1;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.sidebar-logo .logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section {
  padding: 6px 12px 2px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text3);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: var(--text2);
  border-radius: 0;
  transition: background .15s, color .15s;
  font-size: 13.5px;
}

.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: rgba(99,102,241,.15); color: var(--accent-h); }

.nav-link .icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--text3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: color .15s;
}
.sidebar-footer a:hover { color: var(--red); }

/* ── Header ──────────────────────────────────────────────── */

.header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}

.header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.header-right { display: flex; align-items: center; gap: 12px; }

/* ── Main content ────────────────────────────────────────── */

.main {
  padding: 24px;
  overflow-y: auto;
  max-width: 1200px;
}

/* ── Cards & Grids ───────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-card .label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text3);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-card .sub {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
}

.stat-card.accent  { border-color: rgba(99,102,241,.35); }
.stat-card.green   { border-color: rgba(34,197,94,.3); }
.stat-card.yellow  { border-color: rgba(245,158,11,.3); }
.stat-card.red     { border-color: rgba(239,68,68,.3); }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 20px; }

/* ── Table ───────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

td a:hover { color: var(--accent-h); }

/* ── Badges ──────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-active  { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-frozen  { background: rgba(59,130,246,.15);  color: var(--blue); }
.badge-expired { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-warning { background: rgba(245,158,11,.15);  color: var(--yellow); }
.badge-none    { background: rgba(255,255,255,.06); color: var(--text3); }
.badge-unused  { background: rgba(255,255,255,.06); color: var(--text3); }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}

.btn:hover { opacity: .85; }

.btn-primary { background: var(--accent);  color: #fff; }
.btn-danger  { background: rgba(239,68,68,.15); color: var(--red); border-color: rgba(239,68,68,.3); }
.btn-ghost   { background: var(--bg3); color: var(--text2); border-color: var(--border2); }
.btn-sm      { padding: 4px 10px; font-size: 12px; }

/* ── Forms ───────────────────────────────────────────────── */

.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 80px; }

/* ── Search bar ──────────────────────────────────────────── */

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.search-bar input { max-width: 280px; }

/* ── Filter tabs ─────────────────────────────────────────── */

.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 3px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  transition: background .15s, color .15s;
  border: none;
  background: transparent;
  display: inline-block;
}

.filter-tab:hover { color: var(--text); }
.filter-tab.active { background: var(--bg2); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.3); }

/* ── Pagination ──────────────────────────────────────────── */

.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  padding: 16px 0 0;
}

.pagination a, .pagination span {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text2);
  border: 1px solid var(--border);
}

.pagination a:hover { background: var(--bg3); color: var(--text); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ── AWG status dots ─────────────────────────────────────── */

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-active  { background: var(--green); box-shadow: 0 0 6px rgba(34,197,94,.6); }
.dot-idle    { background: var(--yellow); }
.dot-unused  { background: var(--text3); }

/* ── Detail page ─────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 720px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.info-list { display: flex; flex-direction: column; gap: 0; }
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-row .key { color: var(--text2); flex-shrink: 0; }
.info-row .val { color: var(--text); text-align: right; font-weight: 500; word-break: break-all; }

/* ── Action bar ──────────────────────────────────────────── */

.action-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg3);
}

/* ── Code / monospace ────────────────────────────────────── */

code {
  font-family: "SF Mono", "Fira Code", monospace;
  background: var(--bg3);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .9em;
  color: var(--accent-h);
}

/* ── Login page ──────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 36px;
  width: 340px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  font-size: 28px;
  margin-bottom: 8px;
}

.login-title {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-sub {
  text-align: center;
  color: var(--text3);
  font-size: 13px;
  margin-bottom: 28px;
}

.login-box .form-group { margin-bottom: 14px; }
.login-box .btn-primary { width: 100%; justify-content: center; padding: 10px; font-size: 14px; margin-top: 8px; }

.alert-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Empty state ─────────────────────────────────────────── */

.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text3);
}
.empty .icon { font-size: 36px; margin-bottom: 12px; }
.empty p { font-size: 14px; }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr;
  }
  .sidebar { display: none; }
  .main { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Misc ────────────────────────────────────────────────── */

.text-muted   { color: var(--text2); }
.text-danger  { color: var(--red); }
.text-success { color: var(--green); }
.text-warning { color: var(--yellow); }
.text-mono    { font-family: "SF Mono", "Fira Code", monospace; font-size: .9em; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }
