/* Azull · Brand Guidelines v3.0 — Montserrat (texto) + Instrument Serif (titulares, sustituto de Seriously Nostalgic) */
@font-face { font-family: "Montserrat"; src: url(/fonts/Montserrat-Light.ttf) format("truetype"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url(/fonts/Montserrat-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url(/fonts/Montserrat-SemiBold.ttf) format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url(/fonts/Montserrat-Bold.ttf) format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Azull Serif"; src: url(/fonts/InstrumentSerif-Regular.ttf) format("truetype"); font-style: normal; font-display: swap; }
@font-face { font-family: "Azull Serif"; src: url(/fonts/InstrumentSerif-Italic.ttf) format("truetype"); font-style: italic; font-display: swap; }

:root {
  /* Paleta del brandbook */
  --azure: #00A1E4; --azure-dark: #0089C2; --azure-soft: #E5F5FC;
  --sun: #F0A91F; --sand: #EED5C0; --pool: #B5D9DF; --butter: #F3D6A1; --cocktail: #FDDED6; --deep: #3C59A8;
  --ink: #1A1A1A; --muted: #6B6B6B; --line: #ECE7E1; --bg: #FFFFFF; --soft: #FBF8F5;
  --radius: 18px; --radius-sm: 12px;
  --serif: "Azull Serif", Georgia, serif;
  --sans: "Montserrat", "Segoe UI", system-ui, sans-serif;
  font-family: var(--sans); font-weight: 300; color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--bg); }
button { font: inherit; cursor: pointer; }
a { color: var(--azure); }
strong, b { font-weight: 600; }
.serif { font-family: var(--serif); font-weight: 400; }
.eyebrow { font-family: var(--sans); font-weight: 700; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--azure); }
.muted { color: var(--muted); }

/* Cabecera */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px clamp(16px, 3vw, 32px);
  background: var(--bg); border-bottom: 1px solid var(--line); padding-top: max(12px, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand img { width: 42px; height: 42px; flex: none; }
.brand .title { font-family: var(--serif); font-size: 26px; line-height: 1; white-space: nowrap; }
.brand .title em { font-style: italic; }
.brand .sub { display: block; margin-top: 4px; }
.actions-top { display: flex; align-items: center; gap: 8px; }
.pill-ghost { background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: 13px; font-weight: 600; text-decoration: none; }
.pill-ghost:hover { border-color: var(--azure); color: var(--azure); }
#toggle-side { display: none; }

/* Estructura */
.layout { flex: 1; display: grid; grid-template-columns: 330px 1fr; min-height: 0; }
.side { overflow-y: auto; padding: 22px 18px; display: flex; flex-direction: column; gap: 16px; background: var(--soft); border-right: 1px solid var(--line); }
.card { background: var(--bg); border-radius: var(--radius); padding: 18px 18px 16px; }
.card h2 { margin: 0 0 12px; }
.card.sand { background: var(--sand); }
.card.pool { background: var(--pool); }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 0; font-size: 13.5px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 600; text-align: right; }
.warn { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--butter); font-size: 12.5px; line-height: 1.45; }
.news { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; font-size: 13px; }
.news li { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg); }
.news li.hot { background: var(--butter); }
.news .when { color: var(--muted); font-size: 11.5px; }
.news .what { margin-top: 3px; line-height: 1.4; }
.side-foot { margin-top: auto; font-size: 11px; color: var(--muted); text-align: center; padding-top: 8px; }

/* Chat */
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.messages { flex: 1; overflow-y: auto; padding: 28px clamp(16px, 5vw, 64px); display: flex; flex-direction: column; gap: 18px; }
.welcome { max-width: 760px; margin: 7vh auto 0; text-align: center; }
.welcome h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 6vw, 64px); line-height: 1.02; margin: 12px 0 14px; }
.welcome h1 em { font-style: italic; color: var(--azure); }
.welcome p { color: var(--muted); line-height: 1.6; font-size: 15px; max-width: 560px; margin: 0 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 26px; }
.chip { background: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; color: var(--ink); font-size: 13.5px; font-weight: 400; text-align: left; }
.chip:hover { background: var(--azure-soft); border-color: var(--azure); }

.msg { max-width: 860px; width: 100%; font-size: 15px; }
.msg.user { align-self: flex-end; max-width: 620px; width: auto; background: var(--azure); color: #fff; font-weight: 400;
  padding: 12px 18px; border-radius: var(--radius) var(--radius) 6px var(--radius); white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius) var(--radius) var(--radius) 6px; padding: 18px 20px; line-height: 1.65; }
