/* ClubCore Assistant — Chat Widget v0.2.2
   CSS custom properties voor theming via wp_add_inline_style()
*/
:root {
    --cca-primary:       #1a472a;
    --cca-primary-hover: #0f3019;
    --cca-radius:        12px;
    --cca-font:          inherit;
}

/* ===== Widget wrapper ===== */
.cca-widget {
    font-family: var(--cca-font);
    font-size: 14px;
    max-width: 520px;
    border-radius: var(--cca-radius);
    /* v0.6.8: overflow visible zodat het 3-punten menu niet afgesneden wordt.
       Ronde hoeken worden op de individuele secties afgehandeld. */
    overflow: visible;
    box-shadow: 0 4px 20px rgba(0,0,0,0.13);
    background: #fff;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0,0,0,0.08);
}

/* ===== Header (Bol.com stijl) ===== */
.cca-header {
    background: var(--cca-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--cca-font);
    position: relative;
    /* v0.6.8: ronde bovenhoeken nu op header i.p.v. widget (overflow: visible) */
    border-radius: var(--cca-radius) var(--cca-radius) 0 0;
}

/* Avatar rond */
.cca-header-avatar {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.3);
}
.cca-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.cca-avatar-emoji { font-size: 22px; line-height: 1; }

/* Naam + status */
.cca-header-info { flex: 1; min-width: 0; }
.cca-header-name {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cca-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
    font-size: 12px;
    opacity: 0.9;
}
.cca-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4cff72;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(76,255,114,0.3);
}
.cca-thinking-text { font-style: italic; }

/* ===== Drie-puntjes menu ===== */
.cca-menu-wrap { position: relative; flex-shrink: 0; }
.cca-menu-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    padding: 0;
}
.cca-menu-btn:hover { background: rgba(255,255,255,0.28); }

