/**
 * BlijfBewust - Alerta Chatbot Widget Styles
 * Modern design met speech bubble en streaming effect
 * Senior-friendly met custom avatar
 */

/* ==========================================
   CSS VARIABELEN
   ========================================== */
:root {
    --alerta-primary: #118eec;
    --alerta-primary-dark: #0d6ebd;
    --alerta-primary-light: #e8f4fd;
    --alerta-gradient: linear-gradient(135deg, #118eec 0%, #4dabf5 100%);
    --alerta-shadow: 0 8px 32px rgba(17, 142, 236, 0.25);
    --alerta-shadow-lg: 0 12px 48px rgba(17, 142, 236, 0.3);
    --alerta-radius: 24px;
}

/* ==========================================
   CHATBOT TRIGGER BUTTON (Rechtsonder)
   ========================================== */
.alerta-chat-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--alerta-gradient);
    color: white;
    border: none;
    border-radius: 60px;
    padding: 8px 24px 8px 8px;
    cursor: pointer;
    box-shadow: var(--alerta-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-body, 'Nunito', system-ui, sans-serif);
    font-size: 1rem;
    font-weight: 700;
}

.alerta-chat-trigger:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--alerta-shadow-lg);
}

.alerta-chat-trigger:active {
    transform: translateY(-2px) scale(1.01);
}

.alerta-chat-trigger-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 4px;
    box-sizing: border-box;
}

.alerta-chat-trigger-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.alerta-chat-trigger-text {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.25;
}

.alerta-chat-trigger-name {
    font-size: 1.2rem;
    font-weight: 800;
}

/* Pulse animation */
.alerta-chat-trigger.pulse {
    animation: alerta-pulse 2.5s infinite;
}

@keyframes alerta-pulse {
    0%, 100% {
        box-shadow: var(--alerta-shadow);
    }
    50% {
        box-shadow: var(--alerta-shadow-lg), 0 0 0 12px rgba(17, 142, 236, 0.1);
    }
}

/* Kleine schermen */
@media (max-width: 420px) {
    .alerta-chat-trigger {
        padding: 6px 20px 6px 6px;
        gap: 10px;
    }
    
    .alerta-chat-trigger-avatar {
        width: 42px;
        height: 42px;
    }
    
    .alerta-chat-trigger-name {
        font-size: 1.1rem;
    }
}

/* ==========================================
   WELKOMST SPEECH BUBBLE
   ========================================== */
.alerta-welcome-bubble {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 9997;
    background: white;
    border-radius: 20px 20px 4px 20px;
    padding: 0;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    max-width: 340px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.9);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.alerta-welcome-bubble.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Speech bubble tail */
.alerta-welcome-bubble::after {
    content: '';
    position: absolute;
    bottom: -14px;
    right: 30px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 14px 14px 0 0;
    border-color: white transparent transparent transparent;
    filter: drop-shadow(2px 4px 3px rgba(0, 0, 0, 0.1));
}

.alerta-welcome-inner {
    padding: 20px;
}

.alerta-welcome-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.alerta-welcome-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 4px;
    box-sizing: border-box;
    border: 3px solid var(--alerta-primary-light);
    box-shadow: 0 4px 12px rgba(17, 142, 236, 0.2);
}

.alerta-welcome-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.alerta-welcome-info h4 {
    font-size: 1.25rem;
    font-weight: 800;
    color: #1e293b;
    margin: 0;
}

.alerta-welcome-text {
    font-size: 1rem;
    color: #475569;
    line-height: 1.55;
    margin-bottom: 16px;
}

.alerta-welcome-text strong {
    color: var(--alerta-primary);
}

/* Typing indicator in welcome bubble */
.alerta-welcome-typing {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    color: #94a3b8;
    font-size: 0.9rem;
}

.alerta-welcome-typing-dots {
    display: flex;
    gap: 3px;
}

.alerta-welcome-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--alerta-primary);
    border-radius: 50%;
    animation: alerta-typing-bounce 1.4s infinite ease-in-out both;
}

.alerta-welcome-typing-dot:nth-child(1) { animation-delay: 0s; }
.alerta-welcome-typing-dot:nth-child(2) { animation-delay: 0.16s; }
.alerta-welcome-typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes alerta-typing-bounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1.2); opacity: 1; }
}

.alerta-welcome-cta {
    display: block;
    width: 100%;
    background: var(--alerta-gradient);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
}

.alerta-welcome-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(17, 142, 236, 0.35);
}

.alerta-welcome-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #64748b;
    transition: all 0.2s ease;
    z-index: 2;
}

