/* Aegis Solutions - user dashboard and admin panel */

/* ---------- Shell ---------- */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: rgba(8, 8, 10, 0.78);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.topbar-spacer { flex: 1; }
.topbar .badge { margin-left: 4px; }
.icon-btn.menu-toggle { display: none; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-body);
  transition: var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--bg-elevated); }

.user-chip { display: flex; align-items: center; gap: 10px; margin-right: 6px; color: var(--text); font-size: 14px; }
.user-chip .user-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #2a2a30, #14141a);
  border: 1px solid var(--border-hover);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.app-shell { display: flex; padding-top: var(--topbar-h); min-height: 100vh; }

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 55;
}
.sidebar-group-label {
  padding: 4px 12px 8px;
  font-size: 12px;
  color: var(--text-subtle);
}
.sidebar-spacer { flex: 1; min-height: 16px; }
.sidebar-item {
  position: relative;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  text-align: left;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: 0.15s;
}
.sidebar-item:hover { background: var(--bg-elevated); color: var(--text); }
.sidebar-item.active,
.sidebar-item[aria-current="page"] {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}
.sidebar-item.active::before,
.sidebar-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 2px;
  background: #ffffff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  z-index: 54;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  padding: 44px 48px 96px;
}
.main:focus { outline: none; }
.view {
  max-width: 1040px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  animation: fade-in 0.3s ease;
}
.view-wide { max-width: 1280px; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.view-head p { margin-top: 6px; color: var(--text-muted); }
.view-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.section-title { font-size: 16px; color: var(--text); }

.card-lg { padding: 40px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.card-head p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ---------- Welcome and stats ---------- */

.welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 36px 40px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0) 55%), var(--card);
}
.welcome h2 { font-size: 24px; }
.welcome p { margin-top: 8px; color: var(--text-body); }
.welcome-logo {
  width: 72px;
  height: 72px;
  flex: none;
  opacity: 0.9;
  filter: drop-shadow(0 0 24px rgba(255, 255, 255, 0.35));
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stats-5 { grid-template-columns: repeat(5, 1fr); }
.stat { padding: 24px 24px 22px; display: grid; gap: 12px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-muted); font-size: 13px; }
.stat-top .icon { color: var(--text-subtle); }
.stat-value {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  min-height: 29px;
}
.stat-sub { font-size: 12px; color: var(--text-subtle); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-subtle);
  flex: none;
}
.status-dot.is-active { background: var(--success); box-shadow: 0 0 10px rgba(34, 197, 94, 0.6); }
.status-dot.is-expired { background: var(--danger); box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
.status-dot.is-premium { background: var(--warning); box-shadow: 0 0 10px rgba(245, 158, 11, 0.5); }

/* ---------- Key card ---------- */

.key-card { padding: 40px; background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 45%), var(--card); }
.key-card .key-box { font-size: 22px; padding: 28px 20px; }
.key-body { display: grid; gap: 24px; }
.key-meta { display: flex; flex-wrap: wrap; gap: 8px 32px; color: var(--text-muted); font-size: 13px; }
.key-meta strong { color: var(--text); font-weight: 500; }
.key-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.key-empty {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px 16px;
  text-align: center;
  border: 1px dashed var(--border-hover);
  border-radius: 10px;
  background: var(--bg);
}
.key-empty .icon { color: var(--text-subtle); }
.key-empty .icon svg { width: 26px; height: 26px; }
.key-empty h3 { color: var(--text); }
.key-empty p { color: var(--text-muted); max-width: 40ch; }
.key-box.is-dim { color: var(--text-subtle); text-decoration: line-through; cursor: default; }

.wait-panel {
  display: grid;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--border-hover);
  border-radius: 10px;
  background: var(--bg);
}
.wait-head { display: flex; align-items: center; gap: 14px; color: var(--text); font-weight: 500; }
.wait-head small { display: block; color: var(--text-muted); font-weight: 400; font-size: 13px; margin-top: 2px; }

/* ---------- Detail lists ---------- */

