/* ═══════════════════════════════════════════════
   DESIGN SYSTEM — Monochromatic Gray Scale
   ═══════════════════════════════════════════════ */
:root {
  --c-50:  #f8f9fa;
  --c-100: #e9ecef;
  --c-200: #dee2e6;
  --c-300: #ced4da;
  --c-400: #adb5bd;
  --c-500: #6c757d;
  --c-600: #495057;
  --c-700: #343a40;
  --c-800: #212529;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 4px rgba(33,37,41,.05), 0 4px 16px rgba(33,37,41,.06);
  --shadow-widget: 0 8px 32px rgba(33,37,41,.14);
  --transition: 180ms ease;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

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

/* ── Typography ── */
h1, h2, h3, h4 { color: var(--c-800); font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p  { color: var(--c-600); }
small, .text-sm { font-size: .875rem; }
.text-muted { color: var(--c-500); }

/* ── Layout ── */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.container--wide { max-width: 1040px; }

/* ── Card ── */
.card {
  background: var(--c-50);
  border: 1px solid var(--c-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 2rem;
}
.card--sm { padding: 1.25rem 1.5rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .625rem 1.25rem;
  font-size: .9375rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--c-800);
  color: var(--c-50);
  border-color: var(--c-800);
}
.btn-primary:hover { background: var(--c-700); border-color: var(--c-700); }
.btn-primary:disabled,
.btn-primary.disabled {
  background: var(--c-100);
  color: var(--c-400);
  border-color: var(--c-100);
  cursor: not-allowed;
}
.btn-outline {
  background: transparent;
  color: var(--c-600);
  border-color: var(--c-200);
}
.btn-outline:hover {
  background: var(--c-50);
  border-color: var(--c-300);
}
.btn-lg { padding: .875rem 1.75rem; font-size: 1.0625rem; }
.btn-sm { padding: .4rem .875rem; font-size: .8125rem; }

/* ── Google Button ── */
.btn-google {
  background: var(--c-800);
  color: var(--c-50);
  border-color: var(--c-800);
  gap: .75rem;
  font-size: 1rem;
  padding: .875rem 2rem;
  border-radius: 8px;
  width: 100%;
  justify-content: center;
}
.btn-google:hover { background: var(--c-700); border-color: var(--c-700); }
.btn-google svg { opacity: .65; flex-shrink: 0; }

/* ── Nav ── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--c-200);
  background: var(--c-50);
}
.nav__logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--c-800);
  text-decoration: none;
  letter-spacing: -.02em;
}
.nav__user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .875rem;
  color: var(--c-500);
}
.nav__avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--c-200);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  color: var(--c-600);
  font-weight: 600;
  border: 1.5px solid var(--c-300);
  overflow: hidden;
}
.nav__avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── Step indicator ── */
.steps {
  display: flex;
  gap: 0;
  margin-bottom: 2.5rem;
}
.step {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8125rem;
  color: var(--c-400);
  font-weight: 500;
  flex: 1;
  position: relative;
}
.step::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-200);
  margin: 0 .75rem;
}
.step:last-child::after { display: none; }
.step__num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--c-100);
  border: 1.5px solid var(--c-300);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  flex-shrink: 0;
}
.step.active { color: var(--c-700); }
.step.active .step__num {
  background: var(--c-800);
  border-color: var(--c-800);
  color: var(--c-50);
}
.step.done { color: var(--c-500); }
.step.done .step__num {
  background: var(--c-700);
  border-color: var(--c-700);
  color: var(--c-50);
}

/* ── Doc List ── */
.doc-list { display: flex; flex-direction: column; gap: 0; }
.doc-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--c-200);
  cursor: pointer;
  transition: background var(--transition);
  border-radius: var(--radius-sm);
}
.doc-row:last-child { border-bottom: none; }
.doc-row:hover { background: var(--c-100); }
.doc-row.selected { background: var(--c-100); }

/* Custom checkbox */
.cb {
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--c-300);
  background: var(--c-50);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}
.cb.checked {
  background: var(--c-800);
  border-color: var(--c-800);
}
.cb.checked::after {
  content: '';
  display: block;
  width: 10px; height: 6px;
  border-left: 2px solid var(--c-50);
  border-bottom: 2px solid var(--c-50);
  transform: rotate(-45deg) translate(1px, -1px);
}