.msg.bot p { margin: 0 0 10px; }
.msg.bot p:last-child { margin-bottom: 0; }
.msg.bot ul { margin: 4px 0 12px; padding-left: 0; list-style: none; }
.msg.bot li { position: relative; padding-left: 18px; margin: 4px 0; }
.msg.bot li::before { content: ""; position: absolute; left: 2px; top: .72em; width: 7px; height: 7px; border-radius: 50%; background: var(--azure); }
.msg.bot .error { background: var(--cocktail); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13.5px; }
.typing { color: var(--muted); font-style: italic; }
.typing::after { content: " …"; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* PDFs adjuntos */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-top: 16px; }
.file { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius); background: var(--pool); }
.file .ico { flex: none; width: 40px; height: 48px; border-radius: 10px; background: var(--azure); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; display: grid; place-items: center; }
.file .ico.x { background: var(--deep); }
.file .meta { min-width: 0; flex: 1; }
.file .tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .16em; color: var(--ink); opacity: .7; }
.file .name { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; margin-top: 2px; }
.file .sub { font-size: 12px; color: var(--ink); opacity: .7; }
.file .actions { display: flex; gap: 8px; margin-top: 10px; }
.file .actions a { font-size: 12.5px; font-weight: 600; text-decoration: none; padding: 7px 14px; border-radius: 999px; background: var(--bg); color: var(--ink); }
.file .actions a.main { background: var(--azure); color: #fff; }
.sources { margin-top: 14px; font-size: 12px; color: var(--muted); }
.sources summary { cursor: pointer; font-weight: 600; }

/* Clientes y propiedades de Odoo */
.crm-head { margin: 16px 0 8px; }
.crm { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.crm-item { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--sand); font-size: 13px; line-height: 1.45; min-width: 0; }
.crm-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.crm-top strong { overflow-wrap: anywhere; }
.crm-item .stage { flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--deep); }
.crm-sub { margin-top: 3px; overflow-wrap: anywhere; }

/* Links de material añadidos desde el chat */
.link-card { margin-top: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--pool); display: flex; flex-direction: column; gap: 8px; font-size: 13px; max-width: 520px; }
.link-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; }
.link-card input { padding: 10px 14px; border-radius: 999px; border: 0; background: var(--bg); font: 400 15px var(--sans); color: var(--ink); }
.link-card input:focus { outline: 2px solid var(--azure); }
.link-card .primary { align-self: flex-start; padding: 10px 20px; font-size: 14px; }
.links li { background: var(--soft); }
.links li.listo { background: var(--azure-soft); }
.links li.error { background: var(--cocktail); }
.links li.descargando, .links li.pendiente { background: var(--butter); }

