/* ========================================
   Strategic AI — Design System
   Palette: white, slate navy, deep blue
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #F8FAFC;
  --bg-secondary: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F1F5F9;
  --bg-card-active: #EFF6FF;
  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --accent: #1D4ED8;
  --accent-light: #3B82F6;
  --accent-dark: #1E3A8A;
  --accent-bg: #EFF6FF;
  --border: #E2E8F0;
  --border-light: #F1F5F9;
  --border-active: #BFDBFE;
  --success: #059669;
  --success-bg: #ECFDF5;
  --locked: #94A3B8;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: 'Inter', -apple-system, system-ui, sans-serif;
}

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

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

/* ========================================
   Layout
   ======================================== */

.page {
  display: none;
  min-height: 100vh;
}

.page.active {
  display: flex;
  flex-direction: column;
}

/* ========================================
   Navbar
   ======================================== */

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  height: 64px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.navbar-logo {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}

.navbar-subtitle {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.btn-back:hover {
  background: var(--bg-primary);
  border-color: var(--border-active);
  color: var(--accent);
}

.btn-logout {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  padding: 8px;
  transition: color 0.15s;
  font-family: var(--font-sans);
}

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

/* ========================================
   Login Page
   ======================================== */

#login-page {
  background: var(--bg-primary);
}

.login-page-bg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 80px;
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
}

.login-logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 32px;
}

/* Form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.form-input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.login-btn {
  width: 100%;
  padding: 14px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  margin-top: 4px;
  letter-spacing: -0.01em;
}

.login-btn:hover {
  background: var(--accent-dark);
}

.login-btn:active {
  transform: scale(0.99);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.login-error {
  color: #DC2626;
  font-size: 0.84rem;
  margin-top: 4px;
  display: none;
  padding: 10px 14px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
}

.login-help {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

.login-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  text-align: center;
  font-size: 0.76rem;
  color: var(--text-muted);
  background: var(--bg-primary);
  border-top: 1px solid var(--border-light);
}

/* ========================================
   Dashboard Page
   ======================================== */

.dashboard-content {
  flex: 1;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px;
}

.dashboard-header {
  margin-bottom: 40px;
}

.dashboard-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.dashboard-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.dashboard-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Progress Steps */
.progress-steps {
  display: flex;
  align-items: center;
  margin-bottom: 40px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.progress-step.active {
  color: var(--text-primary);
}

.progress-step.completed {
  color: var(--success);
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.progress-step.active .step-number {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.progress-step.completed .step-number {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.progress-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 16px;
  min-width: 30px;
}

.progress-line.completed {
  background: var(--success);
}

/* Agent Cards */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px 24px;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.agent-card.active {
  border-color: var(--border-active);
  box-shadow: var(--shadow-md);
}

.agent-card.active:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.agent-card.locked {
  opacity: 0.5;
}

.agent-card.completed {
  border-color: #A7F3D0;
  background: var(--success-bg);
}

.agent-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.agent-card.active .agent-label {
  color: var(--accent);
}

.agent-card.completed .agent-label {
  color: var(--success);
}

.agent-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}

.agent-desc {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
  flex: 1;
}

.agent-features {
  list-style: none;
  margin-bottom: 20px;
}

.agent-features li {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}

.agent-features li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 11px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-active);
}

.agent-card.active .agent-features li::before {
  background: var(--accent-light);
}

.agent-card.locked .agent-features li::before {
  background: var(--locked);
}

.agent-card.completed .agent-features li::before {
  background: #6EE7B7;
}

.agent-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  width: 100%;
}

.agent-card.active .agent-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.agent-card.active .agent-btn:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.agent-card.locked .agent-btn {
  cursor: not-allowed;
  color: var(--locked);
  background: var(--bg-primary);
}

.agent-card.completed .agent-btn {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.agent-card.completed .agent-btn:hover {
  background: #047857;
  border-color: #047857;
}

.lock-icon {
  font-size: 0.85rem;
}

/* ========================================
   Chat Page
   ======================================== */

#chat-page {
  height: 100vh;
}

.chat-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 14px 40px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-agent-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.chat-agent-step {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--bg-primary);
}

