/* ══════════════════════════════════════════
   CatolicosGPT V10 — CSS Completo
   Mobile-first, minimalista, como Magisterium
══════════════════════════════════════════ */

:root {
  --brown:   #5C3D1E;
  --brown2:  #7A5230;
  --ocre:    #C9923A;
  --ocre-bg: rgba(201,146,58,.08);
  --red:     #8B1A1A;
  --green:   #1E6B3A;
  --purple:  #4A2080;
  --bg:      #FAF7F0;
  --bg2:     #F3EDE0;
  --bg3:     #EDE5D4;
  --border:  #E0D5C2;
  --border2: #C9B89A;
  --ink:     #18100A;
  --ink3:    #4A3728;
  --ink4:    #9B8A77;
  --shadow:  rgba(0,0,0,.06);
  --sb-w:    260px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); }

/* ── App layout ── */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sb {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sb-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  z-index: 200;
  overflow: hidden;
}
.sb.open { transform: translateX(0); }

#sb-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 199;
}
#sb-overlay.active { display: block; }

.sb-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-brand { display: flex; align-items: center; gap: 8px; }
.sb-name {
  font-family: 'Playfair Display', serif;
  font-size: 15px; font-weight: 700; color: var(--brown);
}
.sb-name em { color: var(--ocre); font-style: normal; }
.sb-x {
  width: 26px; height: 26px; border-radius: 6px;
  border: 1px solid var(--border); background: transparent;
  cursor: pointer; color: var(--ink4);
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.sb-x:hover { background: var(--bg3); color: var(--brown); }

.sb-new {
  display: flex; align-items: center; gap: 7px;
  margin: 10px; padding: 9px 12px;
  background: var(--brown); color: #fff;
  border: none; border-radius: 8px;
  font-family: 'Inter', sans-serif; font-size: 13px;
  cursor: pointer; transition: background .12s; flex-shrink: 0;
}
.sb-new:hover { background: var(--brown2); }

.sb-scroll {
  flex: 1; overflow-y: auto; padding: 4px 4px 8px;
}
.sb-scroll::-webkit-scrollbar { width: 3px; }
.sb-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.sb-label {
  font-family: 'Inter', sans-serif; font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: var(--ink4);
  padding: 10px 10px 4px;
}

.sb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  margin: 1px 4px; transition: background .1s;
}
.sb-row:hover { background: var(--bg3); }
.sb-row svg { flex-shrink: 0; }
.sb-row-title {
  font-family: 'Inter', sans-serif; font-size: 13px; color: var(--ink); font-weight: 500;
}
.sb-row-sub {
  font-family: 'Lora', serif; font-size: 11px; color: var(--ink4); font-style: italic;
}

.history-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 13px; color: var(--ink);
}
.history-item:hover { background: var(--bg3); }
.history-item .hi-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hi-time { font-size: 10px; color: var(--ink4); flex-shrink: 0; }

.sb-donate {
  margin-top: auto; display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-top: 1px solid var(--border);
  text-decoration: none; flex-shrink: 0; transition: background .1s;
}
.sb-donate:hover { background: var(--bg3); }
.sb-donate span {
  font-family: 'Lora', serif; font-size: 12px; color: var(--ink4); font-style: italic;
}

