/* Distill App — Shared Styles */

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

:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-light: #eff6ff;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --red: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout ── */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  padding: 16px 24px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
  text-decoration: none;
}

.steps-bar {
  display: flex;
  gap: 8px;
  margin-left: auto;
  align-items: center;
}

.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray-200);
}
.step-dot.active { background: var(--blue); }
.step-dot.done { background: var(--green); }

.main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 48px 24px;
}

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px;
  width: 100%;
  max-width: 560px;
}

.card-wide { max-width: 760px; }
.card-full { max-width: 100%; padding: 0; box-shadow: none; background: transparent; }

/* ── Typography ── */
h1 { font-size: 28px; font-weight: 700; color: var(--gray-900); margin-bottom: 8px; }
h2 { font-size: 22px; font-weight: 600; color: var(--gray-900); margin-bottom: 12px; }
.subtitle { color: var(--gray-600); font-size: 16px; margin-bottom: 32px; }

/* ── Form elements ── */
label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
  margin-bottom: 6px;
}

input[type="email"],
input[type="text"],
input[type="color"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 15px;
  color: var(--gray-900);
  background: white;
  transition: border-color .15s;
  outline: none;
}

input[type="color"] {
  padding: 4px 8px;
  height: 40px;
  cursor: pointer;
}

input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

.field { margin-bottom: 20px; }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--blue);
  color: white;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: white;
  color: var(--gray-800);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-50); }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  padding: 8px 12px;
}
.btn-ghost:hover { color: var(--gray-900); background: var(--gray-100); }

.btn-full { width: 100%; justify-content: center; }

/* ── File drop zone ── */
.drop-zone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--gray-50);
  margin-bottom: 24px;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--blue);
  background: var(--blue-light);
}
.drop-zone-icon { font-size: 32px; margin-bottom: 12px; }
.drop-zone-label { font-weight: 600; color: var(--gray-800); margin-bottom: 4px; }
.drop-zone-hint { font-size: 13px; color: var(--gray-400); }

.file-list { list-style: none; margin-bottom: 24px; display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--gray-50);
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  font-size: 14px;
}
.file-item-icon { font-size: 18px; }
.file-item-name { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item-size { color: var(--gray-400); font-size: 12px; }
.file-item-remove { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: 16px; padding: 0; }
.file-item-remove:hover { color: var(--red); }

/* ── Progress ── */
.progress-section { margin-top: 32px; }
.progress-bar-wrap { background: var(--gray-100); border-radius: 99px; height: 6px; margin: 12px 0; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; background: var(--blue); transition: width .4s; }
.progress-label { font-size: 14px; color: var(--gray-600); text-align: center; }

/* ── Chat ── */
.chat-page {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

.chat-header {
  padding: 16px 0;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-info h2 { margin-bottom: 2px; font-size: 17px; }
.chat-header-info p { font-size: 13px; color: var(--gray-600); margin: 0; }

.chat-messages {
  overflow-y: auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message { display: flex; gap: 10px; max-width: 85%; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }

.message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.55;
}

.message.bot .message-bubble {
  background: white;
  border: 1px solid var(--gray-200);
  border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
  background: var(--blue);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 4px;
}
.message.bot .message-avatar { background: var(--blue-light); }
.message.user .message-avatar { background: var(--gray-200); }

.typing-indicator {
  display: flex; gap: 4px; align-items: center; padding: 12px 16px;
  background: white; border: 1px solid var(--gray-200);
  border-radius: 16px; border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--gray-400);
  animation: typing-bounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.chat-footer {
  padding: 16px 0 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 22px;
  font-size: 15px;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  outline: none;
  font-family: inherit;
  line-height: 1.4;
}
.chat-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.chat-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Output / Results ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.stat-number { font-size: 32px; font-weight: 700; color: var(--blue); }
.stat-label { font-size: 13px; color: var(--gray-600); margin-top: 4px; }

.type-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.type-pill {
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  background: var(--blue-light);
  color: var(--blue-dark);
}

.download-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; }
.download-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
}
.download-item-icon { font-size: 28px; }
.download-item-info { flex: 1; }
.download-item-info strong { display: block; font-size: 15px; }
.download-item-info span { font-size: 13px; color: var(--gray-600); }

.next-steps {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  font-size: 14px;
  color: var(--gray-600);
  margin-bottom: 20px;
}
.next-steps h3 { font-size: 14px; font-weight: 600; color: var(--gray-800); margin-bottom: 12px; }
.next-steps ol { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }

.upgrade-banner {
  background: linear-gradient(135deg, #1e40af, #2563eb);
  color: white;
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.upgrade-banner h3 { font-size: 18px; margin-bottom: 8px; }
.upgrade-banner p { opacity: .85; margin-bottom: 16px; font-size: 14px; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.alert-info { background: var(--blue-light); color: var(--blue-dark); border: 1px solid #bfdbfe; }

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
.spinner-dark { border-color: var(--gray-200); border-top-color: var(--blue); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 600px) {
  .main { padding: 24px 16px; }
  .card { padding: 24px; }
  h1 { font-size: 22px; }
  .chat-page { padding: 0 8px; }
}