.cca-menu-dropdown {
    /* v0.6.9: fixed positioning — ontsnapt aan alle overflow:hidden/clip van parents */
    position: fixed;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.14);
    min-width: 220px;
    z-index: 999999;
    overflow: hidden;
    animation: ccaDropIn 0.12s ease;
}
@keyframes ccaDropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cca-menu-dropdown[hidden] { display: none; }
.cca-menu-item {
    width: 100%;
    background: none;
    border: none;
    padding: 11px 16px;
    text-align: left;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--cca-font);
    transition: background 0.1s;
}
.cca-menu-item:hover { background: #f5f5f5; }
.cca-menu-item--danger { color: #c62828; }
.cca-menu-item--danger:hover { background: #fff5f5; }

/* ===== Messages ===== */
.cca-messages {
    padding: 16px;
    min-height: 200px;
    max-height: 360px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f7f8;
    font-family: var(--cca-font);
}
.cca-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: calc(var(--cca-radius) + 4px);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    font-family: var(--cca-font);
}
.cca-message.bot {
    background: #fff;
    border: 1px solid #e4e4e4;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.cca-message.user {
    background: var(--cca-primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.cca-message.typing {
    background: #fff;
    border: 1px solid #e4e4e4;
    align-self: flex-start;
    color: #888;
    font-style: italic;
}
.cca-dots-wrap { display: flex; gap: 4px; align-items: center; padding: 10px 14px; }
.cca-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #aaa;
    animation: ccaDot 1.2s infinite ease-in-out;
}
.cca-dot:nth-child(2) { animation-delay: 0.2s; }
.cca-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ccaDot {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40%            { transform: scale(1.1); opacity: 1; }
}

/* Escalate */
.cca-escalate-row { margin-top: 6px; align-self: flex-start; }
.cca-escalate-btn {
    background: none;
    border: 1px solid var(--cca-primary);
    color: var(--cca-primary);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--cca-font);
}
.cca-escalate-btn:hover { background: var(--cca-primary); color: #fff; }
.cca-escalate-sent { font-size: 12px; color: var(--cca-primary); font-weight: 600; }

/* ===== Suggestie-chips ===== */
.cca-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 16px 12px;
    background: #f7f7f8;
    border-top: 1px solid #ececec;
}
.cca-chips:empty { display: none; }
.cca-chip {
    background: #fff;
    border: 1px solid var(--cca-primary);
    color: var(--cca-primary);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--cca-font);
    white-space: nowrap;
    line-height: 1.3;
}
.cca-chip:hover { background: var(--cca-primary); color: #fff; }

/* ===== Input row ===== */
.cca-input-row {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
    border-top: 1px solid #e8e8e8;
    /* v0.6.8: ronde onderhoeken nu op input-row i.p.v. widget */
    border-radius: 0 0 var(--cca-radius) var(--cca-radius);
}
.cca-input {
    flex: 1;
    border: 1px solid #d0d0d0;
    border-radius: 22px;
    padding: 9px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
    font-family: var(--cca-font);
    background: #f7f7f8;
}
.cca-input:focus { border-color: var(--cca-primary); background: #fff; }
.cca-send-btn {
    background: var(--cca-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
    padding: 0;
}
.cca-send-btn:hover { background: var(--cca-primary-hover); transform: scale(1.06); }
.cca-send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ===== Floating variant ===== */
.cca-floating {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 360px;
    max-width: calc(100vw - 32px);
    z-index: 9999;
    /* Avada fix: expliciet open state */
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.cca-floating.cca-closed {
    opacity: 0;
    pointer-events: none;
    transform: translateY(14px);
}

/* Toggle button */
.cca-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    /* iOS safe-area: home-indicator ruimte */
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--cca-primary);
    border: none;
    cursor: pointer;
    z-index: 10000;
    box-shadow: 0 4px 18px rgba(0,0,0,0.25);
    display: none;
    align-items: center;
    justify-content: center;
    overflow: visible;
    transition: background 0.15s, transform 0.15s;
    padding: 0;
    /* Voorkom blauw tap-highlight op Android */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.cca-toggle-btn:hover { background: var(--cca-primary-hover); transform: scale(1.08); }
.cca-toggle-btn.visible { display: flex; }

/* SVG iconen op de toggle knop */
.cca-toggle-icon {
    width: 26px;
    height: 26px;
    fill: #fff;
    position: absolute;
    transition: opacity 0.2s, transform 0.2s;
}
.cca-icon-chat  { opacity: 1; transform: scale(1) rotate(0deg); }
.cca-icon-close { opacity: 0; transform: scale(0.6) rotate(-90deg); }
.cca-toggle-btn.cca-is-open .cca-icon-chat  { opacity: 0; transform: scale(0.6) rotate(90deg); }
.cca-toggle-btn.cca-is-open .cca-icon-close { opacity: 1; transform: scale(1) rotate(0deg); }

/* Unread badge */
.cca-badge {
    position: absolute;
    top: 1px; right: 1px;
    background: #e53935;
    color: #fff;
    border-radius: 50%;
    width: 18px; height: 18px;
    font-size: 11px; font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}
.cca-badge.visible { display: flex; }

/* ===== Mobiel (≤ 480px) ===== */
@media (max-width: 480px) {
    /* Widget als bottom sheet */
    .cca-widget {
        max-width: 100%;
        border-radius: 0;
    }

    .cca-floating {
        /* Boven de toggle-knop: knophoogte (52px) + marge (16px) + safe-area */
        bottom: calc(52px + 16px + env(safe-area-inset-bottom, 0px));
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
    }

    /* Verberg toggle-knop als de widget open is —
       sluiten gaat via het ⋯-menu (minimaliseren / afsluiten) */
    .cca-toggle-btn.cca-is-open {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s;
    }

    /* Berichten: minder hoog op kleine schermen */
    .cca-messages {
        min-height: 140px;
        max-height: 42vh;
    }

    /* Toggle knop: iets kleiner en dichter bij de rand */
    .cca-toggle-btn {
        right: 16px;
        width: 52px;
        height: 52px;
    }

    /* Chips: wrap voor categorie-chips, scroll voor platte chips */
    .cca-chips {
        flex-wrap: wrap;
        padding-bottom: 8px;
    }
    /* Platte suggestie-chips: horizontaal scrollbaar (class-gebaseerd — werkt in alle browsers) */
    .cca-chips:not(.cca-chips--hierarchical) {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .cca-chips:not(.cca-chips--hierarchical)::-webkit-scrollbar { display: none; }

    /* Input rij: grotere tikoppervlakte */
    .cca-input { font-size: 16px; /* Voorkomt iOS auto-zoom */ }
    .cca-send-btn { width: 44px; height: 44px; }
}

/* Overscroll: voorkom dat chat-scroller de pagina meetrekt (iOS + Android) */
.cca-messages {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Tap-highlight weg op alle knoppen */
.cca-chip,
.cca-send-btn,
.cca-menu-btn,
.cca-menu-item,
.cca-escalate-btn,
.cca-chip-back {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ===== FAQ "vraag indienen" formulier ===== */
.cca-faq-submit-wrap {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: calc(var(--cca-radius) + 4px);
    padding: 12px 14px;
    margin-top: 8px;
    align-self: flex-start;
    max-width: 90%;
    font-family: var(--cca-font);
}
.cca-faq-submit-label {
    font-size: 13px;
    color: #555;
    margin: 0 0 8px;
}
.cca-faq-input {
    width: 100%;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    margin-bottom: 8px;
    box-sizing: border-box;
    font-family: var(--cca-font);
}
.cca-faq-input:focus { outline: none; border-color: var(--cca-primary); }
.cca-faq-submit-btn { margin-top: 0; }
.cca-faq-submit-msg {
    font-size: 12px;
    color: #d63638;
    margin-top: 6px;
}
.cca-faq-contact-wrap {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.cca-faq-contact-wrap .cca-faq-submit-label {
    width: 100%;
    margin: 0 0 4px;
}
.cca-faq-contact-input {
    flex: 1 1 180px;
    min-width: 140px;
    padding: 8px 10px;
    border: 1px solid #d4d4d8;
    border-radius: var(--cca-radius);
    font-size: 14px;
    font-family: inherit;
}
.cca-faq-contact-input:focus {
    outline: none;
    border-color: var(--cca-primary);
}
.cca-faq-contact-input.cca-input-error {
    border-color: #d63638;
}

/* ===== Links in bot-berichten ===== */
.cca-message.bot .cca-link {
    color: var(--cca-primary);
    text-decoration: underline;
    word-break: break-all;
}
.cca-message.bot .cca-link:hover {
    opacity: 0.8;
}

/* ===== Hiërarchische chips navigatie ===== */
.cca-chip-nav {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #ececec;
}
.cca-chip-back {
    background: none;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
    color: var(--cca-primary);
    white-space: nowrap;
    transition: all 0.15s;
    font-family: var(--cca-font);
}
.cca-chip-back:hover {
    background: var(--cca-primary);
    color: #fff;
    border-color: var(--cca-primary);
}
.cca-chip-crumb {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Categorie chips (niveau 1) — iets voller */
.cca-chip.cca-chip-cat {
    font-weight: 600;
}

/* Subcategorie chips (niveau 2) */
.cca-chip.cca-chip-sub {
    font-style: italic;
}

/* Vraag chips (niveau 3) — volledige breedte */
.cca-chip.cca-chip-question {
    white-space: normal;
    text-align: left;
    flex: 1 1 100%;
    min-width: 100%;
}

/* ===== Markdown rendering in bot-berichten ===== */
.cca-message.bot .cca-p {
    margin: 0 0 6px 0;
}
.cca-message.bot .cca-p:last-child { margin-bottom: 0; }
.cca-message.bot .cca-li {
    display: block;
    padding-left: 4px;
    margin: 2px 0;
}
.cca-message.bot .cca-code {
    background: #f0f0f0;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 12px;
    font-family: monospace;
}

/* === WhatsApp balk === */
.cca-whatsapp-bar {
    padding: 8px 12px 0;
}
.cca-whatsapp-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    background: #25d366;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s;
    box-sizing: border-box;
}
.cca-whatsapp-btn:hover {
    background: #1ebe5d;
    color: #fff;
    text-decoration: none;
}
.cca-whatsapp-btn svg {
    flex-shrink: 0;
    fill: #fff;
}
