/* Widget flotante tipo WhatsApp — compacto y por encima del panel Filament */

.chat-widget-floating {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 99999;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[dir="rtl"].chat-widget-floating {
    right: auto;
    left: 1rem;
}

.chat-widget-floating__trigger {
    position: relative;
}

.chat-button {
    position: relative;
    width: 3rem;
    height: 3rem;
    border-radius: 9999px;
    background-color: #059669;
    border: none;
    color: #ffffff;
    cursor: pointer;
    box-shadow:
        0 4px 16px rgba(5, 150, 105, 0.45),
        0 2px 6px rgba(0, 0, 0, 0.15);
    transition:
        background-color 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-button:hover {
    background-color: #047857;
    transform: translateY(-2px) scale(1.06);
    box-shadow:
        0 6px 20px rgba(5, 150, 105, 0.55),
        0 3px 8px rgba(0, 0, 0, 0.15);
}

.chat-button:hover .chat-icon {
    stroke: #ffffff;
}

.chat-button:focus-visible {
    outline: 2px solid #10b981;
    outline-offset: 3px;
}

.chat-button .chat-icon {
    width: 1.35rem;
    height: 1.35rem;
    stroke: #ffffff;
    color: #ffffff;
}

.dark .chat-button {
    background-color: #059669;
    border: none;
    color: #ffffff;
}

.dark .chat-button .chat-icon {
    stroke: #ffffff;
}

.message-badge {
    position: absolute;
    top: -0.2rem;
    right: -0.2rem;
    background-color: #dc2626;
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1;
    min-width: 1.1rem;
    height: 1.1rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.25rem;
    border: 2px solid #ffffff;
    pointer-events: none;
}

.chat-button[aria-expanded="true"] {
    background-color: #047857;
    box-shadow:
        0 6px 20px rgba(5, 150, 105, 0.55),
        0 2px 8px rgba(0, 0, 0, 0.15);
}

[dir="rtl"] .message-badge {
    right: auto;
    left: -0.2rem;
}

/* Panel compacto sobre la burbuja */
.chat-widget-panel {
    position: absolute;
    bottom: calc(100% + 0.65rem);
    right: 0;
    width: min(22rem, calc(100vw - 2rem));
    height: min(28rem, calc(100dvh - 5rem));
    background: #fff;
    border-radius: 0.875rem;
    border: 1px solid #e5e7eb;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.12),
        0 8px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

[dir="rtl"] .chat-widget-panel {
    right: auto;
    left: 0;
}

.chat-widget-panel[hidden] {
    display: none !important;
}

.chat-widget-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.65rem;
    background: #059669;
    color: #fff;
    flex-shrink: 0;
}

.chat-widget-panel__title {
    font-size: 0.875rem;
    font-weight: 600;
}

.chat-widget-panel__actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chat-widget-panel__expand,
.chat-widget-panel__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    font-size: 1.25rem;
    line-height: 1;
    transition: background-color 0.15s;
}

.chat-widget-panel__expand:hover,
.chat-widget-panel__close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.chat-widget-panel__frame {
    flex: 1;
    width: 100%;
    min-height: 0;
    border: 0;
    background: #f9fafb;
    overflow: hidden;
    display: block;
}

@media (max-width: 480px) {
    .chat-widget-floating {
        bottom: 0.75rem;
        right: 0.75rem;
    }

    .chat-widget-panel {
        width: calc(100vw - 1.5rem);
        height: min(24rem, calc(100dvh - 4.5rem));
    }
}

.dark .chat-widget-panel {
    background: #111827;
    border-color: #374151;
}

.dark .chat-widget-panel__frame {
    background: #030712;
}
