/* ===== ATLAS AI — main.css: base, theme, layout, shared components ===== */
:root, :root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2c;
  --surface2: #16213a;
  --border: #1e2a44;
  --text: #e6edf7;
  --text-dim: #8b98ad;
  --accent: #22d3ee;
  --accent-ink: #062a30;
  --accent-soft: rgba(34, 211, 238, 0.12);
  --danger: #f87171;
  --ok: #34d399;
  --user-bubble: #16213a;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
}
:root[data-theme="light"] {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface2: #eef2f9;
  --border: #dde5f0;
  --text: #0f172a;
  --text-dim: #5b6b82;
  --accent: #0891b2;
  --accent-ink: #ffffff;
  --accent-soft: rgba(8, 145, 178, 0.10);
  --user-bubble: #e6f2f7;
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { height: 100%; }
body {
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Kufi Arabic", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; flex-shrink: 0; }

#app { display: flex; height: 100dvh; max-width: 100vw; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; min-width: 38px;
  border-radius: 10px; color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--surface2); color: var(--text); }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent); color: var(--accent-ink);
  border-radius: 10px; padding: 10px 16px; font-weight: 600;
}
.btn-ghost { border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-radius: 10px; padding: 10px 16px; font-weight: 600; }

/* ===== Generic modal ===== */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; align-items: center; justify-content: center;
  background: rgba(2, 8, 20, 0.6); backdrop-filter: blur(3px);
  animation: fadeIn 0.18s ease;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(480px, calc(100vw - 24px));
  max-height: min(82dvh, 640px); display: flex; flex-direction: column;
  animation: popIn 0.2s ease;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 16px;
}
.modal-body { padding: 16px; overflow-y: auto; }
.confirm-box { width: min(360px, calc(100vw - 24px)); padding: 20px; }
.confirm-title { font-weight: 600; font-size: 16px; margin-bottom: 8px; }
.confirm-text { color: var(--text-dim); font-size: 14px; margin-bottom: 18px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

/* ===== Toast ===== */
#toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast-msg {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 16px; border-radius: 999px; font-size: 13.5px;
  box-shadow: var(--shadow); animation: toastIn 0.25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ===== Setup screen ===== */
#setupScreen {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#setupScreen[hidden] { display: none; }
.setup-box { text-align: center; max-width: 420px; }
.setup-box h1 { margin: 14px 0 8px; font-size: 22px; }
.setup-box p { color: var(--text-dim); margin-bottom: 14px; }
.setup-box code {
  display: block; background: var(--surface); border: 1px solid var(--border);
  padding: 10px 14px; border-radius: 10px; font-size: 12.5px; overflow-x: auto;
  color: var(--accent); text-align: left;
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
