/* ============================================================
   Gemini Chat · estilos
   ============================================================ */

:root {
  --bg: #0b0d12;
  --bg-soft: #10131b;
  --panel: #12161f;
  --panel-2: #171c28;
  --border: #232a3a;
  --border-strong: #2f394d;
  --text: #e9edf6;
  --muted: #8b94aa;
  --accent: #5b8cff;
  --accent-2: #a78bfa;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --font: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

/* El atributo hidden debe ganar a cualquier display de las clases. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(91, 140, 255, 0.16), transparent 60%),
    radial-gradient(800px 500px at 85% 0%, rgba(167, 139, 250, 0.12), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
}

kbd {
  font-family: var(--font);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
}

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px rgba(91, 140, 255, 0.35);
}

.brand__text {
  min-width: 0;
}

.brand__text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand__text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

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

.select {
  appearance: none;
  max-width: 220px;
  padding: 9px 34px 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b94aa' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  font-size: 13px;
  text-overflow: ellipsis;
  transition: border-color 0.15s, background-color 0.15s;
}

.select:hover,
.select:focus {
  border-color: var(--border-strong);
  outline: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--panel-2);
}

/* ---------- Chat ---------- */

.chat {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 4px 8px;
  scrollbar-width: thin;
  scrollbar-color: #2a3244 transparent;
}

.chat::-webkit-scrollbar {
  width: 8px;
}

.chat::-webkit-scrollbar-thumb {
  background: #2a3244;
  border-radius: 99px;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(91, 140, 255, 0.35);
  background: var(--accent-soft);
}

.banner__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.banner__text strong {
  font-weight: 600;
}

.banner__text span {
  color: var(--muted);
}

/* ---------- Empty state ---------- */

.empty {
  max-width: 620px;
  margin: 7vh auto 0;
  text-align: center;
  animation: fade-up 0.35s ease both;
}

.empty[hidden] {
  display: none;
}

.empty__logo {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 18px;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 18px 44px rgba(91, 140, 255, 0.3);
}

.empty h2 {
  margin: 0 0 8px;
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.empty > p {
  margin: 0 auto;
  max-width: 440px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 26px;
}

.chip {
  padding: 9px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 12.5px;
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}

.chip:hover {
  border-color: var(--border-strong);
  background: var(--panel-2);
  transform: translateY(-1px);
}

.empty__hint {
  margin-top: 22px !important;
  font-size: 12px !important;
  color: var(--muted);
}

.empty__hint.is-ok {
  color: #6ee7b7;
}

/* ---------- Mensajes ---------- */

.messages {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding-bottom: 12px;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fade-up 0.25s ease both;
}

.msg--user {
  align-items: flex-end;
}

.msg--model {
  align-items: flex-start;
}

.msg__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  font-size: 11.5px;
  color: var(--muted);
}

.msg__avatar {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.msg__name {
  font-weight: 600;
  color: #b9c1d4;
}

.msg__copy {
  margin-left: 6px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}

.msg:hover .msg__copy,
.msg__copy:focus-visible {
  opacity: 1;
}

.msg__copy:hover {
  color: var(--text);
  border-color: var(--border);
}

.msg__bubble {
  max-width: min(720px, 92%);
  padding: 13px 17px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.msg--user .msg__bubble {
  border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, #3d6bef, #6b5ce7);
  color: #fff;
  box-shadow: 0 10px 26px rgba(61, 107, 239, 0.25);
}

.msg--model .msg__bubble {
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  background: var(--panel);
}

.msg--error .msg__bubble {
  border: 1px solid rgba(255, 107, 107, 0.35);
  background: var(--danger-soft);
  color: #ffb3b3;
}

.msg__body {
  white-space: normal;
}

.msg__body > *:first-child {
  margin-top: 0;
}

.msg__body > *:last-child {
  margin-bottom: 0;
}

.msg__body p {
  margin: 0 0 12px;
}

.msg__body h3,
.msg__body h2,
.msg__body h1 {
  margin: 18px 0 8px;
  font-size: 15.5px;
  font-weight: 650;
  line-height: 1.35;
}

.msg__body ul,
.msg__body ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.msg__body li {
  margin-bottom: 5px;
}

.msg__body code {
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  font-family: var(--mono);
  font-size: 12.6px;
}

.msg__body pre {
  margin: 12px 0;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #0a0c11;
  overflow-x: auto;
}

.msg__body pre code {
  padding: 0;
  background: none;
  font-size: 12.6px;
  line-height: 1.6;
  white-space: pre;
}

.msg__body a {
  text-underline-offset: 2px;
}

.msg--user .msg__body code {
  background: rgba(0, 0, 0, 0.22);
}

.retry-btn {
  margin-top: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 107, 107, 0.4);
  background: transparent;
  color: #ffb3b3;
  font-size: 12.5px;
}

.retry-btn:hover {
  background: rgba(255, 107, 107, 0.14);
}

.typing {
  display: inline-flex;
  gap: 5px;
  padding: 4px 2px;
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}

.typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing i:nth-child(3) {
  animation-delay: 0.3s;
}

/* ---------- Composer ---------- */

.composer-wrap {
  padding: 10px 0 16px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 10px 10px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--panel);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer:focus-within {
  border-color: rgba(91, 140, 255, 0.6);
  box-shadow: 0 0 0 4px rgba(91, 140, 255, 0.1);
}

.composer textarea {
  flex: 1;
  max-height: 200px;
  min-height: 24px;
  padding: 5px 0;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 14.5px;
  line-height: 1.55;
}

.composer textarea::placeholder {
  color: #6b748a;
}

.composer__actions {
  display: flex;
  gap: 8px;
}

.send-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 11px;
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transition: opacity 0.15s, transform 0.15s;
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.send-btn--stop {
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  color: var(--danger);
}

.hint {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 9px 4px 0;
  font-size: 11px;
  color: #6b748a;
}

.hint__model {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Dialog ---------- */

.dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(4, 6, 10, 0.7);
  backdrop-filter: blur(4px);
}

.dialog__form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
}

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

.dialog__head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.dialog__head .icon-btn {
  width: 32px;
  height: 32px;
  border-color: transparent;
  background: transparent;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: #c3cadb;
}

.field__value {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--accent);
}

.field__hint {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: rgba(91, 140, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.12);
}

.range {
  width: 100%;
  accent-color: var(--accent);
}

.dialog__actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.dialog__note {
  margin: 0;
  font-size: 11px;
  line-height: 1.55;
  color: #6b748a;
}

.status {
  min-height: 14px;
  margin: -6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.status.is-error {
  color: #ff9b9b;
}

.status.is-ok {
  color: #6ee7b7;
}

.btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 550;
  transition: transform 0.15s, background-color 0.15s, border-color 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 20px rgba(91, 140, 255, 0.25);
}

.btn--ghost {
  border-color: var(--border);
  background: var(--panel-2);
  color: var(--text);
}

.btn--ghost:hover {
  border-color: var(--border-strong);
}

.btn--sm {
  padding: 8px 14px;
  font-size: 12.5px;
}

/* ---------- Animaciones ---------- */

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .app {
    padding: 0 12px;
  }

  .brand__text p {
    display: none;
  }

  .select {
    max-width: 140px;
    font-size: 12px;
  }

  .empty {
    margin-top: 4vh;
  }

  .empty > p {
    font-size: 13px;
  }

  .chip {
    font-size: 12px;
  }

  .msg__bubble {
    max-width: 100%;
  }

  .hint__model,
  .hint span:first-child {
    display: none;
  }

  .hint {
    justify-content: center;
  }
}