.alerta-welcome-close:hover {
    background: #e2e8f0;
    color: #334155;
    transform: rotate(90deg);
}

/* Mobile speech bubble */
@media (max-width: 500px) {
    .alerta-welcome-bubble {
        bottom: 85px;
        right: 16px;
        left: 16px;
        max-width: none;
    }
    
    .alerta-welcome-bubble::after {
        right: 45px;
    }
}

/* ==========================================
   CHATBOT WINDOW OVERLAY - VERWIJDERD
   Geen overlay meer voor betere toegankelijkheid
   ========================================== */
.alerta-chat-overlay {
    display: none !important;
}

/* ==========================================
   CHATBOT WINDOW
   ========================================== */
.alerta-chat-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 48px);
    background: #f8fafc;
    border-radius: var(--alerta-radius);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(40px) scale(0.92);
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.alerta-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Mobile fullscreen */
@media (max-width: 500px) {
    .alerta-chat-window {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .alerta-chat-trigger {
        bottom: 16px;
        right: 16px;
    }
}

/* ==========================================
   CHATBOT HEADER
   ========================================== */
.alerta-chat-header {
    background: var(--alerta-gradient);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.alerta-chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 4px;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.alerta-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.alerta-chat-info {
    flex: 1;
    min-width: 0;
}

.alerta-chat-name {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 0 0 2px 0;
    font-family: var(--font-heading, Georgia, serif);
}

.alerta-chat-subtitle {
    font-size: 0.85rem;
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 6px;
}

.alerta-status-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
}

.alerta-status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: alerta-status-glow 2s infinite;
}

@keyframes alerta-status-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); }
    50% { box-shadow: 0 0 0 4px rgba(74, 222, 128, 0); }
}

.alerta-chat-close {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.alerta-chat-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

/* ==========================================
   CHATBOT MESSAGES AREA
   ========================================== */
.alerta-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Scrollbar */
.alerta-chat-messages::-webkit-scrollbar {
    width: 5px;
}

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

.alerta-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.alerta-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==========================================
   MESSAGE BUBBLES
   ========================================== */
.alerta-message {
    display: flex;
    gap: 10px;
    max-width: 88%;
    animation: alerta-message-appear 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes alerta-message-appear {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* User message - rechts */
.alerta-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* Bot message - links */
.alerta-message.assistant {
    align-self: flex-start;
}

.alerta-message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 3px;
    box-sizing: border-box;
}

.alerta-message.assistant .alerta-message-avatar {
    border: 2px solid var(--alerta-primary-light);
    box-shadow: 0 2px 8px rgba(17, 142, 236, 0.15);
}

.alerta-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.alerta-message.user .alerta-message-avatar {
    background: #e2e8f0;
    border: none;
    padding: 0;
    font-size: 1.1rem;
}

.alerta-message-content {
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

.alerta-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.98rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.alerta-message.assistant .alerta-message-bubble {
    background: white;
    color: #1e293b;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.alerta-message.user .alerta-message-bubble {
    background: var(--alerta-gradient);
    color: white;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 12px rgba(17, 142, 236, 0.25);
}

/* Formatting in messages */
.alerta-message-bubble strong {
    font-weight: 700;
}

.alerta-message-bubble em {
    font-style: italic;
}

.alerta-message-bubble ul {
    margin: 8px 0;
    padding-left: 18px;
}

.alerta-message-bubble li {
    margin: 4px 0;
}

/* Timestamp */
.alerta-message-time {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 4px;
    padding: 0 4px;
}

.alerta-message.user .alerta-message-time {
    text-align: left;
}

.alerta-message.assistant .alerta-message-time {
    text-align: right;
}

/* Streaming cursor */
.alerta-streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--alerta-primary);
    margin-left: 2px;
    animation: alerta-cursor-blink 0.8s infinite;
    vertical-align: text-bottom;
}

@keyframes alerta-cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ==========================================
   TYPING INDICATOR
   ========================================== */
.alerta-typing-indicator {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    align-self: flex-start;
}

.alerta-typing-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    box-sizing: border-box;
    border: 2px solid var(--alerta-primary-light);
    box-shadow: 0 2px 8px rgba(17, 142, 236, 0.15);
}

.alerta-typing-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.alerta-typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
    background: white;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.alerta-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--alerta-primary);
    border-radius: 50%;
    animation: alerta-typing-wave 1.4s infinite ease-in-out;
}

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

