/* ===== CSS VARIABLES ===== */
:root {
  --bg-deep: #040d07;
  --bg: #081410;
  --surface: #0f1f18;
  --surface-hover: #142a21;
  --surface-raised: #19332a;
  --border: #1e3a2e;
  --border-subtle: #163028;
  --text: #d1d5db;
  --text-bright: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --accent: #34d399;
  --accent-dim: rgba(52,211,153,0.12);
  --accent-glow: rgba(52,211,153,0.06);
  --blue: #60a5fa; --amber: #fbbf24; --green: #34d399;
  --orange: #fb923c; --red: #f87171; --gray: #6b7280;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 8px;
  --transition: 180ms ease;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Subtle background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(52,211,153,0.03) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(52,211,153,0.02) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--text-bright); }

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: -0.2px;
}

/* ===== API KEY GATE ===== */
#gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  animation: fadeIn 600ms ease;
}

.gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 420px;
  text-align: center;
  position: relative;
  box-shadow:
    0 0 0 1px var(--border-subtle),
    0 24px 48px rgba(0,0,0,0.4),
    0 0 120px rgba(52,211,153,0.03);
}

.gate-card::before {
  content: '';
  position: absolute;
  top: -1px; left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 2px;
}

.gate-logo {
  height: 32px;
  width: auto;
  margin-bottom: 16px;
}

.gate-card h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.gate-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
  line-height: 1.5;
}

.gate-error {
  color: var(--red);
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
  padding: 8px 12px;
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.15);
  border-radius: var(--radius);
}

.input-wrap {
  position: relative;
  margin-bottom: 16px;
}

.input-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  width: 16px;
  height: 16px;
}

.gate-card input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.gate-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.gate-card input::placeholder { color: var(--text-dim); }

.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: var(--bg-deep);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.98); }

/* ===== DASHBOARD SHELL ===== */
#dashboard {
  display: none;
  padding: 28px 32px;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  animation: fadeIn 400ms ease;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  padding-bottom: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-logo {
  height: 28px;
  width: auto;
}

.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.3px;
}

header h1 span {
  color: var(--text-dim);
  font-weight: 400;
  margin-left: 8px;
  font-size: 13px;
}

.header-actions { display: flex; gap: 8px; align-items: center; }

.btn-ghost {
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-dim);
  background: var(--accent-glow);
}

.btn-ghost svg { width: 14px; height: 14px; }

/* ===== TAB BAR ===== */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin: 20px 0 24px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  animation: fadeIn 150ms ease;
}

.modal-overlay.removing { animation: fadeOut 150ms ease forwards; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 380px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  animation: modalIn 200ms ease;
}

.modal-overlay.removing .modal { animation: modalOut 150ms ease forwards; }

.modal h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 8px;
}

.modal p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.modal p strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 8px 18px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border);
}

.modal-btn-cancel {
  background: none;
  color: var(--text-muted);
}

.modal-btn-cancel:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.modal-btn-confirm {
  border: none;
}

.modal-btn-confirm.action-deploy {
  background: var(--accent);
  color: var(--bg-deep);
}

.modal-btn-confirm.action-deploy:hover { opacity: 0.88; }

.modal-btn-confirm.action-teardown {
  background: var(--red);
  color: #fff;
}

.modal-btn-confirm.action-teardown:hover { opacity: 0.88; }

/* ===== TOASTS ===== */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-family: var(--font-body);
  min-width: 280px;
  max-width: 420px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 300ms ease;
  border: 1px solid;
}

.toast.removing { animation: toastOut 200ms ease forwards; }

.toast-success {
  background: var(--surface);
  border-color: rgba(52,211,153,0.2);
  color: var(--text);
}

.toast-error {
  background: var(--surface);
  border-color: rgba(248,113,113,0.2);
  color: var(--text);
}

.toast-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.toast-success .toast-icon { color: var(--green); }
.toast-error .toast-icon { color: var(--red); }

.toast-msg { flex: 1; line-height: 1.4; }

.toast-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
  display: flex;
  transition: color var(--transition);
}

.toast-close:hover { color: var(--text); }
.toast-close svg { width: 14px; height: 14px; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  to { opacity: 0; }
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes modalOut {
  to { opacity: 0; transform: scale(0.95); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px) scale(0.96); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  #dashboard { padding: 20px; }
}

@media (max-width: 768px) {
  #dashboard { padding: 14px; }

  /* Header: stack and center */
  header {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  .header-left { justify-content: center; }
  .header-actions { width: 100%; }
  .header-actions button { flex: 1; justify-content: center; }

  /* Tab bar: scroll horizontally */
  .tab-bar { overflow-x: auto; }
}
