/* ── Base ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

/* The HTML `hidden` attribute MUST take priority over .screen's display:flex.
   Without this, both login and app screens render at once and the user sees
   the login on top with no obvious feedback after signing in. */
[hidden] { display: none !important; }

:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #20242d;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8b93a3;
  --accent: #6ea8fe;
  --accent-2: #4d8ff7;
  --success: #3ddc84;
  --error: #ff6b6b;
  --warn: #f5a524;
  --radius: 10px;
  --radius-sm: 6px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  min-height: 100vh;
}

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

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 0.75rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); }

.screen { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Login ────────────────────────────────────────────────────────────── */
#login-screen { align-items: center; justify-content: center; padding: 2rem; }

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}

.login-card h1 { margin-bottom: 0.4rem; }
.login-card p { margin-top: 0; }

#login-form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.5rem; }

#login-error {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

/* ── App layout ───────────────────────────────────────────────────────── */
#app-screen header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

#app-screen main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}

#app-screen footer {
  padding: 1rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

/* ── Form fields ──────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1.25rem;
}

.field > span {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

input[type="password"],
input[type="text"],
select,
textarea {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  min-height: 240px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 168, 254, 0.2);
}

/* ── Config grid ──────────────────────────────────────────────────────── */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.config-grid .field { margin-bottom: 0; }

@media (max-width: 800px) {
  .config-grid { grid-template-columns: 1fr; }
}

.folder-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
#folder-name { flex: 1; min-width: 0; word-break: break-all; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}

button:hover:not(:disabled) { background: #262b36; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  color: #0a0d12;
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }

button.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: inherit;
  cursor: pointer;
}
button.link:hover { text-decoration: underline; background: none; }
button.link.small { font-size: 0.8rem; }

.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* ── Parse preview ────────────────────────────────────────────────────── */
.parse-preview {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

/* ── Progress list ────────────────────────────────────────────────────── */
#progress-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

#progress-list li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

#progress-list li.pending { border-left-color: var(--muted); }
#progress-list li.in-progress { border-left-color: var(--accent); }
#progress-list li.success { border-left-color: var(--success); }
#progress-list li.error { border-left-color: var(--error); }

#progress-list li .name { font-weight: 600; }
#progress-list li .status { color: var(--muted); }
#progress-list li.success .status { color: var(--success); }
#progress-list li.error .status { color: var(--error); }
#progress-list li.in-progress .status { color: var(--accent); }

/* ── Dialog ───────────────────────────────────────────────────────────── */
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 600px;
  width: 90%;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

dialog pre {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
}

dialog code {
  background: var(--panel-2);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

dialog form { margin-top: 1rem; text-align: right; }
