/* Theme: user-dashboard dark (oklch) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --radius: 0.625rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.488 0.243 264.376);
  --accent-foreground: oklch(0.985 0 0);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --sidebar: oklch(0.205 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.488 0.243 264.376);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.269 0 0);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --success: oklch(0.696 0.17 162.48);
  --destructive: oklch(0.704 0.191 22.216);
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.5;
}

#app, .login-screen { height: 100%; }

.screen { display: none; height: 100%; }
.screen.active { display: flex; }

/* ── Login (user-dashboard style) ── */
.login-screen {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--background);
  padding: 1rem;
}

.login-wrap {
  width: 100%;
  max-width: 28rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  text-align: center;
}

.login-wrap h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.login-subtitle {
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

#login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: left;
}

#login-form label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
}

#login-form input {
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--foreground);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#login-form input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px oklch(0.556 0 0 / 20%);
}

.login-error {
  color: var(--destructive);
  font-size: 0.8125rem;
  min-height: 1.125rem;
}

.btn-signin {
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: 9999px;
  padding: 0.625rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
  width: 15rem;
  margin: 0.5rem auto 0;
}

.btn-signin:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-signin:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-continue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 9999px;
  padding: 0.625rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  width: 15rem;
  margin: 0 auto;
  transition: opacity 0.2s;
}

.btn-continue:hover {
  opacity: 0.9;
}

/* ── Role Selection (user-dashboard style) ── */
#role-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background);
  padding: 1rem;
}

.role-card {
  width: 100%;
  max-width: 28rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.role-card .logo {
  font-size: 2.5rem;
  color: var(--sidebar-primary);
  margin-bottom: 0.25rem;
}

.role-card h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.subtitle {
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.role-card label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
}

.role-card input,
.role-card select {
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--foreground);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.role-card input:focus,
.role-card select:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px oklch(0.556 0 0 / 20%);
}

.role-card button,
#send-btn {
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

.role-card button:hover:not(:disabled),
#send-btn:hover {
  opacity: 0.9;
}

.role-card button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Chat Screen ── */
#chat-screen { flex-direction: row; }

#sidebar {
  width: 320px;
  min-width: 280px;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 12px;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h2 { font-size: 16px; font-weight: 700; }

#progress-badge {
  background: var(--sidebar-accent);
  color: var(--sidebar-primary);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 9999px;
}

#progress-bar-wrap {
  height: 4px;
  background: var(--sidebar-accent);
  border-radius: 2px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: var(--sidebar-primary);
  border-radius: 2px;
  transition: width 0.4s ease;
}

#checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

#checklist li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
}

#checklist li:hover { background: var(--sidebar-accent); }

#checklist li .check-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 2px solid var(--sidebar-border);
  border-radius: 50%;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all 0.2s;
}

#checklist li.done .check-icon {
  background: var(--success);
  border-color: var(--success);
  color: var(--background);
}

#checklist li.done .check-label { text-decoration: line-through; color: var(--muted-foreground); }

#checklist li.skipped .check-icon { border-color: var(--muted-foreground); }
#checklist li.skipped .check-label { text-decoration: line-through; color: var(--muted-foreground); opacity: 0.5; }

.check-label { display: flex; flex-direction: column; gap: 2px; }
.check-label .title { font-weight: 500; }
.check-label .desc { font-size: 12px; color: var(--muted-foreground); }

#reset-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

#reset-btn:hover { border-color: var(--muted-foreground); color: var(--foreground); }

#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}

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

#logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

#logout-btn:hover {
  color: var(--foreground);
  border-color: var(--muted-foreground);
}

#sidebar-toggle {
  background: none;
  border: none;
  color: var(--muted-foreground);
  font-size: 20px;
  cursor: pointer;
  display: none;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg {
  max-width: 720px;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--sidebar-primary);
  color: var(--sidebar-primary-foreground);
  border-bottom-right-radius: 2px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
}

.msg.assistant a {
  color: var(--sidebar-primary);
  text-decoration: underline;
}

.msg.typing::after {
  content: "●●●";
  animation: blink 1.2s infinite;
  letter-spacing: 3px;
}

@keyframes blink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

#chat-form {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--card);
}

#chat-input {
  flex: 1;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--foreground);
  padding: 12px 16px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#chat-input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px oklch(0.556 0 0 / 20%);
}

#send-btn {
  padding: 12px 24px;
  margin-top: 0;
}

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: left 0.3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.4);
  }
  #sidebar.open { left: 0; }
  #sidebar-toggle { display: block; }
}