@keyframes alerta-typing-wave {
    0%, 60%, 100% { 
        transform: translateY(0);
        opacity: 0.5;
    }
    30% { 
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ==========================================
   WELCOME MESSAGE IN CHAT
   ========================================== */
.alerta-welcome {
    text-align: center;
    padding: 24px 16px;
}

.alerta-welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    padding: 6px;
    box-sizing: border-box;
    border: 4px solid var(--alerta-primary-light);
    box-shadow: 0 8px 24px rgba(17, 142, 236, 0.2);
}

.alerta-welcome-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.alerta-welcome-title {
    font-family: var(--font-heading, Georgia, serif);
    font-size: 1.35rem;
    color: #1e293b;
    margin-bottom: 6px;
}

.alerta-welcome-intro {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--alerta-primary-light);
    color: var(--alerta-primary);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.alerta-welcome .alerta-welcome-text {
    color: #64748b;
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 20px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

/* Suggestion chips */
.alerta-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.alerta-suggestion-chip {
    background: white;
    border: 2px solid var(--alerta-primary);
    color: var(--alerta-primary);
    padding: 10px 16px;
    border-radius: 24px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 6px rgba(17, 142, 236, 0.1);
}

.alerta-suggestion-chip:hover {
    background: var(--alerta-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(17, 142, 236, 0.25);
}

/* ==========================================
   INPUT AREA
   ========================================== */
.alerta-chat-input-area {
    padding: 14px 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.alerta-chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: #f1f5f9;
    border-radius: 28px;
    padding: 6px 6px 6px 18px;
    transition: all 0.2s ease;
}

.alerta-chat-input-wrapper:focus-within {
    background: #e8f4fd;
    box-shadow: 0 0 0 3px rgba(17, 142, 236, 0.15);
}

.alerta-chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 0;
    border: none;
    background: transparent;
    font-family: var(--font-body, 'Nunito', system-ui, sans-serif);
    font-size: 0.98rem;
    resize: none;
    outline: none;
    line-height: 1.4;
    color: #1e293b;
}

.alerta-chat-input::placeholder {
    color: #94a3b8;
}

.alerta-chat-send {
    width: 44px;
    height: 44px;
    background: var(--alerta-gradient);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.alerta-chat-send:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(17, 142, 236, 0.35);
}

.alerta-chat-send:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.alerta-chat-send svg {
    width: 20px;
    height: 20px;
}

/* Character counter */
.alerta-char-counter {
    font-size: 0.72rem;
    color: #94a3b8;
    text-align: right;
    margin-top: 6px;
    padding-right: 8px;
}

.alerta-char-counter.warning {
    color: #f59e0b;
}

.alerta-char-counter.danger {
    color: #ef4444;
}

/* ==========================================
   FOOTER
   ========================================== */
.alerta-chat-footer {
    padding: 10px 16px;
    background: #f1f5f9;
    text-align: center;
    font-size: 0.72rem;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
}

.alerta-chat-footer a {
    color: var(--alerta-primary);
    text-decoration: none;
    font-weight: 600;
}

.alerta-chat-footer a:hover {
    text-decoration: underline;
}

/* ==========================================
   ERROR STATE
   ========================================== */
.alerta-error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 12px;
    margin: 8px 0;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: alerta-shake 0.4s ease;
}

@keyframes alerta-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

.alerta-error-icon {
    font-size: 1.2rem;
}

/* ==========================================
   FEEDBACK BUTTONS
   ========================================== */
.alerta-message-feedback {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.alerta-message:hover .alerta-message-feedback {
    opacity: 1;
}

.alerta-feedback-btn {
    width: 28px;
    height: 28px;
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.alerta-feedback-btn:hover {
    background: var(--alerta-primary-light);
    transform: scale(1.1);
}

.alerta-feedback-btn.active.positive {
    background: #dcfce7;
    color: #16a34a;
}

.alerta-feedback-btn.active.negative {
    background: #fef2f2;
    color: #dc2626;
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */
.alerta-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus states */
.alerta-chat-trigger:focus-visible,
.alerta-chat-close:focus-visible,
.alerta-chat-send:focus-visible,
.alerta-suggestion-chip:focus-visible,
.alerta-chat-input:focus-visible,
.alerta-welcome-cta:focus-visible {
    outline: 3px solid var(--alerta-primary);
    outline-offset: 3px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .alerta-chat-trigger,
    .alerta-chat-window,
    .alerta-message,
    .alerta-typing-dot,
    .alerta-welcome-bubble,
    .alerta-streaming-cursor {
        animation: none !important;
        transition: opacity 0.2s ease !important;
    }
}

/* High contrast */
@media (prefers-contrast: high) {
    .alerta-message.assistant .alerta-message-bubble {
        border: 2px solid #333;
    }
    
    .alerta-chat-input-wrapper {
        border: 2px solid #333;
    }
}
