/* ── Chat Bubble Flotante ──────────────────────────── */

/* ── Container ────────────────────────────────────── */

.chat-bubble-container-chirho {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    font-family: system-ui, -apple-system, sans-serif;
}

/* ── Toggle Button ────────────────────────────────── */

.chat-bubble-btn-chirho {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #2563eb;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    position: relative;
}

.chat-bubble-btn-chirho:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
    background: #1d4ed8;
}

.chat-bubble-btn-chirho:active {
    transform: scale(0.95);
}

.chat-bubble-btn-chirho svg {
    width: 26px;
    height: 26px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-bubble-btn-chirho .icon-chat-chirho {
    opacity: 1;
    transform: scale(1);
}

.chat-bubble-btn-chirho .icon-close-chirho {
    position: absolute;
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
}

.chat-bubble-btn-chirho.open-chirho .icon-chat-chirho {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}

.chat-bubble-btn-chirho.open-chirho .icon-close-chirho {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* ── Badge notificacion ───────────────────────────── */

.chat-bubble-badge-chirho {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    transition: transform 0.2s ease;
}

.chat-bubble-badge-chirho:empty,
.chat-bubble-badge-chirho.hidden-chirho {
    display: none;
}

.dark .chat-bubble-badge-chirho {
    border-color: #1f2937;
}

/* ── Pulse animation on new message ───────────────── */

@keyframes chat-pulse-chirho {
    0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5); }
    70%  { box-shadow: 0 0 0 12px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.chat-bubble-btn-chirho.pulse-chirho {
    animation: chat-pulse-chirho 1.5s ease-out 3;
}

/* ── Chat Panel ───────────────────────────────────── */

.chat-panel-chirho {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 370px;
    max-height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.chat-panel-chirho.open-chirho {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.dark .chat-panel-chirho {
    background: #1f2937;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* ── Panel Header ─────────────────────────────────── */

.chat-header-chirho {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: #2563eb;
    color: white;
    flex-shrink: 0;
}

.chat-header-title-chirho {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-header-title-chirho h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
}

.chat-header-title-chirho .status-dot-chirho {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
}

.chat-header-subtitle-chirho {
    font-size: 0.75rem;
    opacity: 0.85;
    margin: 0;
}

.chat-header-close-chirho {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header-close-chirho:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-header-close-chirho svg {
    width: 18px;
    height: 18px;
}

/* ── Messages Area ────────────────────────────────── */

.chat-messages-chirho {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 280px;
    max-height: 340px;
}

.chat-messages-chirho::-webkit-scrollbar {
    width: 5px;
}

.chat-messages-chirho::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages-chirho::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.dark .chat-messages-chirho::-webkit-scrollbar-thumb {
    background: #4b5563;
}

/* ── Message Bubbles ──────────────────────────────── */

.chat-msg-chirho {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: msg-appear-chirho 0.25s ease;
}

@keyframes msg-appear-chirho {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-msg-chirho.incoming-chirho {
    align-self: flex-start;
}

.chat-msg-chirho.outgoing-chirho {
    align-self: flex-end;
}

.chat-msg-bubble-chirho {
    padding: 0.625rem 0.875rem;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.incoming-chirho .chat-msg-bubble-chirho {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.outgoing-chirho .chat-msg-bubble-chirho {
    background: #2563eb;
    color: white;
    border-bottom-right-radius: 4px;
}

.dark .incoming-chirho .chat-msg-bubble-chirho {
    background: #374151;
    color: #f3f4f6;
}

.chat-msg-time-chirho {
    font-size: 0.65rem;
    color: #9ca3af;
    margin-top: 0.2rem;
    padding: 0 0.25rem;
}

.outgoing-chirho .chat-msg-time-chirho {
    text-align: right;
}

.dark .chat-msg-time-chirho {
    color: #6b7280;
}

/* ── Typing Indicator ─────────────────────────────── */

.chat-typing-chirho {
    display: none;
    align-self: flex-start;
    padding: 0.625rem 0.875rem;
    background: #f3f4f6;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    gap: 4px;
    align-items: center;
}

.chat-typing-chirho.visible-chirho {
    display: flex;
}

.dark .chat-typing-chirho {
    background: #374151;
}

.typing-dot-chirho {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing-bounce-chirho 1.2s ease-in-out infinite;
}

.typing-dot-chirho:nth-child(2) { animation-delay: 0.15s; }
.typing-dot-chirho:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce-chirho {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-4px); }
}

/* ── Input Area ───────────────────────────────────── */

.chat-input-area-chirho {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e5e7eb;
    background: white;
    flex-shrink: 0;
}

.dark .chat-input-area-chirho {
    border-top-color: #374151;
    background: #1f2937;
}

.chat-input-chirho {
    flex: 1;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.4;
    max-height: 100px;
    outline: none;
    transition: border-color 0.15s ease;
    background: #f9fafb;
    color: #1f2937;
}

.chat-input-chirho:focus {
    border-color: #2563eb;
    background: white;
}

.dark .chat-input-chirho {
    background: #111827;
    border-color: #4b5563;
    color: #f3f4f6;
}

.dark .chat-input-chirho:focus {
    border-color: #3b82f6;
    background: #1f2937;
}

.chat-input-chirho::placeholder {
    color: #9ca3af;
}

.chat-send-btn-chirho {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #2563eb;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.15s ease;
}

.chat-send-btn-chirho:hover {
    background: #1d4ed8;
}

.chat-send-btn-chirho:active {
    transform: scale(0.92);
}

.chat-send-btn-chirho:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

.dark .chat-send-btn-chirho:disabled {
    background: #1e40af;
    opacity: 0.5;
}

.chat-send-btn-chirho svg {
    width: 18px;
    height: 18px;
}

/* ── Welcome state ────────────────────────────────── */

.chat-welcome-chirho {
    text-align: center;
    padding: 2rem 1.5rem;
    color: #6b7280;
}

.chat-welcome-chirho .welcome-icon-chirho {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.75rem;
    background: #eff6ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dark .chat-welcome-chirho .welcome-icon-chirho {
    background: #1e3a5f;
}

.chat-welcome-chirho .welcome-icon-chirho svg {
    width: 24px;
    height: 24px;
    color: #2563eb;
}

.chat-welcome-chirho h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.35rem;
}

.dark .chat-welcome-chirho h4 {
    color: #f3f4f6;
}

.chat-welcome-chirho p {
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 0;
}

.dark .chat-welcome-chirho p {
    color: #9ca3af;
}

/* ── Quick Actions ────────────────────────────────── */

.chat-quick-actions-chirho {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1rem 0.75rem;
}

.chat-quick-btn-chirho {
    font-size: 0.75rem;
    padding: 0.35rem 0.75rem;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.chat-quick-btn-chirho:hover {
    background: #eff6ff;
    border-color: #2563eb;
    color: #2563eb;
}

.dark .chat-quick-btn-chirho {
    background: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}

.dark .chat-quick-btn-chirho:hover {
    background: #1e3a5f;
    border-color: #3b82f6;
    color: #93c5fd;
}

/* ── Mobile responsive ────────────────────────────── */

@media (max-width: 480px) {
    .chat-bubble-container-chirho {
        bottom: 1rem;
        right: 1rem;
    }

    .chat-panel-chirho {
        width: calc(100vw - 2rem);
        max-height: calc(100vh - 8rem);
        right: 0;
        bottom: 66px;
    }

    .chat-messages-chirho {
        min-height: 200px;
        max-height: calc(100vh - 16rem);
    }
}