/* ── Main ── */
.main {
  flex: 1;
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar ── */
.topbar {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; height: 48px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.tb-left { display: flex; align-items: center; gap: 10px; }
.menu-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
}
.menu-btn span {
  display: block; width: 16px; height: 1.5px;
  background: var(--brown); border-radius: 2px;
}
.tb-brand { display: flex; align-items: center; gap: 8px; }
.tb-name {
  font-family: 'Playfair Display', serif;
  font-size: 15px; font-weight: 700; color: var(--brown);
}
.tb-name em { color: var(--ocre); font-style: normal; }
.tb-new-btn {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  color: var(--brown); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.tb-new-btn:hover { background: var(--bg3); }

/* ── Content ── */
.content {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-height: 0;
}

/* ── Welcome — centrado vertical ── */
.welcome {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 20px; overflow: hidden;
}
.wlc-wrap {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  max-width: 520px; width: 100%;
}
.wlc-icon { width: 48px; height: 48px; margin-bottom: 20px; animation: fadeIn .4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
.wlc-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(20px, 3.5vw, 28px);
  font-weight: 700; color: var(--brown);
  line-height: 1.4; margin-bottom: 10px; letter-spacing: -.02em;
}
.wlc-title em { color: var(--ocre); font-style: italic; }
.wlc-hint {
  font-family: 'Lora', serif; font-size: 14px;
  color: var(--ink4); font-style: italic;
}

/* ── Chat ── */
.chat-area {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 16px 0;
}
.chat-inner { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.msg-row { display: flex; gap: 10px; margin-bottom: 20px; }
.bot-row { align-items: flex-start; }
.user-row { flex-direction: row-reverse; }
.av {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.av-user {
  background: var(--brown); color: #fff;
  font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 700;
}
.bubble {
  max-width: calc(100% - 48px); padding: 12px 16px;
  border-radius: 14px; line-height: 1.8;
  font-family: 'Lora', serif; font-size: 15px; color: var(--ink);
}
.bubble-bot {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
}
.bubble-user {
  background: var(--brown); color: #fff;
  border-radius: 14px 4px 14px 14px;
  font-family: 'Inter', sans-serif; font-size: 14px;
}
.bubble h2 { font-family: 'Playfair Display', serif; font-size: 17px; color: var(--brown); margin: 14px 0 6px; }
.bubble h3 { font-family: 'Playfair Display', serif; font-size: 15px; color: var(--brown2); margin: 12px 0 4px; }
.bubble ul { padding-left: 20px; margin: 8px 0; }
.bubble li { margin-bottom: 4px; }
.bubble p { margin-bottom: 10px; }
.bubble strong { font-weight: 600; color: var(--brown2); }

/* Links de citas */
.cita-cic {
  display: inline-flex; align-items: center;
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 600;
  padding: 1px 8px; border-radius: 5px; text-decoration: none; cursor: pointer;
  background: rgba(139,26,26,.07); color: #8B1A1A;
  border: 1px solid rgba(139,26,26,.18); margin: 0 2px;
  transition: background .12s;
}
.cita-cic:hover { background: rgba(139,26,26,.14); }
.cita-biblia {
  display: inline-flex; align-items: center;
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 600;
  padding: 1px 8px; border-radius: 5px; text-decoration: none; cursor: pointer;
  background: rgba(30,107,58,.07); color: #1E6B3A;
  border: 1px solid rgba(30,107,58,.18); margin: 0 2px;
  transition: background .12s;
}
.cita-biblia:hover { background: rgba(30,107,58,.14); }

/* Magisterium badge */
.mag-badge {
  background: rgba(30,80,160,.05); border: 1px solid rgba(30,80,160,.15);
  border-radius: 8px; padding: 8px 12px; margin-bottom: 12px;
  font-family: 'Inter', sans-serif;
}
.mag-badge-title {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: #185FA5; margin-bottom: 5px;
}
.mag-badge-text { font-family: 'Lora', serif; font-size: 13px; color: var(--ink3); line-height: 1.6; }

/* Typing cursor */
.typing-cursor {
  display: inline-block; color: var(--ocre); font-weight: 700;
  animation: blink .7s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* Action row */
.action-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.act-btn {
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 500;
  padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--ink3); cursor: pointer; transition: all .12s;
}
.act-btn:hover { background: var(--bg3); color: var(--brown); border-color: var(--border2); }

/* Sugerencias */
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sug-chip {
  font-family: 'Lora', serif; font-size: 13px; font-style: italic;
  padding: 5px 13px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border2); background: var(--bg2); color: var(--brown);
  transition: all .12s;
}
.sug-chip:hover { background: var(--ocre-bg); border-color: var(--ocre); }

/* Stop button */
.stop-btn {
  position: absolute; right: 52px; bottom: 8px;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--bg2); border: 1px solid var(--border2);
  cursor: pointer; display: none;
  align-items: center; justify-content: center;
}
.stop-btn::before {
  content: ''; width: 10px; height: 10px;
  background: var(--brown); border-radius: 2px;
}

/* ── Vistas (Lecturas, Breviario, Misal) ── */
.main-view {
  flex: 1; flex-direction: column; overflow: hidden;
}
.view-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg2); flex-shrink: 0;
}
.view-back {
  font-family: 'Inter', sans-serif; font-size: 13px; color: var(--brown);
  background: transparent; border: 1px solid var(--border2);
  border-radius: 20px; padding: 5px 12px; cursor: pointer;
  transition: all .12s;
}
.view-back:hover { background: var(--bg3); }
.view-title {
  font-family: 'Playfair Display', serif; font-size: 15px;
  font-weight: 600; color: var(--brown);
}
.view-body {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}
.view-date {
  font-family: 'Inter', sans-serif; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: var(--ocre);
  margin-bottom: 16px;
}
.view-content-area {
  font-family: 'Playfair Display', serif;
  font-size: 15px; line-height: 2; color: var(--ink);
}

