/* InnovaLaw — Chat Bubble Widget
   Aligned with design system tokens: #A20000 primary, Public Sans, Tabler Icons. */

.chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1040;
    font-family: "Public Sans", sans-serif;
}

/* --- Floating launcher button (FAB) --- */
.chat-bubble-fab {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 0;
    background: #A20000;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(162, 0, 0, 0.35);
    transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-bubble-fab:hover {
    background: #cc0000;
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(162, 0, 0, 0.45);
}

.chat-bubble-fab:focus-visible {
    outline: 3px solid rgba(162, 0, 0, 0.35);
    outline-offset: 3px;
}

.chat-bubble-fab-icon {
    font-size: 28px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 150ms ease, transform 200ms ease;
}

.chat-bubble-fab-icon--close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg);
}

.chat-bubble.is-open .chat-bubble-fab-icon--open {
    opacity: 0;
    transform: rotate(90deg);
}

.chat-bubble.is-open .chat-bubble-fab-icon--close {
    opacity: 1;
    transform: rotate(0);
}

/* Badge "1" — visible only first visit */
.chat-bubble-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #fff;
    color: #A20000;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    display: none;
}

.chat-bubble.is-new .chat-bubble-badge {
    display: block;
    animation: chat-bubble-pulse 1.6s ease-in-out infinite;
}

.chat-bubble.is-open .chat-bubble-badge,
.chat-bubble.is-seen .chat-bubble-badge {
    display: none;
}

@keyframes chat-bubble-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* --- Panel --- */
.chat-bubble-panel {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 32px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    transform-origin: bottom right;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    transition: opacity 200ms ease, transform 200ms ease;
    pointer-events: none;
}

.chat-bubble-panel[hidden] {
    display: none;
}

.chat-bubble.is-open .chat-bubble-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* --- Header --- */
.chat-bubble-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 16px 18px;
    background: linear-gradient(135deg, #A20000 0%, #cc0000 100%);
    color: #fff;
}

.chat-bubble-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chat-bubble-avatar img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.chat-bubble-header-info {
    flex: 1;
    min-width: 0;
}

.chat-bubble-header-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

.chat-bubble-header-status {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.92;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.chat-bubble-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
    animation: chat-bubble-dot 2s ease-in-out infinite;
}

@keyframes chat-bubble-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
}

.chat-bubble-close {
    background: rgba(255, 255, 255, 0.15);
    border: 0;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms ease;
    flex-shrink: 0;
}

.chat-bubble-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.chat-bubble-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.chat-bubble-close i {
    font-size: 18px;
}

/* --- Body --- */
.chat-bubble-panel-body {
    padding: 18px;
    max-height: 60vh;
    overflow-y: auto;
}

.chat-bubble-message {
    background: #f1f0f2;
    border-radius: 12px;
    border-top-left-radius: 4px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.chat-bubble-message-greeting {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
    color: #2a2a2a;
}

.chat-bubble-message-subtitle {
    margin: 0;
    font-size: 13px;
    color: #565360;
    line-height: 1.4;
}

/* --- Actions --- */
.chat-bubble-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-bubble-action {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 10px;
    border: 1px solid #e7e7ea;
    background: #fff;
    color: #2a2a2a;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: left;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
    width: 100%;
    font-family: inherit;
}

.chat-bubble-action:hover {
    background: #fff5f5;
    border-color: #A20000;
    color: #A20000;
    transform: translateX(2px);
}

.chat-bubble-action:focus-visible {
    outline: 2px solid #A20000;
    outline-offset: 2px;
}

.chat-bubble-action i {
    font-size: 18px;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

.chat-bubble-action--primary {
    background: #A20000;
    border-color: #A20000;
    color: #fff;
}

.chat-bubble-action--primary:hover {
    background: #cc0000;
    border-color: #cc0000;
    color: #fff;
}

.chat-bubble-action--whatsapp:hover {
    background: #e6f7ed;
    border-color: #25d366;
    color: #128c3e;
}

/* --- Mobile --- */
@media (max-width: 575.98px) {
    .chat-bubble {
        bottom: 16px;
        right: 16px;
    }

    .chat-bubble-fab {
        width: 56px;
        height: 56px;
    }

    .chat-bubble-fab-icon {
        font-size: 26px;
    }

    .chat-bubble-panel {
        position: fixed;
        bottom: 84px;
        right: 16px;
        left: 16px;
        width: auto;
        max-width: none;
    }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    .chat-bubble-fab,
    .chat-bubble-fab-icon,
    .chat-bubble-panel,
    .chat-bubble-action,
    .chat-bubble-badge,
    .chat-bubble-status-dot {
        transition: none;
        animation: none;
    }
}
