/* PrintFlow Chat Widget — estilos */

/* ── Widget container ───────────────────────────────────────── */
#pf-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Instrument Sans', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Botón flotante ─────────────────────────────────────────── */
#pf-chat-btn {
    width: 56px;
    height: 56px;
    border-radius: 9999px;
    background: var(--foreground, #141414);
    color: var(--background, #f9f8f5);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}
#pf-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
}
#pf-chat-btn svg {
    width: 24px;
    height: 24px;
    pointer-events: none;
}

/* Burbuja de notificación */
#pf-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #ef4444;
    border-radius: 9999px;
    border: 2px solid var(--background, #f9f8f5);
    display: none;
}
#pf-chat-badge.visible {
    display: block;
}

/* ── Panel del chat ─────────────────────────────────────────── */
#pf-chat-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 360px;
    max-height: 540px;
    background: var(--card, #fff);
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid color-mix(in oklch, var(--foreground, #141414) 10%, transparent);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0.85) translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), opacity 0.18s ease;
}
#pf-chat-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ─────────────────────────────────────────────────── */
#pf-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--foreground, #141414);
    color: var(--background, #f9f8f5);
    flex-shrink: 0;
}
#pf-chat-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 9999px;
    background: color-mix(in oklch, var(--background, #f9f8f5) 15%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#pf-chat-header-avatar svg {
    width: 18px;
    height: 18px;
}
#pf-chat-header-info {
    flex: 1;
    min-width: 0;
}
#pf-chat-header-title {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.2;
}
#pf-chat-header-status {
    font-size: 11px;
    opacity: 0.6;
    display: flex;
    align-items: center;
    gap: 4px;
}
#pf-chat-header-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    background: #4ade80;
}
#pf-chat-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: opacity 0.15s;
}
#pf-chat-close:hover { opacity: 1; }

/* ── Mensajes ───────────────────────────────────────────────── */
#pf-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#pf-chat-messages::-webkit-scrollbar { width: 4px; }
#pf-chat-messages::-webkit-scrollbar-track { background: transparent; }
#pf-chat-messages::-webkit-scrollbar-thumb {
    background: color-mix(in oklch, var(--foreground, #141414) 15%, transparent);
    border-radius: 9999px;
}

.pf-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
    animation: pfMsgIn 0.2s ease;
}
@keyframes pfMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Mensaje del asistente */
.pf-msg.ai {
    align-self: flex-start;
    background: color-mix(in oklch, var(--foreground, #141414) 6%, transparent);
    color: var(--foreground, #141414);
    border-bottom-left-radius: 4px;
}

/* Mensaje del usuario */
.pf-msg.user {
    align-self: flex-end;
    background: var(--foreground, #141414);
    color: var(--background, #f9f8f5);
    border-bottom-right-radius: 4px;
}

/* Indicador "escribiendo..." */
.pf-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: color-mix(in oklch, var(--foreground, #141414) 6%, transparent);
    border-radius: 16px 16px 16px 4px;
}
.pf-typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    background: var(--muted-foreground, #888);
    animation: pfDot 1.2s infinite;
}
.pf-typing span:nth-child(2) { animation-delay: 0.2s; }
.pf-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pfDot {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40%            { transform: scale(1.1); opacity: 1; }
}

/* Comandos rápidos */
#pf-chat-commands {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 10px;
}
.pf-cmd-btn {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 9999px;
    border: 1px solid color-mix(in oklch, var(--foreground, #141414) 18%, transparent);
    background: none;
    color: var(--muted-foreground, #666);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.pf-cmd-btn:hover {
    background: var(--foreground, #141414);
    color: var(--background, #f9f8f5);
    border-color: var(--foreground, #141414);
}

/* ── Input ──────────────────────────────────────────────────── */
#pf-chat-footer {
    padding: 12px 14px;
    border-top: 1px solid color-mix(in oklch, var(--foreground, #141414) 8%, transparent);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: var(--card, #fff);
}
#pf-chat-input {
    flex: 1;
    border: 1px solid color-mix(in oklch, var(--foreground, #141414) 14%, transparent);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    background: var(--background, #f9f8f5);
    color: var(--foreground, #141414);
    min-height: 38px;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.15s;
}
#pf-chat-input::placeholder { color: var(--muted-foreground, #888); }
#pf-chat-input:focus {
    border-color: color-mix(in oklch, var(--foreground, #141414) 40%, transparent);
}
#pf-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--foreground, #141414);
    color: var(--background, #f9f8f5);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s, transform 0.15s;
    flex-shrink: 0;
}
#pf-chat-send:hover { opacity: 0.85; }
#pf-chat-send:active { transform: scale(0.93); }
#pf-chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
#pf-chat-send svg { width: 16px; height: 16px; pointer-events: none; }

/* ── Responsive móvil ───────────────────────────────────────── */
@media (max-width: 480px) {
    #pf-chat-panel {
        width: calc(100vw - 24px);
        right: 0;
        bottom: 68px;
        max-height: 70vh;
    }
    #pf-chat-widget {
        right: 16px;
        bottom: 16px;
    }
}
