/* ============================================================
   fase4.css v623 — Chat Premium definitivo
   ============================================================ */

.ch-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 94px);
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface1);
}

/* ── Panel izquierdo ── */
.ch-left { display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface1); overflow: hidden; }
.ch-left-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 14px; border-bottom: 1px solid var(--border); flex: none; }
.ch-title { font-size: 17px; font-weight: 800; color: var(--text); }

.ch-search { padding: 10px 12px; border-bottom: 1px solid var(--border); flex: none; }
.ch-search-inner { display: flex; align-items: center; gap: 8px; background: var(--surface2); border: 1px solid var(--border); border-radius: 99px; padding: 8px 13px; transition: border-color .12s; }
.ch-search-inner:focus-within { border-color: var(--accent); }
.ch-search-inner svg { width: 14px; height: 14px; color: var(--text-2); flex: none; }
.ch-search-inner input { flex: 1; background: none; border: none; outline: none; font-family: var(--font); font-size: 13px; color: var(--text); }

.ch-list { flex: 1; overflow-y: auto; }
.ch-empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 30px 20px; text-align: center; }
.ch-empty-txt { font-size: 13px; color: var(--text-2); }
.ch-err { padding: 12px 16px; font-size: 12px; color: var(--danger); }

/* ── Ítem conversación: SIEMPRE una sola línea, sin wrap ── */
.ch-item { display: flex; align-items: center; gap: 11px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background .1s; -webkit-tap-highlight-color: transparent; }
.ch-item:hover { background: var(--surface2); }
.ch-item-on { background: color-mix(in srgb, var(--accent) 8%, var(--surface1)); border-left: 3px solid var(--accent); }
.ch-av {
  border-radius: 50% !important;
  position: relative !important;
  flex: none !important;
  flex-shrink: 0 !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  aspect-ratio: 1 / 1 !important;
  font-weight: 800 !important;
  color: #fff !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
}
.ch-av::before {
  content: attr(data-ini);
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}
.ch-item-body { flex: 1; min-width: 0; }
.ch-item-r1 { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 3px; }
.ch-item-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fw-800 { font-weight: 800; }
.ch-item-time { font-size: 11px; color: var(--text-2); flex: none; white-space: nowrap; }
.ch-item-r2 { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.ch-item-prev { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ch-badge { background: var(--accent); color: #fff; font-size: 10px; font-weight: 800; min-width: 18px; height: 18px; border-radius: 99px; display: grid; place-items: center; padding: 0 4px; flex: none; }

/* ── Panel derecho ── */
.ch-right { display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
.ch-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text-2); text-align: center; padding: 40px; }
.ch-empty svg { width: 44px; height: 44px; opacity: .12; }
.ch-empty p { font-size: 14px; font-weight: 500; }

/* ── Header ── */
.ch-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface1); flex: none; }
.ch-back-btn { display: none; background: none; border: none; cursor: pointer; color: var(--text-2); padding: 6px; border-radius: 8px; flex: none; align-items: center; justify-content: center; }
.ch-back-btn svg { width: 20px; height: 20px; }
.ch-head-info { flex: 1; min-width: 0; }
.ch-head-name { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-head-status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--success); font-weight: 600; margin-top: 2px; }
.ch-dot { width: 7px; height: 7px; background: var(--success); border-radius: 50%; flex: none; }
.ch-head-actions { display: flex; gap: 6px; }
.ch-wa-active { color: #25D366 !important; }
.ch-wa-active:hover { background: color-mix(in srgb, #25D366 12%, var(--surface2)); }
.icon-btn[disabled] { opacity: .35; cursor: not-allowed; }

/* ── Mensajes ── */
.ch-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.ch-day { display: flex; align-items: center; gap: 12px; margin: 12px 0 8px; }
.ch-day span { font-size: 11px; font-weight: 700; color: var(--text-2); background: var(--surface1); padding: 3px 12px; border-radius: 99px; border: 1px solid var(--border); white-space: nowrap; }
.ch-day::before, .ch-day::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.ch-row-me { display: flex; flex-direction: column; align-items: flex-end; margin-bottom: 4px; }
.ch-bbl-me { display: inline-block; width: fit-content; min-width: 32px; text-align: left; background: var(--accent); color: #fff; padding: 9px 14px; border-radius: 18px 18px 4px 18px; font-size: 14px; font-weight: 500; line-height: 1.5; max-width: 70%; word-break: break-word; }
.ch-row-other { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 4px; max-width: 100%; }
.ch-row-other > div { display: inline-flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: calc(70% - 38px); }
.ch-bbl-other { display: inline-block; width: max-content; min-width: 32px; text-align: left; background: var(--surface1); color: var(--text); padding: 9px 14px; border-radius: 18px 18px 18px 4px; font-size: 14px; font-weight: 500; line-height: 1.5; max-width: 100%; word-break: break-word; border: 1px solid var(--border); }
.ch-t { font-size: 10px; color: var(--text-2); margin-top: 3px; display: block; padding: 0 4px; }

.ch-link { color: inherit; text-decoration: underline; word-break: break-all; }
.ch-bbl-me .ch-link { color: #fff; opacity: .95; }
.ch-bbl-other .ch-link { color: var(--accent); }

/* ── Input ── */
.ch-input-wrap { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface1); flex: none; }
.ch-input { flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: 24px; padding: 10px 17px; font-family: var(--font); font-size: 14px; font-weight: 500; color: var(--text); outline: none; transition: border-color .12s; }
.ch-input:focus { border-color: var(--accent); }
.ch-input::placeholder { color: var(--text-2); font-weight: 400; }
.ch-send-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; border: none; display: grid; place-items: center; cursor: pointer; transition: background .12s, transform .08s; flex: none; }
.ch-send-btn:hover { background: var(--accent-hover); }
.ch-send-btn:active { transform: scale(.93); }
.ch-send-btn svg { width: 16px; height: 16px; }

/* ── Modal "Nueva conversación" — listado compacto, una línea por contacto ── */
.ch-newlist { display: flex; flex-direction: column; max-height: 360px; overflow-y: auto; }
.ch-new-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 6px; cursor: pointer; border-radius: 10px;
  transition: background .1s; border-bottom: 1px solid var(--border);
}
.ch-new-row:last-child { border-bottom: none; }
.ch-new-row:hover { background: var(--surface2); }
.ch-new-name { flex: 1; font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ch-new-role { font-size: 10.5px; font-weight: 700; color: var(--text-2); background: var(--surface2); padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border); flex: none; }

/* ── MÓVIL ── */
@media (max-width: 980px) {
  .ch-layout { grid-template-columns: 1fr; height: calc(100vh - 52px - calc(64px + env(safe-area-inset-bottom))); min-height: 0; border-radius: 12px; }
  .ch-left { display: flex; width: 100%; height: 100%; border-right: none; }
  .ch-left.ch-hidden { display: none !important; }
  .ch-right { display: none; width: 100%; height: 100%; }
  .ch-right.ch-visible { display: flex !important; }
  .ch-back-btn { display: flex; }
  .ch-bbl-me { max-width: 80%; }
  .ch-row-other > div { max-width: calc(80% - 36px); }
  .ch-msgs { padding: 12px 14px; }
  .ch-input-wrap { padding: 10px 12px; }
}

/* ══ NOTIFICACIONES — popover campanita ══ */
.topbar-pop .tp-notif-list { max-height: 320px; overflow-y: auto; }
.topbar-pop .tp-notif-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 10px; border-radius: 10px; transition: background .1s; border-bottom: 1px solid var(--border); }
.topbar-pop .tp-notif-item:last-child { border-bottom: none; }
.topbar-pop .tp-notif-item.tp-notif-link { cursor: pointer; }
.topbar-pop .tp-notif-item.tp-notif-link:hover { background: var(--surface2); }
.topbar-pop .tp-notif-title { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.3; }
.topbar-pop .tp-notif-body { font-size: 12px; color: var(--text-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-pop .tp-notif-time { font-size: 10px; color: var(--text-2); font-weight: 600; margin-top: 1px; }

/* ══ CONFIGURACIÓN ══ */
.cfg-wrap { display: grid; grid-template-columns: 230px 1fr; background: var(--surface1); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; margin-top: 20px; min-height: 560px; }
.cfg-nav { display: flex; flex-direction: column; background: var(--surface1); border-right: 1px solid var(--border); padding: 12px 0; gap: 1px; }
.cfg-nav-group { padding: 14px 14px 4px; font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); opacity: .5; }
.cfg-nav-group:first-child { padding-top: 4px; }
.cfg-nav-sep { height: 1px; background: var(--border); margin: 8px 14px; }
.cfg-nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; margin: 0 8px; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--text-2); background: none; border: none; cursor: pointer; text-align: left; transition: background .1s, color .1s; -webkit-tap-highlight-color: transparent; white-space: nowrap; }
.cfg-nav-item:hover { background: var(--surface2); color: var(--text); }
.cfg-nav-item.active { background: color-mix(in srgb, var(--accent) 10%, var(--surface2)); color: var(--accent); font-weight: 700; }
.cfg-nav-icon { display: flex; align-items: center; flex: none; }
.cfg-nav-icon svg { width: 15px; height: 15px; }
.cfg-panel { padding: 26px 28px; overflow-y: auto; background: var(--bg); }
.cfg-panel-title { font-size: 15px; font-weight: 800; color: var(--text); margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.cfg-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.cfg-profile-head { display: flex; align-items: center; gap: 18px; padding: 18px 20px; background: var(--surface1); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 20px; }
.cfg-avatar { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; font-weight: 800; color: #fff; flex: none; }
.cfg-logo-upload { display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--surface1); border: 1.5px dashed var(--border); border-radius: 10px; cursor: pointer; transition: border-color .12s, background .12s; font-size: 13px; font-weight: 600; color: var(--text-2); }
.cfg-logo-upload:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--surface1)); color: var(--accent); }
.cfg-logo-upload svg { width: 18px; height: 18px; }
.cfg-typo-preview { background: var(--surface1); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 20px; }
.cfg-typo-label { font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--text-2); margin-bottom: 10px; }
.cfg-typo-head { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.cfg-typo-sub { font-size: 13px; color: var(--text-2); }
.cfg-theme-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.cfg-theme-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 18px; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); transition: border-color .12s, background .12s; -webkit-tap-highlight-color: transparent; }
.cfg-theme-card:hover { border-color: var(--accent); }
.cfg-theme-card.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface1)); color: var(--accent); }
.cfg-theme-preview { width: 72px; height: 46px; border-radius: 8px; border: 1px solid var(--border); }
.cfg-theme-light { background: linear-gradient(135deg,#FFFFFF 50%,#F6F9FC 100%); border-color: #DCE6EF; }
.cfg-theme-dark { background: linear-gradient(135deg,#1E2A3A 50%,#263548 100%); border-color: #3A4D66; }
.cfg-color-group { margin-bottom: 16px; }
.cfg-color-group-label { font-size: 11px; font-weight: 800; color: var(--text-2); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; }
.cfg-swatch-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cfg-sw { width: 32px; height: 32px; border-radius: 8px; cursor: pointer; border: 2.5px solid transparent; transition: transform .12s, border-color .12s; flex: none; }
.cfg-sw:hover { transform: scale(1.1); }
.cfg-sw-on { border-color: var(--text) !important; box-shadow: 0 0 0 1px var(--bg); transform: scale(1.12); }
.cfg-sw-custom { background: conic-gradient(red,yellow,lime,cyan,blue,magenta,red); display: grid; place-items: center; }
.cfg-qa-opt { border: none; background: transparent; padding: 6px 12px; border-radius: 16px; font-size: 11.5px; font-weight: 700; color: var(--text-2); cursor: pointer; font-family: var(--font); }
.cfg-qa-opt.on { background: var(--accent); color: #fff; }
.cfg-toggle-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.cfg-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface1); transition: background .1s; }
.cfg-toggle-row:last-child { border-bottom: none; }
.cfg-toggle-row:hover { background: var(--surface2); }
.cfg-toggle-label { font-size: 13px; font-weight: 600; color: var(--text); }
.cfg-toggle-switch { position: relative; flex: none; }
.cfg-toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.cfg-toggle-track { display: block; width: 44px; height: 26px; background: var(--border); border-radius: 99px; cursor: pointer; transition: background .2s; position: relative; }
.cfg-toggle-switch input:checked + .cfg-toggle-track { background: var(--accent); }
.cfg-toggle-thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: transform .2s; }
.cfg-toggle-switch input:checked + .cfg-toggle-track .cfg-toggle-thumb { transform: translateX(18px); }
@media (max-width: 860px) {
  .cfg-wrap { grid-template-columns: 1fr; border-radius: 12px; }
  .cfg-nav { flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--border); padding: 8px 10px; gap: 4px; }
  .cfg-nav-item { border-radius: 8px; padding: 8px 12px; font-size: 12px; }
  .cfg-nav-item.active { border-left: none; border-bottom: 2px solid var(--accent); }
  .cfg-panel { padding: 18px 16px; }
  .cfg-form-grid { grid-template-columns: 1fr; }
}
