/* ==========================================================================
   assets/css/ik-chat.css — Chat v2 (assets/js/ik-chat.js). Independiente de Tailwind: se usa en el
   panel, en el marketplace web y en las apps móviles. Paleta de la marca (carbón + bronce).
   ========================================================================== */
.ikc {
    --c-ink: #1f2328; --c-ink-2: #57606a; --c-muted: #8b949e; --c-line: #eaeef2; --c-line-2: #f3f4f6;
    --c-bg: #f6f3ee; --c-card: #fff; --c-accent: #AB733C; --c-accent-2: #CD9765; --c-navy: #1D2530;
    --c-mine: #1D2530; --c-mine-ink: #fff; --c-theirs: #fff; --c-ok: #16a34a; --c-err: #d1242f;
    --c-read: #6fc3ff;
    position: relative; display: grid; grid-template-columns: 340px minmax(0, 1fr); height: 100%; min-height: 0;
    background: var(--c-card); color: var(--c-ink); font-family: Inter, system-ui, -apple-system, sans-serif; font-size: 14px;
    border-radius: inherit; overflow: hidden;
}
.ikc *, .ikc *::before, .ikc *::after { box-sizing: border-box; }
.ikc .material-symbols-outlined { font-size: 20px; line-height: 1; font-variation-settings: 'FILL' 0, 'wght' 400; vertical-align: middle; }
.ikc button { font: inherit; color: inherit; }
.ikc [hidden] { display: none !important; }

