/* Dockbox Admin */
:root {
  --bg: #f7f8fc;
  --bg-elevated: #ffffff;
  --sidebar: rgba(255, 255, 255, 0.82);
  --card: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-2: #059669;
  --accent-glow: rgba(37, 99, 235, 0.14);
  --accent-2-glow: rgba(5, 150, 105, 0.1);
  --gradient: linear-gradient(135deg, #2563eb 0%, #059669 100%);
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 12px;
  --radius-lg: 18px;
  --font: 'Outfit', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --sidebar-w: 252px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 40px rgba(15, 23, 42, 0.1);
  --topbar-bg: rgba(255, 255, 255, 0.72);
  --input-bg: #ffffff;
  --table-head: #f8fafc;
  --table-hover: rgba(37, 99, 235, 0.03);
  --noise-opacity: 0.025;
  --glow-opacity: 0.55;
}

[data-theme="dark"] {
  --bg: #0a0b0f;
  --bg-elevated: #12141c;
  --sidebar: rgba(18, 20, 28, 0.88);
  --card: #161922;
  --border: rgba(255, 255, 255, 0.07);
  --text: #e8eaef;
  --muted: #8b92a5;
  --accent: #3b9eff;
  --accent-2: #00d4aa;
  --accent-glow: rgba(59, 158, 255, 0.22);
  --accent-2-glow: rgba(0, 212, 170, 0.15);
  --gradient: linear-gradient(135deg, #3b9eff 0%, #00d4aa 100%);
  --shadow-sm: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 24px 64px rgba(0, 0, 0, 0.45);
  --topbar-bg: rgba(18, 20, 28, 0.75);
  --input-bg: #0f1118;
  --table-head: rgba(255, 255, 255, 0.03);
  --table-hover: rgba(59, 158, 255, 0.06);
  --noise-opacity: 0.035;
  --glow-opacity: 0.9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }
.loading { color: var(--muted); padding: 2.5rem; font-size: 0.95rem; }

/* Ambient background */
.admin-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.admin-bg .noise {
  position: absolute;
  inset: 0;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.admin-bg .glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  opacity: var(--glow-opacity);
}

.admin-bg .glow-1 {
  width: 520px;
  height: 520px;
  background: var(--accent-glow);
  top: -180px;
  right: -80px;
}

.admin-bg .glow-2 {
  width: 420px;
  height: 420px;
  background: var(--accent-2-glow);
  bottom: 10%;
  left: -120px;
}

#app { position: relative; z-index: 1; }

/* Logo */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo-icon {
  display: flex;
  color: var(--accent);
  flex-shrink: 0;
}

.logo-icon svg { width: 26px; height: 26px; }

.logo-text {
  white-space: nowrap;
  line-height: 1;
}

.logo span.accent {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: 0.2s ease;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: rgba(37, 99, 235, 0.25);
  background: rgba(37, 99, 235, 0.06);
}

.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* Auth */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient);
}

.auth-card .logo { margin-bottom: 1.75rem; }

.auth-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}

.auth-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

.auth-card label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--muted);
}

.auth-card input,
.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-card input:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-hint {
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.auth-hint a { color: var(--accent); font-weight: 500; text-decoration: none; }
.auth-hint a:hover { text-decoration: underline; }

.auth-theme {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 10;
}

/* Layout */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
}

.sidebar .logo {
  padding: 1.35rem 1.4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: 0.18s ease;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  opacity: 0.7;
  flex-shrink: 0;
}

.sidebar-nav a:hover {
  background: rgba(37, 99, 235, 0.06);
  color: var(--text);
}

.sidebar-nav a:hover .nav-icon { opacity: 1; }

.sidebar-nav a.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(5, 150, 105, 0.08));
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.sidebar-nav a.active .nav-icon { opacity: 1; color: var(--accent); }

