﻿/* Paleta CSC: azul primario #0c326b (40 %), verde #a6cb13 (10 %), azul secundario #3467d5, grises #676767 / #8c8c8c */
:root {
  --primary: #0c326b;
  --primary-soft: #e6ecf6;
  --green: #a6cb13;
  --green-dark: #7f9c0c;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #0f1f3d;
  --muted: #676767;
  --border: #dfe4ee;
  --accent: #3467d5;
  --accent-soft: #e8eefb;
  --user: #0c326b;
  --user-text: #ffffff;
  --ok: #7f9c0c;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary-soft: #16294f; --bg: #0a1226; --surface: #12203f; --text: #e9eef8; --muted: #9aa4b8; --border: #223559;
    --accent: #6b9aff; --accent-soft: #1a2d55; --user: #3467d5; --ok: #a6cb13;
  }
}
:root[data-theme="dark"] {
  --primary-soft: #16294f; --bg: #0a1226; --surface: #12203f; --text: #e9eef8; --muted: #9aa4b8; --border: #223559;
  --accent: #6b9aff; --accent-soft: #1a2d55; --user: #3467d5; --ok: #a6cb13;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 15px; line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13.5px; margin: 0 0 4px; }
.only-mobile { display: none; }

/* ---------- Marca / botones ---------- */
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 44px; height: 44px; border-radius: 12px; background: #fff; flex-shrink: 0; overflow: hidden;
  display: grid; place-items: center; border: 1px solid var(--border);
}
.logo img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
/* El logo lleva texto azul marino: siempre va sobre fondo blanco para que se vea también en modo oscuro */
.logo-wide { display: block; width: 100%; max-width: 230px; margin: 0 auto 8px; background: #fff; border-radius: 14px; padding: 10px 14px; }
.gate-card .brand { flex-direction: column; gap: 4px; }
.gate-card .brand-name { font-size: 20px; color: var(--primary); }
:root[data-theme="dark"] .gate-card .brand-name { color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .gate-card .brand-name { color: #fff; } }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: #123f86; }
.dot { background: var(--green); }
.side-new { background: var(--accent); }
.theme-btn { background: none; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; cursor: pointer; font-size: 14px; color: var(--muted); }
.theme-btn:hover { color: var(--text); border-color: var(--muted); }
.theme-opts { display: flex; gap: 6px; }
.theme-opts button { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; font: inherit; }
.theme-opts button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.brand-name { font-weight: 650; font-size: 16px; }
.brand-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 7px 12px; border-radius: 10px; cursor: pointer; font-size: 13px; font-family: inherit;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 11px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.link { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 13.5px; padding: 4px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 16px; }
.form-ok { color: var(--ok); font-size: 13px; }

/* ---------- Pantalla de acceso ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.gate-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 26px 24px; }
.gate-tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.gate-tab { flex: 1; border: none; background: transparent; color: var(--muted); padding: 8px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; }
.gate-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.gate-view { display: flex; flex-direction: column; gap: 10px; }
.gate-view input, .gate-view select, .modal select {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; outline: none;
}
.gate-view input:focus, .gate-view select:focus { border-color: var(--accent); }
.pin { text-align: center; font-size: 26px; letter-spacing: .5em; font-family: ui-monospace, Consolas, monospace; }
.pin.ok { border-color: var(--ok) !important; } .pin.bad { border-color: var(--danger) !important; }
.pin-label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 500; }
.pin-label small { color: var(--muted); font-weight: 400; } .pin-label small.ok { color: var(--ok); } .pin-label small.bad { color: var(--danger); }
.optional summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.optional input { margin-top: 8px; }
.notice { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border)); border-radius: 10px; padding: 9px 12px; font-size: 13px; }
.code-box {
  font-family: ui-monospace, Consolas, monospace; font-size: 34px; letter-spacing: .3em; text-align: center;
  padding: 16px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-weight: 700; user-select: all;
}

/* ---------- Portal (barra lateral + chat) ---------- */
.portal { display: flex; height: 100dvh; }
.side {
  width: 300px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 12px;
}
.side-head { padding: 4px 6px 12px; }
.side-new { width: 100%; padding: 10px; }
.side-tabs { display: flex; gap: 4px; margin: 12px 0 8px; border-bottom: 1px solid var(--border); }
.side-tab { flex: 1; background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 4px; color: var(--muted); cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; }
.side-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.side-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 2px 6px 8px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch { width: 36px; height: 20px; border-radius: 999px; background: var(--border); position: relative; transition: background .2s; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(16px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle .muted { font-size: 12px; margin: 0 0 0 auto; }
.badge.company { background: #ede9fe; color: #6d28d9; }
.badge.reabierto { background: #fde68a; color: #92400e; }
.side-tools { display: flex; align-items: center; gap: 6px; }
.side-tools .toggle { flex: 1; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 15px; }
.icon-btn:hover, .icon-btn.active { border-color: var(--border); background: var(--bg); }
.search-panel { display: flex; flex-direction: column; gap: 6px; padding: 8px; margin-bottom: 8px; background: var(--bg); border-radius: 10px; }
.search-panel input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.search-panel .dates { display: flex; gap: 6px; }
.search-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.ticket-item.compact { padding: 8px 10px; }
.ticket-item.compact .s { font-size: 13px; margin: 1px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-item.compact .m { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ticket-item.active { border-color: var(--accent); background: var(--accent-soft); }
.side-tools { flex-wrap: wrap; } .side-tools .toggle { flex: 0 0 auto; padding: 2px 4px 6px; }
.ticket-actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 4px; }
.ticket-actions .rating-inline { margin: 0 auto 0 0; }
.ticket-actions .link { font-size: 11.5px; color: var(--muted); padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.ticket-actions .link:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.ticket-actions .escalate-link:hover { color: var(--danger); border-color: var(--danger); }
.bell { position: relative; }
.bell-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.notif-panel { position: absolute; right: 16px; top: 62px; width: min(380px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 30; max-height: 70vh; overflow-y: auto; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13.5px; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--accent-soft); }
.notif-item .t { font-weight: 600; } .notif-item .b { color: var(--muted); font-size: 12.5px; white-space: pre-wrap; } .notif-item .d { font-size: 11px; color: var(--muted); margin-top: 2px; }
.msg.update .bubble { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.msg.update .avatar { background: var(--accent); color: #fff; }
.app { position: relative; }
.rating-inline { font-size: 12px; color: #d97706; margin-top: 4px; }
.stars { display: flex; justify-content: center; gap: 4px; }
.stars button { background: none; border: none; font-size: 34px; line-height: 1; color: var(--border); cursor: pointer; padding: 2px; transition: transform .1s; }
.stars button.on { color: #f59e0b; } .stars button:hover { transform: scale(1.15); }
.rate-ticket { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.rate-ticket b { display: block; }
.rate-card { align-self: center; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 18px; text-align: center; max-width: 420px; }
.rate-card .stars button { font-size: 28px; }
.banner { margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--danger) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); color: var(--danger); font-size: 14px; font-weight: 500; }
.closed-notice { text-align: center; font-size: 13px; color: var(--muted); padding: 8px; background: var(--surface); border: 1px dashed var(--border); border-radius: 10px; margin-bottom: 8px; }
.closed-notice button { margin-left: 8px; }
.conv-item.closed .t { color: var(--muted); }
.badge.closed { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.ticket-item.escalated { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.badge.escalated { background: var(--danger); color: #fff; }
.ticket-foot { display: flex; justify-content: flex-end; margin-top: 2px; }

.attach { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 18px; flex-shrink: 0; }
.attach:hover { border-color: var(--accent); }
.attachment img, .attachment video { max-width: 280px; max-height: 220px; border-radius: 8px; display: block; margin-top: 6px; }
.attachment a { color: inherit; font-size: 13px; }
.side-foot { padding-top: 8px; border-top: 1px solid var(--border); }
.conv-item { padding: 9px 10px; border-radius: 10px; cursor: pointer; border: 1px solid var(--border); margin-bottom: 2px; }
.conv-item:hover { border-color: var(--accent); }
.conv-item.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.conv-item .t { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .m { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .meta { display: flex; gap: 6px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.abierto { background: #fee2e2; color: #b91c1c; } .badge.en_proceso { background: #fef3c7; color: #b45309; } .badge.cerrado { background: #dcfce7; color: #15803d; }
.badge.cc { background: var(--accent-soft); color: var(--accent); }
.empty { color: var(--muted); font-size: 13px; padding: 12px 8px; text-align: center; }

.ticket-item { padding: 10px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 6px; cursor: pointer; }
.ticket-item:hover { border-color: var(--accent); }
.ticket-item .n { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.ticket-item .s { font-size: 13.5px; font-weight: 600; margin: 2px 0; }
.ticket-item .notes { font-size: 12px; color: var(--muted); margin-top: 4px; border-left: 2px solid var(--border); padding-left: 8px; }

.app { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 0 16px; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.conv-title { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-actions { display: flex; align-items: center; gap: 8px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }

.messages { flex: 1; overflow-y: auto; padding: 20px 4px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 85%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.user.other { align-self: flex-start; flex-direction: row; }
.bubble { padding: 11px 15px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--user); color: var(--user-text); border-color: transparent; border-bottom-right-radius: 4px; }
.msg.user.other .bubble { background: var(--accent-soft); color: var(--text); border-bottom-right-radius: var(--radius); border-bottom-left-radius: 4px; }
.msg.assistant .bubble { border-bottom-left-radius: 4px; }
.author { font-size: 11.5px; font-weight: 600; opacity: .8; margin-bottom: 3px; }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 6px 0; padding-left: 20px; }
.bubble pre { background: rgba(0,0,0,.06); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
.bubble code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.bubble a { color: var(--accent); }
.avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; margin-top: 2px; }
.event { align-self: center; font-size: 12.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; }
.event.ticket { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.event.error { color: var(--danger); }
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 1px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

.pending-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 0; }
.pending-file { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; max-width: 260px; }
.pending-file img { width: 26px; height: 26px; object-fit: cover; border-radius: 6px; }
.pending-file span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pending-file button { background: none; border: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.pending-file.uploading { opacity: .6; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 0 6px; border-top: 1px solid var(--border); }
.composer textarea { flex: 1; resize: none; max-height: 160px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; outline: none; }
.composer textarea:focus { border-color: var(--accent); }
.composer button { width: 44px; height: 44px; border-radius: 12px; border: none; background: var(--accent); color: #fff; cursor: pointer; display: grid; place-items: center; }
.composer button:disabled { opacity: .5; cursor: default; }
.footnote { font-size: 11.5px; color: var(--muted); text-align: center; padding: 4px 0 10px; }

/* ---------- Modal seguidores ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.modal-card h3 { margin: 0; }
.follower-list { display: flex; flex-direction: column; gap: 6px; }
.follower { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: var(--bg); border-radius: 10px; font-size: 14px; }
.follower button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.add-follower { display: flex; gap: 8px; } .add-follower select { flex: 1; } .add-follower .btn-primary { padding: 8px 14px; }

@media (max-width: 800px) {
  .only-mobile { display: inline-block; }
  .side { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(85vw, 320px); transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.2); }
  .side.open { transform: none; }
  .conv-actions .chips { display: none; }
}