/* Opciones con foto */
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.opt { border-radius: var(--radius); overflow: hidden; background: var(--soft); border: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.opt img, .opt-nofoto { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--pool); }
.opt-nofoto { display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; padding: 14px; background: linear-gradient(150deg, var(--cocktail) 0%, var(--butter) 45%, var(--pool) 100%); }
.opt-nofoto span { font-family: var(--serif); font-size: 26px; line-height: 1.05; color: var(--ink); }
.opt-nofoto small { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--deep); }
.opt-body { padding: 12px 14px 14px; font-size: 13px; line-height: 1.45; }
.opt-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.opt-links a { font-size: 12px; font-weight: 600; text-decoration: none; padding: 6px 12px; border-radius: 999px; background: var(--azure); color: #fff; }

.opt.clic { cursor: pointer; transition: border-color .15s, transform .15s; }
.opt.clic:hover { border-color: var(--azure); transform: translateY(-2px); }
.opt-zona { margin-top: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--azure); }
.opt-origen { margin-top: 8px; font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.opt-grupo { margin: 14px 0 8px; font-family: var(--serif); font-size: 22px; }
.sources li { margin: 6px 0; line-height: 1.5; }
.sources a { font-weight: 600; }

/* Lista de links literales para copiar */
.links-lista { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.links-top { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg); }
.links-lista pre { margin: 0; padding: 12px 14px; white-space: pre-wrap; word-break: break-all; font: 400 13px/1.6 ui-monospace, Consolas, monospace; user-select: text; }
.copiar { background: var(--azure); color: #fff; border: 0; border-radius: 999px; padding: 6px 14px; font-size: 12.5px; font-weight: 600; }

/* Caja de pregunta */
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 14px clamp(16px, 5vw, 64px); padding-bottom: max(16px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.composer textarea { flex: 1; resize: none; max-height: 180px; padding: 14px 18px; border-radius: 26px; border: 1px solid var(--line);
  background: var(--soft); color: var(--ink); font: 400 16px/1.4 var(--sans); }
.composer textarea:focus { outline: 2px solid var(--azure); outline-offset: 0; border-color: transparent; background: var(--bg); }
.primary { background: var(--azure); color: #fff; border: 0; border-radius: 999px; padding: 14px 24px; font-weight: 600; font-size: 15px; }
.primary:hover { background: var(--azure-dark); }
.primary:disabled { opacity: .5; cursor: wait; }
.foot { text-align: center; font-size: 11px; color: var(--muted); padding: 0 16px 10px; background: var(--bg); }

/* Pestañas: una conversación por cliente o tema */
.tabs { display: flex; align-items: center; gap: 8px; padding: 10px clamp(16px, 5vw, 64px); border-bottom: 1px solid var(--line); background: var(--bg); }
.tab-list { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.tab { flex: none; display: flex; align-items: center; max-width: 240px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); }
.tab.on { background: var(--azure); border-color: var(--azure); }
.tab.on .tab-name, .tab.on .tab-x { color: #fff; }
.tab.draft { border-style: dashed; }
.tab-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; border: 0; padding: 8px 4px 8px 14px; font-size: 13px; font-weight: 600; color: var(--ink); text-align: left; }
.tab.draft .tab-name { padding-right: 14px; }
.tab-x { background: none; border: 0; padding: 4px 12px 4px 6px; font-size: 16px; line-height: 1; color: var(--muted); }
.tab-x:hover { color: var(--azure); }
.tab.on .tab-x:hover { color: var(--butter); }
.tab-new { flex: none; background: var(--azure-soft); color: var(--azure); border: 1px solid transparent; border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 700; }
.tab-new:hover { border-color: var(--azure); }

.tab-edit { background: none; border: 0; padding: 4px 2px 4px 6px; font-size: 13px; line-height: 1; color: #fff; opacity: .85; }
.tab-edit:hover { opacity: 1; color: var(--butter); }
.tab-tool { flex: none; background: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 6px 11px; font-size: 13px; }
.tab-tool[aria-expanded="true"], .tab-tool:hover { border-color: var(--azure); background: var(--azure-soft); }
.tab-search { display: flex; align-items: center; gap: 10px; padding: 8px clamp(16px, 5vw, 64px); border-bottom: 1px solid var(--line); background: var(--azure-soft); }
.tab-search[hidden] { display: none; }
.tab-search input { flex: 1; min-width: 0; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); font: 400 15px var(--sans); color: var(--ink); }
.tab-search input:focus { outline: 2px solid var(--azure); border-color: transparent; }
.tab-search span { font-size: 12px; white-space: nowrap; }
.msg[hidden] { display: none; }
.msg.hit.user { box-shadow: 0 0 0 3px var(--butter); }
.hist-edit { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 6px 2px 6px 6px; }
.hist-edit:hover { color: var(--azure); }

/* Historial */
.search { width: 100%; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--soft); font: 400 14px var(--sans); color: var(--ink); margin-bottom: 10px; }
.search:focus { outline: 2px solid var(--azure); border-color: transparent; background: var(--bg); }
.hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 42vh; overflow-y: auto; font-size: 13px; }
.hist li { display: flex; align-items: center; border-radius: var(--radius-sm); background: var(--soft); }
.hist li.on { background: var(--azure-soft); }
.hist-open { flex: 1; min-width: 0; background: none; border: 0; text-align: left; padding: 9px 4px 9px 12px; color: var(--ink); }
.hist-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.hist-del { background: none; border: 0; color: var(--muted); font-size: 16px; padding: 6px 12px; }
.hist-del:hover { color: #C0392B; }

/* Ventana "nueva conversación" */
.dlg { border: 0; border-radius: 24px; padding: 28px; width: min(440px, calc(100% - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.dlg::backdrop { background: rgba(26,26,26,.35); }
.dlg form { display: flex; flex-direction: column; gap: 12px; }
.dlg h3 { font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.05; margin: 0; }
.dlg h3 em { font-style: italic; color: var(--azure); }
.dlg input { padding: 14px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--soft); font: 400 16px var(--sans); color: var(--ink); }
.dlg input:focus { outline: 2px solid var(--azure); border-color: transparent; background: var(--bg); }
.dlg p { margin: 0; font-size: 12.5px; line-height: 1.5; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.dlg-actions .primary { padding: 10px 20px; font-size: 14px; }

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: none; border-right: 0; border-bottom: 1px solid var(--line); max-height: 60vh; }
  .side.open { display: flex; }
  #toggle-side { display: inline-block; }
  .brand img { width: 36px; height: 36px; }
  .brand .title { font-size: 22px; }
  .brand .sub, .brand .long { display: none; }
  .brand .title em { font-size: 24px; }
  .welcome { margin-top: 2vh; }
  .chips { flex-direction: column; align-items: stretch; }
  .msg.bot { padding: 14px 16px; }
  .primary { padding: 14px 18px; }
  .foot { display: none; }
  .tabs { padding: 8px 12px; }
  .tab { max-width: 170px; }
}

/* Pantalla de acceso: degradado del brandbook (peach → butter → pool water) */
body.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(150deg, var(--cocktail) 0%, var(--butter) 45%, var(--pool) 100%); }
.login-card { width: min(420px, 100%); background: var(--bg); border-radius: 28px; padding: 36px 30px 30px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.login-card img { width: 118px; height: 118px; margin: 0 auto 6px; }
.login-card h1 { font-family: var(--serif); font-weight: 400; font-size: 40px; line-height: 1.05; margin: 4px 0 0; }
.login-card h1 em { font-style: italic; color: var(--azure); }
.login-card p { margin: 0; }
.login-card label { text-align: left; font-size: 12px; font-weight: 600; margin-top: 12px; }
.login-card input { padding: 14px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--soft); color: var(--ink); font: 400 16px var(--sans); }
.login-card input:focus { outline: 2px solid var(--azure); border-color: transparent; background: var(--bg); }
.login-card .primary { margin-top: 8px; }
.login-card .warn { margin: 4px 0 0; }
.login-foot { font-size: 11px; color: var(--muted); margin-top: 10px; }