.sidebar-footer {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

[data-theme="dark"] .user-avatar { color: #0a0b0f; }

.user-meta { min-width: 0; }

.user-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-plan {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 2rem;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.content {
  padding: 1.75rem 2rem 3rem;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.58rem 1.05rem;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: 0.18s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
}

[data-theme="dark"] .btn-primary { color: #0a0b0f; }

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}

.btn-outline {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: rgba(37, 99, 235, 0.3);
  background: rgba(37, 99, 235, 0.05);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--text);
  background: rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .btn-ghost:hover { background: rgba(255, 255, 255, 0.05); }

.btn-danger {
  background: rgba(220, 38, 38, 0.08);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.btn-danger:hover { background: rgba(220, 38, 38, 0.14); }

.btn-sm { padding: 0.42rem 0.8rem; font-size: 0.8rem; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }

/* Cards & Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--stat-glow, var(--accent-glow));
  filter: blur(28px);
  opacity: 0.7;
  pointer-events: none;
}

.stat-card:nth-child(1) { --stat-glow: rgba(37, 99, 235, 0.2); }
.stat-card:nth-child(2) { --stat-glow: rgba(5, 150, 105, 0.2); }
.stat-card:nth-child(3) { --stat-glow: rgba(139, 92, 246, 0.2); }
.stat-card:nth-child(4) { --stat-glow: rgba(245, 158, 11, 0.2); }
.stat-card:nth-child(5) { --stat-glow: rgba(236, 72, 153, 0.2); }
.stat-card:nth-child(6) { --stat-glow: rgba(14, 165, 233, 0.2); }

.stat-card .label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.stat-card .value {
  font-size: 1.85rem;
  font-weight: 700;
  margin-top: 0.3rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-card .value.sm { font-size: 1.15rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-body { padding: 1.25rem 1.35rem; }

.card-body p { margin-bottom: 0.5rem; }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

.table th {
  text-align: left;
  padding: 0.8rem 1.35rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--table-head);
  font-weight: 600;
}

.table td {
  padding: 0.9rem 1.35rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr { transition: background 0.15s; }
.table tbody tr:hover td { background: var(--table-hover); }
.table tbody tr:last-child td { border-bottom: none; }

.table a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.table a:hover { text-decoration: underline; }

.table code {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: rgba(37, 99, 235, 0.08);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}

[data-theme="dark"] .table code { background: rgba(59, 158, 255, 0.1); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.65rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.badge-success { background: rgba(5, 150, 105, 0.12); color: #059669; }
.badge-warning { background: rgba(217, 119, 6, 0.12); color: #d97706; }
.badge-danger { background: rgba(220, 38, 38, 0.12); color: #dc2626; }
.badge-info { background: rgba(37, 99, 235, 0.12); color: #2563eb; }
.badge-muted { background: rgba(100, 116, 139, 0.12); color: var(--muted); }

[data-theme="dark"] .badge-success { color: #00d4aa; }
[data-theme="dark"] .badge-info { color: #3b9eff; }

/* Logs */
.log-viewer {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: #0c1017;
  color: #cbd5e1;
  padding: 1.15rem;
  border-radius: 10px;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.75;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.log-viewer .success { color: #34d399; }

/* Chart */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 130px;
  padding: 1rem 0;
}

.chart-bar {
  flex: 1;
  background: var(--gradient);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  opacity: 0.85;
  transition: height 0.35s ease, opacity 0.2s;
}

.chart-bar:hover { opacity: 1; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.35rem;
}

.tab {
  padding: 0.7rem 1rem;
  border: none;
  background: none;
  font: inherit;
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 11, 15, 0.55);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: 0.15s;
}

.modal-close:hover {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text);
}

.modal-body { padding: 1.5rem; }

.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Deploy timeline */
.deploy-list { display: flex; flex-direction: column; gap: 0.55rem; }

.deploy-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.88rem;
  transition: 0.15s;
}

.deploy-item:hover { border-color: rgba(37, 99, 235, 0.2); }

.deploy-item.current {
  border-color: rgba(5, 150, 105, 0.35);
  background: rgba(5, 150, 105, 0.06);
}

.empty {
  text-align: center;
  padding: 3.5rem 2rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--text);
  color: var(--bg);
  padding: 0.8rem 1.3rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
}

/* Responsive */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .content { padding: 1.25rem 1rem 2rem; }
  .topbar { padding: 1rem 1.25rem; }
}