.doc-icon {
  width: 34px; height: 34px;
  background: var(--c-100);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--c-200);
}
.doc-icon svg { color: var(--c-500); }

.doc-info { flex: 1; min-width: 0; }
.doc-title {
  font-weight: 600;
  color: var(--c-800);
  font-size: .9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-meta {
  font-size: .8125rem;
  color: var(--c-500);
  margin-top: 1px;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--c-200);
}
.pagination__info { font-size: .875rem; color: var(--c-500); }
.pagination__controls { display: flex; gap: .5rem; }

/* ── Progress / Pipeline ── */
.pipeline-log {
  background: var(--c-50);
  border: 1px solid var(--c-200);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .8125rem;
  max-height: 280px;
  overflow-y: auto;
}
.log-line {
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  padding: .25rem 0;
  color: var(--c-600);
  line-height: 1.45;
}
.log-line + .log-line { border-top: 1px solid var(--c-100); }
.log-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.log-dot--pending  { background: var(--c-400); }
.log-dot--running  { background: var(--c-700); animation: pulse 1s infinite; }
.log-dot--done     { background: var(--c-800); }
.log-dot--error    { background: #c0392b; }
.log-line--error   { color: var(--c-800); background: var(--c-50); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--c-200);
  border-radius: 99px;
  overflow: hidden;
  margin: 1rem 0;
}
.progress-bar__fill {
  height: 100%;
  background: var(--c-700);
  border-radius: 99px;
  transition: width .4s ease;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  font-size: .75rem;
  font-weight: 500;
  padding: .25rem .625rem;
  border-radius: 99px;
  background: var(--c-100);
  color: var(--c-600);
}
.status-badge--active {
  background: var(--c-800);
  color: var(--c-50);
}

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: .375rem; }
.form-label { font-size: .875rem; font-weight: 500; color: var(--c-600); }
.form-input {
  padding: .625rem .875rem;
  border: 1px solid var(--c-200);
  border-radius: var(--radius-sm);
  background: var(--c-50);
  color: var(--c-800);
  font-size: .9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input::placeholder { color: var(--c-400); }
.form-input:focus {
  border-color: var(--c-700);
  box-shadow: 0 0 0 3px rgba(52,58,64,.08);
}
.form-input:disabled {
  background: var(--c-100);
  color: var(--c-400);
  cursor: not-allowed;
}

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid var(--c-200);
  margin: 1.5rem 0;
}

/* ── Alert ── */
.alert {
  padding: .875rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  border: 1px solid var(--c-200);
  background: var(--c-100);
  color: var(--c-700);
}

/* ── Page Layouts ── */
.page-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2rem;
  padding: 2rem 1.5rem;
  background: var(--c-50);
}
.page-auth__logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-800);
  letter-spacing: -.03em;
}
.page-auth__tagline {
  font-size: .9375rem;
  color: var(--c-500);
  text-align: center;
  max-width: 320px;
  line-height: 1.5;
}
.page-auth__card {
  width: 100%;
  max-width: 380px;
}

.page-main {
  padding: 2.5rem 0 4rem;
}

/* ── Bot Config Card ── */
.bot-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--c-200);
  border-radius: var(--radius-md);
  background: var(--c-50);
  transition: border-color var(--transition);
}
.bot-card:hover { border-color: var(--c-300); }
.bot-card__icon {
  width: 40px; height: 40px;
  background: var(--c-800);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bot-card__info { flex: 1; min-width: 0; }
.bot-card__name { font-weight: 600; color: var(--c-800); font-size: .9375rem; }
.bot-card__id { font-size: .75rem; color: var(--c-400); font-family: monospace; }

/* ── Code Block (SDK snippet) ── */
.code-block {
  background: var(--c-800);
  color: var(--c-200);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  font-size: .8125rem;
  line-height: 1.65;
  overflow-x: auto;
  position: relative;
}
.code-block .kw  { color: var(--c-400); }
.code-block .str { color: var(--c-300); }
.code-block__copy {
  position: absolute;
  top: .75rem; right: .75rem;
  padding: .3rem .65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-600);
  background: transparent;
  color: var(--c-400);
  font-size: .75rem;
  cursor: pointer;
  transition: all var(--transition);
}
.code-block__copy:hover {
  border-color: var(--c-400);
  color: var(--c-200);
}