/* ── Input ── */
.input-area {
  flex-shrink: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
}
.input-wrap {
  max-width: 760px; margin: 0 auto; position: relative;
}
.cin {
  width: 100%; padding: 13px 50px 13px 16px;
  background: #fff; border: 1.5px solid var(--border2);
  border-radius: 14px; resize: none; outline: none;
  font-family: 'Lora', serif; font-size: 15px; color: var(--ink);
  line-height: 1.5; max-height: 140px;
  box-shadow: 0 1px 6px var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.cin:focus {
  border-color: var(--ocre);
  box-shadow: 0 2px 12px rgba(201,146,58,.15);
}
.cin::placeholder { color: var(--ink4); font-style: italic; }
.send-btn {
  position: absolute; right: 8px; bottom: 8px;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--brown); border: none; cursor: pointer;
  color: #fff; display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.send-btn:hover { background: var(--brown2); }
.send-btn svg { width: 16px; height: 16px; }
.input-hint {
  text-align: center; margin-top: 5px;
  font-family: 'Inter', sans-serif; font-size: 11px; color: var(--ink4);
}

/* ── Modal donar ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 500; display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--bg); border-radius: 16px;
  padding: 28px 24px; max-width: 360px; width: 90%;
  text-align: center; box-shadow: 0 8px 40px rgba(0,0,0,.2);
}
.modal-title {
  font-family: 'Playfair Display', serif; font-size: 20px;
  font-weight: 700; color: var(--brown); margin-bottom: 8px;
}
.modal-sub {
  font-family: 'Lora', serif; font-size: 14px; color: var(--ink4);
  font-style: italic; margin-bottom: 20px; line-height: 1.6;
}
.modal-amounts { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; }
.amount-btn {
  font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 600;
  padding: 9px 18px; border-radius: 8px; cursor: pointer;
  border: 1.5px solid var(--border2); background: var(--bg2); color: var(--brown);
  transition: all .12s;
}
.amount-btn.on { background: var(--brown); color: #fff; border-color: var(--brown); }
.paypal-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px; border-radius: 10px;
  background: #003087; color: #fff; text-decoration: none;
  font-family: 'Inter', sans-serif; font-size: 15px; font-weight: 600;
  margin-bottom: 12px; transition: opacity .12s;
}
.paypal-btn:hover { opacity: .9; }
.modal-close {
  font-family: 'Lora', serif; font-size: 13px; color: var(--ink4);
  background: transparent; border: none; cursor: pointer; text-decoration: underline;
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .sb { width: min(82vw, 300px) !important; }
  .wlc-title { font-size: 21px !important; }
  .bubble { font-size: 14px; }
  .view-body { padding: 14px; }
}
