/* ============================================================
   EVA X — LAYOUT
   App structure, navigation, screens
   ============================================================ */

/* ── Global Layout ───────────────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
}

* {
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
}

body.modal-open {
  overflow: auto !important;
}

/* ── App Shell ───────────────────────────────────────────── */
#app,
.app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}

.main-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Screens ─────────────────────────────────────────────── */
.scr {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: var(--nav-h);
  -webkit-overflow-scrolling: touch;
}

.scr.on {
  display: flex;
  animation: screen-in 0.28s cubic-bezier(0.16,1,0.3,1) both;
}

.explorar,
.charlas,
.generador,
.perfil,
#s-explore,
#s-chats,
#s-create,
#s-profile,
#s-notes {
  overflow-y: auto;
  max-height: 100%;
}

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--hdr-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-4);
  background: rgba(15,15,26,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.app-header-logo {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ── Bottom Navigation ───────────────────────────────────── */
#nav {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: var(--nav-h);
  background: rgba(15,15,26,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.ni {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--sp-2) 0;
  cursor: pointer;
  transition: var(--ease);
  color: var(--tx-4);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.ni:active { transform: scale(0.9); }

.ni svg { width: 22px; height: 22px; stroke-width: 1.75; transition: var(--ease); }
.ni span { font-size: 0.625rem; font-weight: 500; transition: var(--ease); }

.ni.on { color: var(--accent-2); }
.ni.on svg { stroke-width: 2.25; }

.ni.on::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 2px;
  background: var(--accent-grad);
  border-radius: 0 0 var(--r-full) var(--r-full);
  animation: nav-line-in 0.25s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* ── Grid ────────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

/* ── Explore Section ─────────────────────────────────────── */
.explore-header {
  padding: var(--sp-4) var(--sp-4) 0;
}

.pill-row {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.pill-row::-webkit-scrollbar { display: none; }

.pill {
  flex-shrink: 0;
  padding: 6px var(--sp-4);
  background: var(--bg-3);
  color: var(--tx-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-full);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--ease);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.pill:hover { border-color: var(--border); color: var(--tx); }
.pill.on { background: var(--accent-dim); color: var(--accent-2); border-color: rgba(139,92,246,0.35); }

.chars-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
  padding: 0 var(--sp-3) var(--sp-4);
}

/* ── Chat View ───────────────────────────────────────────── */
.chatview {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  animation: screen-in 0.28s cubic-bezier(0.16,1,0.3,1) both;
}

.chat-header {
  height: var(--hdr-h);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  background: rgba(15,15,26,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top);
}

.chat-header .back-btn {
  color: var(--tx-3);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-2);
  margin-left: -var(--sp-2);
  border-radius: var(--r-md);
  transition: var(--ease);
}
.chat-header .back-btn:hover { color: var(--tx); background: var(--bg-3); }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  -webkit-overflow-scrolling: touch;
}

.chat-input-bar {
  padding: var(--sp-3) var(--sp-4);
  padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom));
  background: var(--bg-2);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  flex-shrink: 0;
}

.chat-input-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-2) var(--sp-3);
  transition: var(--ease);
  gap: var(--sp-2);
}

.chat-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.chat-input-wrap textarea {
  flex: 1;
  background: none;
  border: none;
  padding: 0;
  min-height: 24px;
  max-height: 160px;
  resize: none;
  font-size: 0.9375rem;
  color: var(--tx);
  outline: none;
  box-shadow: none;
  line-height: 1.5;
}

.chat-input-actions {
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

/* ── Send Button ─────────────────────────────────────────── */
.send-btn {
  width: 40px; height: 40px;
  border-radius: var(--r-lg);
  background: var(--accent-grad);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--ease-out);
  box-shadow: var(--shadow-accent);
}

.send-btn:hover { filter: brightness(1.1); transform: scale(1.05); }
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Profile Screen ──────────────────────────────────────── */
.profile-hero {
  padding: var(--sp-6) var(--sp-4) var(--sp-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
}

.profile-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--tx);
  text-align: center;
}

.profile-bio {
  font-size: 0.875rem;
  color: var(--tx-3);
  text-align: center;
  line-height: 1.5;
  max-width: 280px;
}

.profile-stats {
  display: flex;
  gap: var(--sp-6);
  padding: var(--sp-4);
  background: var(--bg-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-xl);
  width: 100%;
}

.profile-stat {
  flex: 1;
  text-align: center;
  cursor: pointer;
  transition: var(--ease);
}
.profile-stat:hover .profile-stat-val { color: var(--accent-2); }
.profile-stat-val { font-size: 1.25rem; font-weight: 700; color: var(--tx); line-height: 1; }
.profile-stat-lbl { font-size: 0.6875rem; color: var(--tx-3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

.settings-group {
  margin: 0 var(--sp-4) var(--sp-4);
}

.settings-group-title {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--tx-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 var(--sp-2) var(--sp-2);
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-3);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  transition: var(--ease);
}

.settings-item:first-of-type { border-radius: var(--r-lg) var(--r-lg) 0 0; }
.settings-item:last-of-type  { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.settings-item:not(:last-of-type) { border-bottom: none; }
.settings-item:hover { background: var(--bg-4); }

.settings-item-left { display: flex; align-items: center; gap: var(--sp-3); }
.settings-item-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tx-3);
}

.settings-item-label { font-size: 0.9375rem; font-weight: 500; color: var(--tx); }
.settings-item-value { font-size: 0.8125rem; color: var(--tx-3); }
.settings-item-arrow { color: var(--tx-4); width: 16px; height: 16px; }

/* ── Wizard / Create ─────────────────────────────────────── */
.wizard-wrap {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.wizard-progress {
  display: flex;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
}

.wiz-step {
  flex: 1;
  height: 3px;
  background: var(--bg-4);
  border-radius: var(--r-full);
  transition: var(--ease);
}
.wiz-step.done { background: var(--accent-grad); }
.wiz-step.active { background: var(--accent); }

.wizard-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  padding: var(--sp-4) var(--sp-4) 0;
}

.wiz-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--tx-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-2);
}

.wiz-opts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.wiz-opt {
  padding: 8px var(--sp-4);
  background: var(--bg-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-full);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--tx-2);
  cursor: pointer;
  transition: var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.wiz-opt:hover { border-color: var(--border); color: var(--tx); }
.wiz-opt.on { background: var(--accent-dim); color: var(--accent-2); border-color: rgba(139,92,246,0.35); }