/* ── Chat Widget ── */
#gd-chat-launcher {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--c-800);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-widget);
  z-index: 9998;
  transition: background var(--transition), transform var(--transition);
}
#gd-chat-launcher:hover { background: var(--c-700); transform: scale(1.05); }
#gd-chat-launcher svg { color: var(--c-50); }

#gd-chat-window {
  position: fixed;
  bottom: 88px; right: 24px;
  width: 360px;
  max-height: 520px;
  display: flex; flex-direction: column;
  background: var(--c-50);
  border: 1px solid var(--c-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-widget);
  z-index: 9999;
  overflow: hidden;
  transform-origin: bottom right;
  transition: opacity .2s ease, transform .2s ease;
}
#gd-chat-window.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(.92) translateY(8px);
}

.chat-header {
  background: var(--c-800);
  color: var(--c-50);
  padding: 1rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header__title {
  font-weight: 600;
  font-size: .9375rem;
  display: flex; align-items: center; gap: .5rem;
}
.chat-header__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--c-400);
}
.chat-header__close {
  background: none; border: none; color: var(--c-400);
  cursor: pointer; padding: .25rem; border-radius: 4px;
  display: flex; align-items: center;
  transition: color var(--transition);
}
.chat-header__close:hover { color: var(--c-50); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .625rem;
}
.chat-msg {
  max-width: 85%;
  padding: .625rem .875rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  line-height: 1.5;
  word-break: break-word;
}
.chat-msg--user {
  align-self: flex-end;
  background: var(--c-800);
  color: var(--c-50);
  border-radius: var(--radius-md) var(--radius-md) 2px var(--radius-md);
}
.chat-msg--bot {
  align-self: flex-start;
  background: var(--c-100);
  color: var(--c-800);
  border: 1px solid var(--c-200);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 2px;
}
.chat-msg--typing {
  align-self: flex-start;
  background: var(--c-100);
  border: 1px solid var(--c-200);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 2px;
  padding: .625rem .875rem;
}
.typing-dots { display: flex; gap: 4px; }
.typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--c-400);
  animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

.chat-footer {
  padding: .875rem;
  border-top: 1px solid var(--c-200);
  display: flex; gap: .5rem; align-items: flex-end;
}
.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--c-300);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .875rem;
  font-family: inherit;
  background: var(--c-50);
  color: var(--c-800);
  outline: none;
  max-height: 100px;
  min-height: 36px;
  line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.chat-input::placeholder { color: var(--c-400); }
.chat-input:focus {
  border-color: var(--c-700);
  box-shadow: 0 0 0 3px rgba(52,58,64,.08);
}
.chat-send {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--c-800);
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition);
}
.chat-send:hover { background: var(--c-700); }
.chat-send:disabled { background: var(--c-200); cursor: not-allowed; }
.chat-send svg { color: var(--c-50); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-400); }

/* ── Utility ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Form inputs full width ── */
.form-input,
.form-textarea {
  width: 100%;
  padding: .625rem .875rem;
  border: 1px solid var(--c-200);
  border-radius: var(--radius-sm);
  background: var(--c-50);
  color: var(--c-800);
  font-size: .9375rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--c-400); }
.form-input:focus,
.form-textarea:focus {
  border-color: var(--c-700);
  box-shadow: 0 0 0 3px rgba(52,58,64,.08);
}
.form-input:disabled {
  background: var(--c-100);
  color: var(--c-400);
  cursor: not-allowed;
}
.form-textarea {
  resize: vertical;
  min-height: 240px;
  line-height: 1.6;
}

/* ── Alert variants ── */
.alert--success {
  background: var(--c-100);
  border-color: var(--c-300);
  color: var(--c-800);
}

/* ── Steps: compactar con 5 ítems ── */
.steps .step span {
  font-size: .75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .steps .step span { display: none; }
  .steps .step::after { margin: 0 .375rem; }
}

@media (max-width: 600px) {
  .container { padding: 0 1rem; }
  .card { padding: 1.25rem; }
  #gd-chat-window {
    width: calc(100vw - 16px);
    right: 8px; bottom: 80px;
  }
  .steps { flex-wrap: wrap; gap: .5rem; }
  .step::after { display: none; }
}