.detail-list { display: grid; }
.detail-list > div {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--text-muted); }
.detail-list dd { color: var(--text); text-align: right; word-break: break-all; }
.detail-list .mono { font-size: 13px; }

.recent-list { display: grid; }
.recent-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.recent-list li:last-child { border-bottom: 0; }
.recent-list .mono { color: var(--text); font-size: 13px; }
.recent-list small { color: var(--text-muted); }

/* ---------- Premium compare ---------- */

.compare th:not(:first-child),
.compare td:not(:first-child) { text-align: center; }
.compare td:first-child { color: var(--text); }
.compare .icon { display: inline-flex; vertical-align: middle; }
.compare .yes { color: var(--text); }
.compare .no { color: var(--text-subtle); }
.compare .col-featured { background: rgba(255, 255, 255, 0.025); }

.premium-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.premium-status h2 { font-size: 22px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.premium-status p { margin-top: 8px; color: var(--text-muted); }

/* ---------- Settings ---------- */

.settings-grid { display: grid; gap: 24px; }
.form-stack { display: grid; gap: 18px; max-width: 420px; }
.danger-zone { border-color: rgba(239, 68, 68, 0.28); }
.danger-zone::before { display: none; }
.danger-zone .card-head { margin-bottom: 16px; }
.danger-zone h2 { color: var(--text); }

/* ---------- Toolbar, segmented control, pager ---------- */

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar-left,
.toolbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.segmented button {
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.search { position: relative; min-width: 240px; }
.search .input { height: 36px; font-size: 13px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 13px;
  flex-wrap: wrap;
}
.pager-controls { display: flex; align-items: center; gap: 10px; }

.row-actions { display: inline-flex; gap: 2px; }
.row-actions .icon-btn { width: 32px; height: 32px; }
.row-actions .icon-btn.is-danger:hover { color: var(--danger); background: rgba(239, 68, 68, 0.08); }
.key-cell { display: inline-flex; align-items: center; gap: 8px; max-width: 220px; }
.key-cell span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-cell .icon-btn { width: 28px; height: 28px; flex: none; }

/* ---------- Charts ---------- */

.charts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.chart-card { padding: 28px; }
.chart-card h3 { margin-bottom: 4px; }
.chart-card .chart-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart-axis { fill: var(--text-subtle); font-size: 11px; font-family: var(--font); }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-bar { transition: opacity var(--ease); }
.chart-bar:hover { opacity: 0.8; }
.chart-line { fill: none; stroke: #ffffff; stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--bg); stroke: #ffffff; stroke-width: 1.5; }
.chart-value { fill: var(--text); font-size: 11px; font-family: var(--mono); text-anchor: middle; }

/* ---------- Logs ---------- */

.log-time { color: var(--text-muted); white-space: nowrap; font-size: 13px; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .stats-5 { grid-template-columns: repeat(3, 1fr); }
  .charts { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .icon-btn.menu-toggle { display: grid; }
  .topbar { padding: 0 12px; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: min(280px, 82vw);
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-overlay { display: block; animation: fade-in 0.2s ease; }
  body.sidebar-open { overflow: hidden; }
  .main { margin-left: 0; padding: 28px 20px 72px; }
  .user-chip .user-name { display: none; }
  .topbar .btn span.btn-label { display: none; }

  .stats,
  .stats-5 { grid-template-columns: 1fr 1fr; }
  .welcome { padding: 28px 24px; }
  .welcome-logo { width: 52px; height: 52px; }
  .key-card,
  .card-lg { padding: 28px 22px; }
  .search { min-width: 0; width: 100%; }
  .toolbar-left,
  .toolbar-right { width: 100%; }
}

@media (max-width: 480px) {
  .stats,
  .stats-5 { grid-template-columns: 1fr; }
  .key-card .key-box { font-size: 16px; padding: 22px 12px; }
  .detail-list > div { flex-direction: column; gap: 4px; }
  .detail-list dd { text-align: left; }
  .welcome-logo { display: none; }
}