.message {
  max-width: 780px;
  width: 100%;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-assistant {
  align-self: flex-start;
}

.message-user {
  align-self: flex-end;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  line-height: 1.65;
  font-size: 0.91rem;
}

.message-assistant .message-bubble {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.message-user .message-bubble {
  background: var(--accent);
  color: #fff;
}

/* Markdown inside messages */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
  font-weight: 700;
  margin: 16px 0 8px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.message-assistant .message-bubble h1 { font-size: 1.2rem; }
.message-assistant .message-bubble h2 { font-size: 1.1rem; }
.message-assistant .message-bubble h3 { font-size: 1rem; }

.message-bubble ul,
.message-bubble ol {
  padding-left: 20px;
  margin: 8px 0;
}

.message-bubble li {
  margin: 4px 0;
}

.message-bubble strong {
  font-weight: 600;
}

.message-bubble p {
  margin: 8px 0;
}

.message-bubble p:first-child { margin-top: 0; }
.message-bubble p:last-child { margin-bottom: 0; }

.message-bubble code {
  background: rgba(0,0,0,0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}

.message-bubble blockquote {
  border-left: 3px solid var(--border-active);
  padding-left: 14px;
  margin: 10px 0;
  color: var(--text-secondary);
}

/* Typing indicator */
.typing-indicator {
  display: none;
  align-self: flex-start;
  padding: 14px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.typing-indicator.visible {
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-light);
  animation: typing 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* Chat Input */
.chat-input-area {
  padding: 20px 40px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-input-wrapper {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-textarea {
  flex: 1;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.91rem;
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text-primary);
  resize: none;
  outline: none;
  min-height: 48px;
  max-height: 150px;
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-textarea::placeholder {
  color: var(--text-muted);
}

.chat-textarea:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-send-btn {
  padding: 13px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  height: 48px;
}

.chat-send-btn:hover {
  background: var(--accent-dark);
}

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

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

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.81rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-upload:hover {
  background: var(--bg-primary);
  border-color: var(--border-active);
  color: var(--accent);
}

.btn-complete-agent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  background: var(--success);
  color: #fff;
  font-size: 0.81rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-complete-agent:hover {
  background: #047857;
  border-color: #047857;
}

.btn-download-report {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--border-active);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font-size: 0.81rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-download-report:hover {
  background: var(--accent-bg);
}

/* File preview */
.file-preview {
  display: none;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  align-items: center;
  gap: 8px;
}

.file-preview.visible {
  display: flex;
}

.file-preview-name {
  flex: 1;
}

.file-preview-remove {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  border: none;
  background: none;
  padding: 2px 6px;
  transition: color 0.15s;
}

.file-preview-remove:hover {
  color: #DC2626;
}

/* ========================================
   Report Download Card
   ======================================== */

.report-download-card {
  background: var(--success-bg);
  border: 1px solid #A7F3D0;
  border-radius: var(--radius-md);
  padding: 24px 28px;
  margin: 8px 0 16px;
  max-width: 560px;
}

.report-download-title {
  font-size: 1rem;
  font-weight: 600;
  color: #065F46;
  margin-bottom: 8px;
}

.report-download-desc {
  font-size: 0.875rem;
  color: #047857;
  margin-bottom: 16px;
  line-height: 1.5;
}

.report-download-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-download-report {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-download-report:hover {
  background: #047857;
}

.btn-back-dashboard {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: transparent;
  color: #047857;
  border: 1px solid #A7F3D0;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-back-dashboard:hover {
  background: #D1FAE5;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
  .navbar {
    padding: 0 20px;
  }

  .agents-grid {
    grid-template-columns: 1fr;
  }

  .progress-steps {
    display: none;
  }

  .dashboard-content {
    padding: 32px 16px;
  }

  .chat-messages {
    padding: 20px 16px;
  }

  .chat-input-area {
    padding: 16px;
  }

  .chat-header {
    padding: 12px 20px;
  }
}

@media (max-width: 540px) {
  .navbar-subtitle {
    display: none;
  }

  .login-card {
    padding: 32px 24px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .dashboard-title {
    font-size: 1.4rem;
  }
}
