/* chat-widget.css — burbuja y panel del chat de soporte. Salió del <style> de
   partials/_chat-widget.blade.php (2026-08-23): va en todas las páginas y como
   archivo queda cacheado por asset_v(). */
/* ── NC Chat Widget — scoped con prefix .nc-chat- ─────────────────── */
.nc-chat-fab {
    position: fixed; bottom: 22px; right: 22px; z-index: 9999;
    width: 60px; height: 60px; border-radius: 50%;
    background: linear-gradient(135deg, var(--orange), var(--orange2));
    color: #fff; border: none; cursor: pointer;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
    display: flex; align-items: center; justify-content: center;
    transition: transform .18s, box-shadow .18s;
}
.nc-chat-fab:hover { transform: scale(1.06); box-shadow: 0 12px 28px rgba(37, 99, 235, 0.45); }
/* En espera: renderizada pero invisible hasta que el checkout la revele. */
.nc-chat-fab.nc-chat-hold { display: none; }
.nc-chat-fab svg { width: 30px; height: 30px; display: block; }
.nc-chat-fab .nc-chat-fab-dot {
    position: absolute; top: 2px; right: 2px;
    min-width: 20px; height: 20px; padding: 0 5px;
    background: #ef4444; color: #fff; border-radius: 999px;
    font-size: 11px; font-weight: 700; line-height: 20px;
    border: 2px solid #fff; box-sizing: content-box;
}
/* Pulse cuando hay mensajes sin leer — ondas concentricas rojas */
.nc-chat-fab.has-unread {
    animation: ncFabPulse 1.8s ease-out infinite;
}
.nc-chat-fab.has-unread .nc-chat-fab-dot {
    animation: ncDotBounce 1.2s ease-in-out infinite;
}
@keyframes ncFabPulse {
    0%   { box-shadow: 0 8px 24px rgba(37,99,235,0.35), 0 0 0 0   rgba(239,68,68,0.65); }
    70%  { box-shadow: 0 8px 24px rgba(37,99,235,0.35), 0 0 0 22px rgba(239,68,68,0); }
    100% { box-shadow: 0 8px 24px rgba(37,99,235,0.35), 0 0 0 0   rgba(239,68,68,0); }
}
@keyframes ncDotBounce {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.18); }
}

