/* Voorkomt FOUC — Alpine.js verwijdert x-cloak na initialisatie */
[x-cloak] { display: none !important; }

/* =======================================================================
   SANDRA CHAT WIDGET — Rechtfabriek publieke chatbot
   Gebaseerd op Mira's floating_chat.html structuur, aangepast met RF-huisstijl.
   ======================================================================= */

/* Container — rechtsonder fixed */
.rf-sandra-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* =======================================================================
   FAB — avatar expandeert naar pill
   ======================================================================= */
.rf-sandra__fab {
    position: relative;
    display: flex;
    align-items: center;
}

.rf-sandra__fab-btn {
    display: flex;
    align-items: center;
    gap: 0;
    height: 88px;
    border-radius: 44px;
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0;
    overflow: visible;
    position: relative;
    box-shadow: 0 4px 24px rgba(189, 30, 16, 0.2);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    color: var(--rf-red, #BD1E10);
    width: 88px;
    box-sizing: border-box;
}

/* Expanded — pill-vorm */
.rf-sandra__fab--expanded .rf-sandra__fab-btn {
    width: auto;
    padding-right: 40px;
    gap: 12px;
    border: 3px solid var(--rf-red, #BD1E10);
    background: #fff;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(189, 30, 16, 0.25);
}

.rf-sandra__fab-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 32px rgba(189, 30, 16, 0.3);
}

.rf-sandra__fab:not(.rf-sandra__fab--expanded) .rf-sandra__fab-btn {
    justify-content: center;
}

/* Avatar cirkel */
.rf-sandra__avatar {
    width: 88px;
    height: 88px;
    border: 3px solid var(--rf-red, #BD1E10);
    box-sizing: border-box;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--rf-red, #BD1E10);
}

.rf-sandra__fab--expanded .rf-sandra__avatar {
    width: 82px;
    height: 82px;
    border: 0;
}

.rf-sandra__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Sluit-icon als chat open is */
.rf-sandra__close-icon {
    margin: auto;
}

/* Tekst in pill */
.rf-sandra__fab-text {
    font-size: 0.875rem;
    color: var(--rf-dark, #1c1f2b);
    white-space: nowrap;
    line-height: 1.4;
    font-family: inherit;
}

.rf-sandra__fab-text strong {
    color: var(--rf-red, #BD1E10);
    font-weight: 600;
}

/* Pulse ring rondom avatar */
.rf-sandra__pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--rf-red, #BD1E10);
    animation: sandraFabPulse 2.5s ease-in-out infinite;
    pointer-events: none;
}

/* Dismiss-knop (rechtsboven op pill) */
.rf-sandra__fab-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #e7e5e4;
    background: #fff;
    cursor: pointer;
    font-size: 0.875rem;
    color: #78716c;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5;
    line-height: 1;
    padding: 0;
}

.rf-sandra__fab-close:hover {
    background: #f5f5f4;
    color: var(--rf-dark, #1c1f2b);
    border-color: #78716c;
}

/* =======================================================================
   CHAT WINDOW
   ======================================================================= */
.rf-sandra__window {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    width: 420px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 16px 64px rgba(28, 31, 43, 0.15);
    border: 1px solid #e7e5e4;
    display: flex;
    flex-direction: column;
    font-family: inherit;
}

/* Header */
.rf-sandra__header {
    background: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: 1px solid #e7e5e4;
    border-radius: 16px 16px 0 0;
    overflow: visible;
    position: relative;
}

.rf-sandra__header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rf-sandra__header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--rf-red, #BD1E10);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s ease;
    transform-origin: center center;
    position: relative;
    z-index: 1;
}

.rf-sandra__header-avatar:hover {
    transform: scale(4);
    z-index: 500;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.rf-sandra__header-name {
    font-weight: 600;
    color: var(--rf-dark, #1c1f2b);
    font-size: 0.875rem;
    margin: 0;
}

.rf-sandra__header-status {
    font-size: 0.75rem;
    color: var(--rf-red, #BD1E10);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.rf-sandra__header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--rf-red, #BD1E10);
    display: inline-block;
    animation: sandraStatusPulse 1.5s ease-in-out infinite;
}

.rf-sandra__header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.rf-sandra__header-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f5f5f4;
    border: none;
    cursor: pointer;
    color: #78716c;
    padding: 4px;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rf-sandra__header-btn:hover {
    background: #e7e5e4;
    color: var(--rf-dark, #1c1f2b);
}

/* Berichten area */
.rf-sandra__messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #fafaf9;
}

.rf-sandra__msg {
    margin-bottom: 16px;
}

.rf-sandra__msg-author {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--rf-red, #BD1E10);
    margin: 0 0 4px 0;
}

.rf-sandra__msg-text {
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 0;
    color: var(--rf-dark, #1c1f2b);
}

/* Berichtbubbles */
.rf-sandra__bubble--assistant {
    background: #fff;
    border: 1px solid #e7e5e4;
    border-radius: 12px 12px 12px 2px;
    padding: 12px 16px;
    max-width: 320px;
}

.rf-sandra__bubble--user {
    background: #fdf2f2;
    border: 1px solid #f5c6c3;
    border-radius: 12px 12px 2px 12px;
    padding: 12px 16px;
    max-width: 320px;
    margin-left: auto;
}

.rf-sandra__bubble--user .rf-sandra__msg-author {
    color: var(--rf-dark, #1c1f2b);
}

.rf-sandra__msg--animate {
    animation: sandraFadeInUp 0.3s ease-out;
}

/* =======================================================================
   AGENT CARDS
   ======================================================================= */
.rf-sandra__agent-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #fff;
    border: 2px solid var(--rf-red, #BD1E10);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    font-family: inherit;
    width: 100%;
    margin-top: 8px;
    transition: background 0.2s;
}

.rf-sandra__agent-card:hover {
    background: #fdf2f2;
}

.rf-sandra__agent-card img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.rf-sandra__agent-card strong {
    display: block;
    font-size: 0.875rem;
    color: var(--rf-dark, #1c1f2b);
}

.rf-sandra__agent-card span {
    font-size: 0.75rem;
    color: var(--rf-red, #BD1E10);
}

.rf-sandra__registration-card {
    display: inline-block;
    margin-top: 8px;
    padding: 8px 16px;
    background: var(--rf-red, #BD1E10);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s;
}

.rf-sandra__registration-card:hover {
    background: #9e1a0e;
    color: #fff;
}

/* =======================================================================
   INVOER AREA
   ======================================================================= */
.rf-sandra__input-area {
    padding: 16px;
    border-top: 1px solid #e7e5e4;
    background: #fff;
    flex-shrink: 0;
    border-radius: 0 0 16px 16px;
}

.rf-sandra__form {
    display: flex;
    gap: 8px;
}

.rf-sandra-widget .rf-sandra__input,
.rf-sandra-widget form input.rf-sandra__input {
    flex: 1;
    background: #f5f5f4;
    color: var(--rf-dark, #1c1f2b);
    border: 1px solid #e7e5e4;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.rf-sandra-widget .rf-sandra__input::placeholder,
.rf-sandra-widget form input.rf-sandra__input::placeholder {
    color: #a8a29e;
}

.rf-sandra-widget .rf-sandra__input:focus,
.rf-sandra-widget form input.rf-sandra__input:focus {
    border-color: var(--rf-red, #BD1E10);
    background: #fff;
}

.rf-sandra__send-btn {
    background: var(--rf-green, #61CE70);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    white-space: nowrap;
}

.rf-sandra__send-btn:hover {
    background: var(--rf-dark, #1c1f2b);
}

/* Typing indicator */
.rf-sandra__typing {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.75rem;
    color: #78716c;
}

.rf-sandra__typing-dots {
    display: flex;
    gap: 3px;
}

.rf-sandra__typing-dots span {
    width: 6px;
    height: 6px;
    background: #a8a29e;
    border-radius: 50%;
    animation: sandraTypingBounce 1.2s ease-in-out infinite;
}

.rf-sandra__typing-dots span:nth-child(2) { animation-delay: 0.1s; }
.rf-sandra__typing-dots span:nth-child(3) { animation-delay: 0.2s; }

/* =======================================================================
   ANIMATIES
   ======================================================================= */
@keyframes sandraFabPulse {
    0%, 100% { opacity: 0; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.15); }
}

@keyframes sandraStatusPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@keyframes sandraFadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* =======================================================================
   RESPONSIVE
   ======================================================================= */
@media (max-width: 768px) {
    .rf-sandra__header-avatar:hover {
        transform: scale(2.5);
    }
}

@media (max-width: 480px) {
    .rf-sandra-widget {
        bottom: 16px;
        right: 16px;
    }

    .rf-sandra__fab-btn {
        width: 68px;
        height: 68px;
        border-radius: 34px;
    }

    .rf-sandra__avatar {
        width: 68px;
        height: 68px;
    }

    .rf-sandra__fab--expanded .rf-sandra__avatar {
        width: 62px;
        height: 62px;
    }

    .rf-sandra__fab--expanded .rf-sandra__fab-btn {
        max-width: calc(100vw - 48px);
    }

    .rf-sandra__fab-text {
        font-size: 0.8125rem;
    }

    .rf-sandra__window {
        width: calc(100vw - 16px);
        right: -8px;
        height: auto;
        max-height: calc(100vh - 140px);
        min-height: 360px;
        border-radius: 16px;
    }

    .rf-sandra__header {
        padding: 12px 16px;
    }

    .rf-sandra__header-avatar {
        width: 38px;
        height: 38px;
    }

    .rf-sandra__header-avatar:hover {
        transform: scale(1.8);
    }

    .rf-sandra__messages {
        padding: 12px;
        max-height: 50vh;
    }

    .rf-sandra__bubble--assistant,
    .rf-sandra__bubble--user {
        max-width: 85%;
    }

    .rf-sandra__input-area {
        padding: 12px;
    }

    .rf-sandra__send-btn span {
        display: none;
    }

    .rf-sandra__send-btn {
        padding: 10px 12px;
    }
}
