/* ─── Design tokens ───────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-0:        #0a0a0f;          /* base dark */
  --bg-1:        #11131a;          /* surface 1 */
  --bg-2:        #181b24;          /* surface 2 */
  --bg-3:        #1f2330;          /* surface 3 / hover */
  --bg-overlay:  rgba(255,255,255,0.04);

  /* Foreground */
  --fg:          #e8eaf2;
  --fg-mute:     #8b90a3;
  --fg-dim:      #5d6275;

  /* Borders */
  --border:      #232733;
  --border-hi:   #2e3441;

  /* Accents */
  --accent:      #5e6bf0;          /* primary blue/indigo */
  --accent-h:    #4a57e6;
  --discord:     #5865f2;
  --discord-h:   #4752c4;
  --success:     #3ddc97;
  --warn:        #f0a830;
  --danger:      #f0586a;

  /* Radius */
  --r-sm:        6px;
  --r-md:        10px;
  --r-lg:        14px;

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg:   0 12px 40px rgba(0,0,0,0.5);

  /* Layout */
  --sidebar-w:   260px;
  --header-h:    56px;
  --space:       16px;

  /* Type */
  --font:        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:   "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
code, pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-overlay);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--fg);
}

/* ─── Login screen ────────────────────────────────────────── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(94,107,240,0.12) 0%, transparent 70%),
    var(--bg-0);
}

.login-card {
  max-width: 380px;
  width: 100%;
  text-align: center;
  padding: 40px 32px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  color: var(--accent);
  display: grid;
  place-items: center;
}
.login-logo svg { width: 100%; height: 100%; }

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--fg-mute);
  margin-bottom: 28px;
  font-size: 14px;
}

.login-footnote {
  color: var(--fg-dim);
  font-size: 12px;
  margin-top: 16px;
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 0;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  color: white;
  background: var(--accent);
  transition: background 0.15s, transform 0.05s;
  width: 100%;
}
.btn:hover { background: var(--accent-h); }
.btn:active { transform: translateY(1px); }

.btn-discord {
  background: var(--discord);
}
.btn-discord:hover { background: var(--discord-h); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  color: var(--fg-mute);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-ghost:hover {
  color: var(--fg);
  border-color: var(--border-hi);
  background: var(--bg-overlay);
}

/* ─── App shell ───────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-header {
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--fg);
}
.app-brand svg { color: var(--accent); }

.app-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--discord));
  color: white;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.user-name {
  color: var(--fg);
  font-weight: 500;
}

/* ─── App body : sidebar + main ─────────────────────────── */
.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-1);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h2 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-mute);
}

.badge-count {
  display: inline-block;
  padding: 1px 7px;
  background: var(--bg-3);
  color: var(--fg-mute);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  min-width: 22px;
  text-align: center;
}

.project-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.1s;
  border-left: 2px solid transparent;
}
.project-item:hover { background: var(--bg-2); }
.project-item.active {
  background: var(--bg-2);
  border-left-color: var(--accent);
}
.project-item .project-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-item .project-status {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg-dim);
}
.project-item .project-status.ready { background: var(--success); }
.project-item .project-status.partial { background: var(--warn); }

.state-loading,
.state-empty-list {
  padding: 16px;
  text-align: center;
  color: var(--fg-mute);
  font-size: 13px;
  list-style: none;
}

.sidebar-hint {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-mute);
  line-height: 1.5;
}
.sidebar-hint svg { flex-shrink: 0; margin-top: 2px; color: var(--fg-dim); }
.sidebar-hint code {
  font-size: 11px;
  padding: 1px 5px;
}

/* ── Main area ───────────────────────────────────────────── */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-0);
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  color: var(--fg-mute);
}
.empty-state svg { color: var(--fg-dim); margin-bottom: 20px; }
.empty-state h2 {
  color: var(--fg);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}
.empty-state p { font-size: 14px; max-width: 380px; }

.project-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
}
.project-header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}
.project-meta {
  font-size: 12px;
  color: var(--fg-mute);
  font-family: var(--font-mono);
}

.project-actions {
  display: flex;
  gap: 8px;
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-mute);
  transition: background 0.1s, color 0.1s;
}
.tab:hover { color: var(--fg); background: var(--bg-overlay); }
.tab.active {
  color: var(--fg);
  background: var(--bg-3);
}
.tab .badge-count {
  background: var(--bg-overlay);
  font-size: 10px;
  padding: 0 6px;
  min-width: 18px;
}

.tab-content {
  display: none;
  flex: 1;
  min-height: 0;
}
.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* ── Preview ─────────────────────────────────────────────── */
.preview-frame {
  flex: 1;
  position: relative;
  background:
    repeating-conic-gradient(#1a1d28 0% 25%, #161922 0% 50%) 50% / 20px 20px;
  /* subtle checkerboard so transparent iframes are visible */
}
#preview-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}

.state-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  color: var(--fg-mute);
}
.state-empty svg { color: var(--fg-dim); margin-bottom: 16px; }
.state-empty p { font-size: 14px; max-width: 420px; line-height: 1.6; }
.state-empty p strong { color: var(--fg); font-weight: 600; display: block; margin-bottom: 4px; }
.muted { color: var(--fg-mute); font-size: 13px; }

/* ── File list ───────────────────────────────────────────── */
.file-list {
  flex: 1;
  list-style: none;
  overflow-y: auto;
  padding: 12px 20px;
}
.file-list .file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.file-list .file-item:hover { background: var(--bg-2); }
.file-list .file-item svg { color: var(--fg-dim); flex-shrink: 0; }
.file-list .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .file-size { color: var(--fg-mute); font-size: 11px; flex-shrink: 0; }

/* ── Scrollbars ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 10px;
  border: 2px solid var(--bg-0);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 720px) {
  .app-sidebar { width: 220px; }
  .app-header { padding: 0 12px; }
  .project-header { padding: 14px 16px; }
  .user-name { display: none; }
  .empty-state h2 { font-size: 16px; }
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.project-view { animation: fadeIn 0.2s ease-out; }
.tab-content.active { animation: fadeIn 0.15s ease-out; }