.nc-chat-panel {
    position: fixed; bottom: 96px; right: 22px; z-index: 9998;
    width: 360px; max-width: calc(100vw - 30px);
    height: 580px;
    /* dvh descuenta la barra del navegador del móvil, que vh ignora: con vh
       a secas el panel se hace más alto que lo que se ve y su cabecera (con
       la ✕ de cerrar) se va debajo de la barra. Además, al abrirse el teclado
       dvh encoge y el campo de escribir no queda tapado. */
    max-height: calc(100vh - 130px);
    max-height: calc(100dvh - 130px);
    background: #fff; border-radius: 16px; overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
    display: none; flex-direction: column;
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
    color: #0f172a;
}
[data-theme="dark"] .nc-chat-panel { background: #1e293b; color: #f1f5f9; }
.nc-chat-panel.open { display: flex; animation: ncChatSlideUp .22s ease-out; }
@keyframes ncChatSlideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.nc-chat-header {
    padding: 12px 16px; background: linear-gradient(135deg, var(--orange2), var(--orange));
    color: #fff; display: flex; align-items: center; gap: 10px;
}
.nc-chat-header .nc-chat-h-icon {
    width: 32px; height: 32px; flex-shrink: 0;
    background: rgba(255,255,255,0.18); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.nc-chat-header .nc-chat-h-icon svg { width: 18px; height: 18px; }
.nc-chat-header .nc-chat-title-wrap { flex: 1; min-width: 0; }
.nc-chat-header h3 { margin: 0; font-family: 'Outfit'; font-size: 15px; font-weight: 700; line-height: 1.2; }
.nc-chat-header .nc-chat-sub { font-size: 11px; opacity: 0.92; margin-top: 1px; display: flex; align-items: center; gap: 5px; }
.nc-chat-header .nc-chat-dot {
    width: 7px; height: 7px; border-radius: 50%; background: #94a3b8;
}
.nc-chat-header .nc-chat-dot.online { background: #34d399; box-shadow: 0 0 0 2px rgba(52,211,153,0.30); }
.nc-chat-header button {
    background: transparent; border: none; color: #fff; cursor: pointer;
    font-size: 22px; padding: 0; opacity: 0.85; transition: opacity .15s;
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
}
.nc-chat-header button:hover { opacity: 1; }

.nc-chat-body {
    flex: 1; overflow-y: auto; padding: 14px;
    display: flex; flex-direction: column; gap: 12px;
    background: #f8fafc;
}
[data-theme="dark"] .nc-chat-body { background: #0f172a; }

/* ── Welcome compacto (modo "sin thread") ─────────────────────── */
.nc-chat-welcome-compact {
    text-align: center; padding: 14px 12px; color: #475569;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
}
[data-theme="dark"] .nc-chat-welcome-compact { background: #1e293b; color: #cbd5e1; border-color: rgba(255,255,255,0.08); }
.nc-chat-welcome-compact .icon { font-size: 28px; margin-bottom: 4px; }
.nc-chat-welcome-compact .text { font-size: 13.5px; font-weight: 600; line-height: 1.4; }

.nc-chat-broadcast {
    background: linear-gradient(135deg, rgba(168,85,247,0.10), rgba(99,102,241,0.10));
    border: 1px solid rgba(168, 85, 247, 0.30); border-radius: 10px;
    padding: 10px 12px; font-size: 12.5px; line-height: 1.45;
}
.nc-chat-broadcast .b-label { font-size: 9.5px; font-weight: 700; text-transform: uppercase; color: #9333ea; letter-spacing: 0.5px; margin-bottom: 3px; }
.nc-chat-broadcast .b-question { font-weight: 600; font-size: 13px; color: inherit; margin-bottom: 6px; line-height: 1.35; }
.nc-chat-broadcast .b-desc { font-size: 11.5px; opacity: 0.82; margin-bottom: 8px; line-height: 1.4; }
.nc-chat-broadcast button {
    background: #9333ea; color: #fff; border: none; border-radius: 7px;
    padding: 6px 14px; font-size: 12px; font-weight: 600; cursor: pointer;
}

/* ── Mensajes ─────────────────────────────────────────────────── */
.nc-chat-msg { display: flex; gap: 8px; }
.nc-chat-msg.user { flex-direction: row-reverse; }
/* El tope de ancho va en el envoltorio, NO en .bubble: dentro del envoltorio
   el % se mide contra SU ancho, que depende del contenido, asi que no limita
   nada y un mensaje largo ocupa el panel entero sin respetar su lado. */
.nc-chat-msg > div { max-width: 78%; min-width: 0; }
.nc-chat-msg .bubble {
    max-width: 100%; padding: 9px 13px; border-radius: 14px;
    font-size: 14px; line-height: 1.5; overflow-wrap: anywhere;
}
.nc-chat-msg.admin .bubble { background: #fff; border: 1px solid #e2e8f0; color: #0f172a; border-top-left-radius: 4px; }
[data-theme="dark"] .nc-chat-msg.admin .bubble { background: #1e293b; border-color: rgba(255,255,255,0.08); color: #f1f5f9; }
.nc-chat-msg.user .bubble { background: var(--orange); color: #fff; border-top-right-radius: 4px; }
.nc-chat-msg .meta { font-size: 10px; opacity: 0.6; margin-top: 3px; }
.nc-chat-msg.user .meta { text-align: right; }
.nc-chat-msg .bubble img { max-width: 180px; max-height: 140px; border-radius: 6px; margin-top: 5px; display: block; }
.nc-chat-msg .bubble img.nc-chat-zoom { cursor: zoom-in; transition: filter .15s; }
.nc-chat-msg .bubble img.nc-chat-zoom:hover { filter: brightness(1.06); }

/* Visor de imagenes — se abre encima del chat, no en otra pestaña */
.nc-chat-viewer {
    position: fixed; inset: 0; z-index: 10050;
    background: rgba(15, 23, 42, 0.92);
    display: none; align-items: center; justify-content: center;
    padding: 40px 20px;
}
.nc-chat-viewer.is-open { display: flex; }
.nc-chat-viewer img {
    max-width: 100%; max-height: 100%;
    border-radius: 10px; object-fit: contain;
    box-shadow: 0 18px 50px rgba(0,0,0,0.5);
}
.nc-chat-viewer-close {
    position: absolute; top: 14px; right: 18px;
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,0.14); color: #fff;
    border: none; font-size: 19px; cursor: pointer; line-height: 1;
}
.nc-chat-viewer-close:hover { background: rgba(255,255,255,0.26); }
.nc-chat-viewer-dl {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(255,255,255,0.14); color: #fff; text-decoration: none;
    padding: 9px 18px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.nc-chat-viewer-dl:hover { background: rgba(255,255,255,0.26); }
.nc-chat-msg .bubble a { color: inherit; text-decoration: underline; }
/* Tarjeta link para PDF/SVG/DXF/HEIC dentro de la burbuja */
.nc-att-link {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(0,0,0,0.06); border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px; padding: 7px 10px; margin-top: 6px;
    text-decoration: none !important; color: inherit;
    min-width: 160px; max-width: 240px;
}
.nc-chat-msg.user .nc-att-link { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.25); color: #fff; }
[data-theme="dark"] .nc-chat-msg.admin .nc-att-link { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.10); }
.nc-att-link:hover { filter: brightness(1.05); }
.nc-att-icon { font-size: 20px; line-height: 1; flex-shrink: 0; }
.nc-att-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.nc-att-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-att-meta { font-size: 10px; opacity: 0.7; margin-top: 1px; }
.nc-att-action { font-size: 14px; font-weight: 700; flex-shrink: 0; }

.nc-chat-resolved-banner {
    text-align: center; padding: 10px; background: rgba(22, 163, 74, 0.10);
    border: 1px dashed rgba(22, 163, 74, 0.30); border-radius: 10px;
    font-size: 13px; color: #16a34a; font-weight: 600;
}

/* ── Footer (send form, solo cuando hay thread) ────────────────── */
.nc-chat-footer {
    padding: 10px 12px; border-top: 1px solid #e2e8f0; background: #fff;
}
[data-theme="dark"] .nc-chat-footer { background: #1e293b; border-color: rgba(255,255,255,0.08); }

.nc-chat-form {
    display: flex; gap: 6px; align-items: flex-end;
}
.nc-chat-form textarea {
    flex: 1; padding: 9px 12px; border-radius: 10px;
    border: 1px solid #cbd5e1; background: #fff; color: #0f172a;
    font-size: 14px; resize: none; min-height: 38px; max-height: 100px;
    font-family: 'DM Sans', sans-serif; line-height: 1.4;
}
[data-theme="dark"] .nc-chat-form textarea { background: #0f172a; border-color: rgba(255,255,255,0.10); color: #f1f5f9; }
.nc-chat-form textarea:focus { outline: none; border-color: var(--orange); }
.nc-chat-form .send-btn, .nc-chat-form .attach-btn {
    width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s, background .15s; flex-shrink: 0;
}
.nc-chat-form .send-btn { background: var(--orange); color: #fff; font-size: 18px; }
.nc-chat-form .send-btn:hover { transform: scale(1.08); }
.nc-chat-form .send-btn:disabled { background: #94a3b8; cursor: not-allowed; transform: none; }
.nc-chat-form .attach-btn { background: #f1f5f9; color: #475569; }
.nc-chat-form .attach-btn svg { width: 18px; height: 18px; }
[data-theme="dark"] .nc-chat-form .attach-btn { background: #0f172a; color: #94a3b8; }

/* ── Start form (cuando no hay thread, dentro del body) ──────── */
.nc-chat-start-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    padding: 14px; display: flex; flex-direction: column; gap: 10px;
    /* Crece para llenar el espacio sobrante del body (textarea expandible) */
    flex: 1; min-height: 0;
}
[data-theme="dark"] .nc-chat-start-card { background: #1e293b; border-color: rgba(255,255,255,0.08); }

.nc-chat-start-form { display: flex; flex-direction: column; gap: 7px; flex: 1; min-height: 0; }
.nc-chat-start-form .anon-hint {
    font-size: 11.5px; color: #64748b; line-height: 1.4;
    background: rgba(37, 99, 235, 0.06); padding: 6px 10px; border-radius: 7px;
    border-left: 3px solid var(--orange);
}
[data-theme="dark"] .nc-chat-start-form .anon-hint { color: #94a3b8; }
.nc-chat-start-form input, .nc-chat-start-form select, .nc-chat-start-form textarea {
    padding: 8px 11px; border-radius: 8px; border: 1px solid #cbd5e1;
    background: #f8fafc; color: #0f172a; font-size: 13px;
    font-family: 'DM Sans', sans-serif; box-sizing: border-box; width: 100%;
}
[data-theme="dark"] .nc-chat-start-form input,
[data-theme="dark"] .nc-chat-start-form select,
[data-theme="dark"] .nc-chat-start-form textarea { background: #0f172a; color: #f1f5f9; border-color: rgba(255,255,255,0.10); }
.nc-chat-start-form input:focus, .nc-chat-start-form select:focus, .nc-chat-start-form textarea:focus { outline: none; border-color: var(--orange); }
.nc-chat-start-form textarea {
    min-height: 58px; resize: none; line-height: 1.4;
    /* Crece para ocupar el espacio sobrante */
    flex: 1;
}
.nc-chat-start-form .start-bottom { display: flex; gap: 8px; align-items: center; }
.nc-chat-start-form .attach-btn-start {
    background: #f1f5f9; border: 1px solid #cbd5e1; color: #475569;
    width: 38px; height: 38px; border-radius: 8px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
[data-theme="dark"] .nc-chat-start-form .attach-btn-start { background: #0f172a; border-color: rgba(255,255,255,0.10); color: #94a3b8; }
.nc-chat-start-form .attach-btn-start svg { width: 18px; height: 18px; }
.nc-chat-start-form .attach-btn-start[title]:hover { color: var(--orange); }
.nc-chat-start-form button[type=submit] {
    flex: 1; background: var(--orange); color: #fff; border: none; border-radius: 8px;
    padding: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.nc-chat-start-form button[type=submit]:hover { opacity: 0.92; }
.nc-chat-start-form button[type=submit]:disabled { background: #94a3b8; cursor: not-allowed; }

.nc-chat-att-preview {
    display: flex; align-items: center; gap: 8px; font-size: 12px; color: #64748b;
    padding: 6px 8px; background: rgba(99,102,241,0.08); border-radius: 7px;
}
.nc-chat-att-preview img { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; }
.nc-chat-att-preview button { background: none; border: none; color: #dc2626; cursor: pointer; font-size: 16px; line-height: 1; }

.nc-chat-err {
    background: rgba(220, 38, 38, 0.10); color: #dc2626;
    padding: 8px 12px; border-radius: 7px; font-size: 12px;
}

/* Tips card debajo del start form (llena espacio vacio cuando logueado) */
.nc-chat-tips {
    background: rgba(37,99,235,0.05); border: 1px dashed rgba(37,99,235,0.25);
    border-radius: 10px; padding: 12px 14px; font-size: 12.5px; color: #475569;
    line-height: 1.55;
}
[data-theme="dark"] .nc-chat-tips { background: rgba(96,165,250,0.06); border-color: rgba(96,165,250,0.20); color: #cbd5e1; }
.nc-chat-tips strong { color: var(--orange); font-weight: 700; }
[data-theme="dark"] .nc-chat-tips strong { color: #60a5fa; }
.nc-chat-tips ul { margin: 6px 0 0 0; padding-left: 18px; }
.nc-chat-tips li { margin-bottom: 3px; }

@media (max-width: 480px) {
    .nc-chat-panel {
        width: calc(100vw - 30px); bottom: 86px; right: 15px;
        height: calc(100vh - 110px);
        height: calc(100dvh - 110px);
    }
    .nc-chat-fab { width: 52px; height: 52px; bottom: 18px; right: 18px; }
    .nc-chat-fab svg { width: 26px; height: 26px; }
}