/* ── Lista ──────────────────────────────────────────────────────────── */
.ikc-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--c-line); background: #fff; }
.ikc-list-head { padding: 12px; border-bottom: 1px solid var(--c-line-2); }
.ikc-search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-radius: 10px; background: var(--c-line-2); color: var(--c-muted); }
.ikc-search input { flex: 1; min-width: 0; border: 0 !important; outline: 0 !important; box-shadow: none !important; background: transparent !important; font-size: 14px !important; padding: 0 !important; height: auto !important; color: var(--c-ink); }
.ikc-list-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 6px; }
.ikc-row { width: 100%; display: flex; gap: 12px; align-items: flex-start; padding: 10px; border: 0; background: transparent; border-radius: 12px; text-align: left; cursor: pointer; transition: background .12s; }
.ikc-row:hover { background: #faf8f5; }
.ikc-row.is-active { background: #f4ede4; }
.ikc-av { width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #3b2a14; background: linear-gradient(135deg, #CD9765, #f3dcc2); overflow: hidden; }
.ikc-av img { width: 100%; height: 100%; object-fit: cover; }
.ikc-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ikc-row-top, .ikc-row-bottom { display: flex; align-items: center; gap: 8px; }
.ikc-row-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ikc-row-time { font-size: 12px; color: var(--c-muted); flex-shrink: 0; }
.ikc-row.is-unread .ikc-row-time { color: var(--c-accent); font-weight: 600; }
.ikc-row-preview { flex: 1; min-width: 0; color: var(--c-ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ikc-row.is-unread .ikc-row-preview { color: var(--c-ink); font-weight: 500; }
.ikc-row-product { font-size: 11.5px; color: var(--c-muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ikc-row-product .material-symbols-outlined { font-size: 14px; }
.ikc-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--c-accent); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.ikc-verified .material-symbols-outlined { font-size: 15px; color: var(--c-accent); font-variation-settings: 'FILL' 1; }
.ikc-typing-txt { color: var(--c-ok); font-style: normal; }
.ikc-tick { display: inline-flex; color: var(--c-muted); margin-right: 3px; }
.ikc-tick .material-symbols-outlined { font-size: 15px; }
.ikc-tick.is-read { color: #2f81f7; }
.ikc-list-empty, .ikc-thread-empty, .ikc-empty-thread { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 40px 24px; color: var(--c-ink-2); font-size: 13px; }
.ikc-list-empty .material-symbols-outlined, .ikc-thread-empty .material-symbols-outlined, .ikc-empty-thread .material-symbols-outlined { font-size: 40px; color: var(--c-accent-2); }
.ikc-list-empty strong, .ikc-thread-empty strong, .ikc-empty-thread strong { color: var(--c-ink); font-size: 15px; }
.ikc-empty-thread { flex: 1; }

/* esqueletos */
@keyframes ikcShim { 0% { background-position: 100% 0 } 100% { background-position: -100% 0 } }
.ikc-skel .ikc-av, .ikc-skel i { background: linear-gradient(100deg, #eee 30%, #f7f7f7 50%, #eee 70%); background-size: 200% 100%; animation: ikcShim 1.2s linear infinite; }
.ikc-row.ikc-skel i { display: block; height: 10px; border-radius: 5px; margin: 6px 0; width: 70%; }
.ikc-row.ikc-skel i + i { width: 45%; }
.ikc-msg.ikc-skel .ikc-bubble { background: transparent !important; box-shadow: none !important; width: 220px; }
.ikc-msg.ikc-skel i { display: block; height: 14px; border-radius: 7px; margin: 6px 0; }
.ikc-msg.ikc-skel i + i { width: 60%; }

/* ── Hilo ───────────────────────────────────────────────────────────── */
.ikc-thread { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--c-bg); }
.ikc-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--c-line); min-height: 62px; }
.ikc-av--head { width: 40px; height: 40px; font-size: 13px; }
.ikc-head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ikc-head-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ikc-head-sub { font-size: 12.5px; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ikc-head-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ikc-ibtn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--c-ink-2); flex-shrink: 0; text-decoration: none; transition: background .12s, color .12s; }
.ikc-ibtn:hover { background: var(--c-line-2); color: var(--c-ink); }
.ikc-ibtn .material-symbols-outlined { font-size: 22px; }
.ikc-btn { height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--c-line); background: #fff; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.ikc-btn--ok { background: var(--c-ok); border-color: var(--c-ok); color: #fff; }
.ikc-btn .material-symbols-outlined { font-size: 18px; }
.ikc-chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.ikc-chip--ok { background: #e7f6ec; color: #15803d; }
.ikc-chip .material-symbols-outlined { font-size: 16px; font-variation-settings: 'FILL' 1; }
.ikc-banner { background: #fff8ef; border-bottom: 1px solid #f1dfc7; font-size: 13px; }
.ikc-banner summary { padding: 10px 16px; cursor: pointer; display: flex; align-items: center; gap: 8px; list-style: none; color: #6b4a22; }
.ikc-banner summary::-webkit-details-marker { display: none; }
.ikc-pay { display: grid; gap: 8px; padding: 0 16px 12px; }
.ikc-pay > div { background: #fff; border: 1px solid #f1dfc7; border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.ikc-pay span { color: var(--c-ink-2); font-size: 12.5px; user-select: all; }

.ikc-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 18px 8px; outline: 0;
    background-image: radial-gradient(rgba(171,115,60,.06) 1px, transparent 1px); background-size: 18px 18px; }
.ikc-older { display: flex; justify-content: center; padding: 6px 0 12px; }
.ikc-spin { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #e2d3c0; border-top-color: var(--c-accent); animation: ikcSpin .7s linear infinite; }
@keyframes ikcSpin { to { transform: rotate(360deg); } }
.ikc-day { display: flex; justify-content: center; margin: 14px 0 8px; position: sticky; top: 0; z-index: 2; }
.ikc-day span { background: rgba(255,255,255,.95); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-size: 11.5px; font-weight: 600; color: var(--c-ink-2); padding: 4px 12px; border-radius: 999px; }
.ikc-msg { display: flex; margin-top: 10px; animation: ikcIn .18s ease; }
.ikc-msg.is-grouped { margin-top: 3px; }
@keyframes ikcIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ikc-msg.is-mine { justify-content: flex-end; }
.ikc-bubble { max-width: min(78%, 560px); min-width: 0; background: var(--c-theirs); border-radius: 16px 16px 16px 4px; padding: 8px 10px 6px 12px; box-shadow: 0 1px 1.5px rgba(0,0,0,.08); position: relative; overflow-wrap: anywhere; }
.ikc-msg.is-grouped .ikc-bubble { border-radius: 16px; }
.ikc-msg.is-mine .ikc-bubble { background: var(--c-mine); color: var(--c-mine-ink); border-radius: 16px 16px 4px 16px; }
.ikc-msg.is-mine.is-grouped .ikc-bubble { border-radius: 16px; }
.ikc-msg.is-failed .ikc-bubble { opacity: .75; outline: 1.5px dashed var(--c-err); }
.ikc-text { line-height: 1.45; white-space: normal; }
.ikc-text a { color: inherit; text-decoration: underline; }
.ikc-msg.is-mine .ikc-text a { color: #ffe1bf; }
.ikc-msg.is-emoji .ikc-bubble { background: transparent !important; box-shadow: none; padding: 0; }
.ikc-msg.is-emoji .ikc-text { font-size: 40px; line-height: 1.15; }
.ikc-msg.is-emoji .ikc-meta { color: var(--c-muted) !important; }
.ikc-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11px; color: var(--c-muted); margin-top: 3px; }
.ikc-msg.is-mine .ikc-meta { color: rgba(255,255,255,.65); }
.ikc-msg.is-mine .ikc-tick { color: rgba(255,255,255,.65); }
.ikc-msg.is-mine .ikc-tick.is-read { color: var(--c-read); }
.ikc-retry { border: 0; background: none; color: #ffb4b4; font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; cursor: pointer; padding: 0; }
.ikc-retry .material-symbols-outlined { font-size: 15px; }
.ikc-product { display: flex; align-items: center; gap: 10px; padding: 6px; margin: 0 -4px 6px -6px; border-radius: 10px; background: rgba(0,0,0,.04); text-decoration: none; color: inherit; }
.ikc-msg.is-mine .ikc-product { background: rgba(255,255,255,.1); }
.ikc-product img, .ikc-product > .material-symbols-outlined { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: #f3ece2; color: var(--c-accent); }
.ikc-product span { display: flex; flex-direction: column; min-width: 0; font-size: 12.5px; }
.ikc-product b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ikc-product small { opacity: .75; }
.ikc-imgs { display: grid; gap: 3px; margin: -2px -4px 4px -6px; border-radius: 12px; overflow: hidden; }
.ikc-imgs--1 { grid-template-columns: 1fr; } .ikc-imgs--2 { grid-template-columns: 1fr 1fr; } .ikc-imgs--3, .ikc-imgs--4 { grid-template-columns: 1fr 1fr; }
.ikc-imgs--3 .ikc-img:first-child { grid-column: 1 / -1; }
.ikc-img { position: relative; border: 0; padding: 0; cursor: zoom-in; background: #eee; display: block; aspect-ratio: 4 / 3; overflow: hidden; }
.ikc-imgs--1 .ikc-img { aspect-ratio: auto; max-height: 320px; }
.ikc-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ikc-imgs--1 .ikc-img img { max-height: 320px; min-width: 180px; }
.ikc-more { position: absolute; inset: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 22px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.ikc-file { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 2px -4px 6px -6px; border-radius: 10px; background: rgba(0,0,0,.04); text-decoration: none; color: inherit; min-width: 220px; }
.ikc-msg.is-mine .ikc-file { background: rgba(255,255,255,.1); }
.ikc-file:hover { background: rgba(0,0,0,.07); }
.ikc-file-ic { width: 38px; height: 44px; flex-shrink: 0; border-radius: 6px; background: var(--c); color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; letter-spacing: .02em; position: relative; clip-path: polygon(0 0, 72% 0, 100% 22%, 100% 100%, 0 100%); }
.ikc-file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ikc-file-main b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ikc-file-main small { font-size: 11.5px; opacity: .7; }
.ikc-typing { display: inline-flex; gap: 4px; padding: 10px 14px; margin: 8px 0 4px; background: #fff; border-radius: 16px 16px 16px 4px; box-shadow: 0 1px 1.5px rgba(0,0,0,.08); }
.ikc-typing span { width: 7px; height: 7px; border-radius: 50%; background: #b8a58c; animation: ikcDot 1.2s infinite ease-in-out; }
.ikc-typing span:nth-child(2) { animation-delay: .15s; } .ikc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ikcDot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.ikc-newpill { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 4; border: 0; border-radius: 999px; background: var(--c-navy); color: #fff; font-size: 12.5px; font-weight: 600; height: 34px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.2); cursor: pointer; }
.ikc-newpill .material-symbols-outlined { font-size: 18px; }

/* ── Compositor ─────────────────────────────────────────────────────── */
.ikc-compose { position: relative; background: #fff; border-top: 1px solid var(--c-line); padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); }
.ikc-compose-row { display: flex; align-items: flex-end; gap: 2px; }
.ikc-compose textarea { flex: 1; min-width: 0; resize: none; border: 1px solid var(--c-line) !important; border-radius: 20px !important; padding: 9px 14px !important; font: inherit; font-size: 15px !important; line-height: 1.4; max-height: 140px; outline: 0 !important; background: #f7f7f8 !important; color: var(--c-ink); box-shadow: none !important; margin: 0 4px; }
.ikc-compose textarea:focus { border-color: var(--c-accent-2) !important; background: #fff !important; }
.ikc-send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--c-accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: transform .12s, background .12s, opacity .12s; }
.ikc-send:hover { background: #9a6533; }
.ikc-send:active { transform: scale(.94); }
.ikc-send:disabled { opacity: .45; cursor: default; }
.ikc-send .material-symbols-outlined { font-size: 21px; margin-left: 2px; }
.ikc-tray { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; }
.ikc-chip-file { display: flex; align-items: center; gap: 8px; padding: 6px 4px 6px 6px; border: 1px solid var(--c-line); border-radius: 12px; background: #fafafa; min-width: 200px; max-width: 260px; flex-shrink: 0; }
.ikc-chip-file img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.ikc-chip-file .ikc-file-ic { width: 32px; height: 40px; font-size: 9px; }
.ikc-chip-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ikc-chip-main b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ikc-chip-main small { font-size: 11px; color: var(--c-muted); }
.ikc-chip-file.is-error { border-color: #f5c2c2; background: #fff5f5; }
.ikc-chip-file.is-error small { color: var(--c-err); }
.ikc-chip-file .ikc-ibtn { width: 28px; height: 28px; }
.ikc-chip-file .ikc-ibtn .material-symbols-outlined { font-size: 18px; }
.ikc-progress { height: 4px; border-radius: 2px; background: #eee; overflow: hidden; }
.ikc-progress i { display: block; height: 100%; background: var(--c-accent); transition: width .15s; }
.ikc-emoji { position: absolute; left: 8px; bottom: calc(100% + 6px); width: min(360px, calc(100vw - 16px)); background: #fff; border: 1px solid var(--c-line); border-radius: 16px; box-shadow: 0 14px 40px rgba(0,0,0,.16); z-index: 20; overflow: hidden; animation: ikcIn .14s ease; }
.ikc-emoji-tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--c-line-2); overflow-x: auto; }
.ikc-emoji-tabs button { border: 0; background: none; border-radius: 8px; height: 34px; min-width: 38px; padding: 0 6px; font-size: 18px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.ikc-emoji-tabs button span { display: none; font-size: 12px; font-weight: 600; }
.ikc-emoji-tabs button.is-active { background: #f4ede4; }
.ikc-emoji-tabs button.is-active span { display: inline; }
.ikc-emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; max-height: 230px; overflow-y: auto; }
.ikc-emoji-grid button { border: 0; background: none; font-size: 24px; height: 40px; border-radius: 8px; cursor: pointer; transition: background .1s, transform .1s; }
.ikc-emoji-grid button:hover { background: #f4ede4; transform: scale(1.15); }
.ikc-drop { position: absolute; inset: 8px; z-index: 30; border: 2px dashed var(--c-accent); border-radius: 16px; background: rgba(255,248,239,.94); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #6b4a22; font-weight: 600; pointer-events: none; }
.ikc-drop .material-symbols-outlined { font-size: 44px; color: var(--c-accent); }
.ikc-lightbox { position: fixed; inset: 0; z-index: 10000; background: rgba(10,10,10,.92); display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.ikc-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.ikc-lb-close { position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; }
.ikc-lb-dl { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); color: #fff; text-decoration: none; font-weight: 600; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; background: rgba(255,255,255,.14); padding: 10px 18px; border-radius: 999px; }
.ikc-toast { position: absolute; left: 50%; bottom: 90px; transform: translate(-50%, 10px); background: #1f2328; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 40; max-width: 90%; text-align: center; }
.ikc-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── Disposición apilada (móvil / apps): lista O hilo ─────────────────── */
.ikc--stack { grid-template-columns: 1fr; }
.ikc--stack .ikc-thread { display: none; }
.ikc--stack.ikc--thread-open .ikc-list { display: none; }
.ikc--stack.ikc--thread-open .ikc-thread { display: flex; }
.ikc--stack .ikc-empty-thread { display: none; }
@media (max-width: 860px) {
    .ikc--split { grid-template-columns: 1fr; }
    .ikc--split .ikc-thread { display: none; }
    .ikc--split.ikc--thread-open .ikc-list { display: none; }
    .ikc--split.ikc--thread-open .ikc-thread { display: flex; }
}
@media (max-width: 520px) {
    .ikc-body { padding: 10px 10px 6px; }
    .ikc-bubble { max-width: 86%; }
    .ikc-head-actions .ikc-btn { padding: 0 10px; font-size: 12px; }
    .ikc-file { min-width: 0; }
    .ikc-compose .ikc-ibtn { width: 36px; height: 40px; }
}
