/* ==========================================================
   AI chat widget (website + user portal). Standalone — no Bootstrap needed.
   Colours follow the site theme when available.
   ========================================================== */
.ccc, .ccc * { box-sizing: border-box; }
.ccc {
    --ccc-primary: var(--cc-primary, var(--color-primary, #123a63));
    --ccc-primary-dark: var(--cc-primary-dark, var(--color-primary-dark, #0b2540));
    --ccc-accent: var(--cc-secondary, var(--color-accent, #f5a623));
    --ccc-text: #2b3648;
    --ccc-muted: #6b7688;
    --ccc-border: #e6eaf1;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: var(--ccc-text);
}

/* Launcher */
.ccc-launcher {
    position: fixed; right: 24px; bottom: 24px; z-index: 1045;
    width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer;
    background: linear-gradient(135deg, var(--ccc-primary), var(--ccc-primary-dark));
    color: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 28px rgba(11, 37, 64, .35);
    transition: transform .2s ease, box-shadow .2s ease;
}
.ccc-launcher:hover { transform: translateY(-2px) scale(1.04); }
.ccc-launcher svg { width: 28px; height: 28px; }
.ccc-launcher .ccc-dot {
    position: absolute; top: 6px; right: 6px; width: 13px; height: 13px; border-radius: 50%;
    background: #3ddc84; border: 2px solid #fff; animation: cccPulse 2s infinite;
}
@keyframes cccPulse { 0% { box-shadow: 0 0 0 0 rgba(61,220,132,.6); } 70% { box-shadow: 0 0 0 9px rgba(61,220,132,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,132,0); } }
.ccc-tip {
    position: fixed; right: 94px; bottom: 36px; z-index: 1045;
    background: #fff; color: var(--ccc-text); border-radius: 14px 14px 4px 14px;
    padding: 9px 14px; font-weight: 600; font-size: 13px; max-width: 220px;
    box-shadow: 0 10px 28px rgba(11, 37, 64, .18); cursor: pointer;
    opacity: 0; transform: translateY(8px); transition: opacity .3s, transform .3s; pointer-events: none;
}
.ccc-tip.show { opacity: 1; transform: none; pointer-events: auto; }

/* Panel */
.ccc-panel {
    position: fixed; right: 24px; bottom: 96px; z-index: 1046;
    width: 370px; max-width: calc(100vw - 32px); height: 560px; max-height: calc(100vh - 120px);
    background: #fff; border-radius: 20px; overflow: hidden;
    box-shadow: 0 24px 60px rgba(11, 37, 64, .28);
    display: flex; flex-direction: column;
    opacity: 0; transform: translateY(16px) scale(.98); pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
}
.ccc.open .ccc-panel { opacity: 1; transform: none; pointer-events: auto; }
.ccc-head {
    display: flex; align-items: center; gap: 10px; padding: 14px 14px 14px 16px;
    background: linear-gradient(135deg, var(--ccc-primary), var(--ccc-primary-dark)); color: #fff;
}
.ccc-avatar {
    width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; position: relative;
    background: var(--ccc-accent); color: var(--ccc-primary-dark);
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px;
}
.ccc-avatar.has-logo { background: #fff; }
.ccc-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.ccc-avatar::after { content: ''; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: #3ddc84; border: 2px solid var(--ccc-primary); }
.ccc-title { flex: 1; min-width: 0; line-height: 1.25; }
.ccc-title strong { display: block; font-size: 15px; }
.ccc-title small { opacity: .8; font-size: 12px; }
.ccc-icon-btn {
    width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer; flex-shrink: 0;
    background: rgba(255,255,255,.14); color: #fff; display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.ccc-icon-btn:hover { background: rgba(255,255,255,.26); }
.ccc-icon-btn svg { width: 18px; height: 18px; }

.ccc-head, .ccc-input, .ccc-foot { flex-shrink: 0; }
.ccc-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 14px 8px; background: #f4f6fa; overscroll-behavior: contain; }
.ccc-msg { display: flex; margin-bottom: 10px; }
.ccc-msg .ccc-bubble {
    max-width: 82%; padding: 9px 13px; border-radius: 16px; line-height: 1.5; font-size: 14px;
    white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 2px rgba(16, 38, 70, .06);
}
.ccc-msg.bot .ccc-bubble { background: #fff; border-bottom-left-radius: 4px; }
.ccc-msg.me { justify-content: flex-end; }
.ccc-msg.me .ccc-bubble { background: var(--ccc-primary); color: #fff; border-bottom-right-radius: 4px; }
.ccc-bubble a { color: inherit; text-decoration: underline; font-weight: 600; }
.ccc-msg.bot .ccc-bubble a { color: var(--ccc-primary); }
.ccc-typing .ccc-bubble { display: inline-flex; gap: 4px; padding: 12px 14px; }
.ccc-typing i { width: 7px; height: 7px; border-radius: 50%; background: #aab3c2; animation: cccBlink 1.2s infinite; }
.ccc-typing i:nth-child(2) { animation-delay: .2s; } .ccc-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes cccBlink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.ccc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.ccc-chip {
    border: 1px solid var(--ccc-primary); background: #fff; color: var(--ccc-primary);
    border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.ccc-chip:hover { background: var(--ccc-primary); color: #fff; }

.ccc-card { background: #fff; border: 1px solid var(--ccc-border); border-radius: 14px; padding: 12px; margin: 4px 0 12px; }
.ccc-card p { margin: 0 0 8px; font-weight: 600; font-size: 13px; color: var(--ccc-text); }
.ccc-card input {
    width: 100%; height: 38px; border: 1px solid var(--ccc-border); border-radius: 10px; padding: 0 10px;
    margin-bottom: 7px; font: inherit; font-size: 13.5px; color: var(--ccc-text); background: #fff;
}
.ccc-card input:focus { outline: none; border-color: var(--ccc-primary); }
.ccc-card-actions { display: flex; gap: 8px; align-items: center; }
.ccc-btn { border: 0; border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 700; font-size: 13px; cursor: pointer; background: var(--ccc-accent); color: var(--ccc-primary-dark); }
.ccc-btn:disabled { opacity: .6; cursor: wait; }
.ccc-link { background: none; border: 0; color: var(--ccc-muted); font: inherit; font-size: 12.5px; cursor: pointer; text-decoration: underline; }
.ccc-err { color: #c62828; font-size: 12px; min-height: 0; margin: 0 0 6px; }

.ccc-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--ccc-border); background: #fff; }
.ccc-input textarea {
    flex: 1; resize: none; border: 1px solid var(--ccc-border); border-radius: 18px; padding: 9px 14px;
    font: inherit; font-size: 14px; line-height: 1.4; max-height: 110px; min-height: 40px; color: var(--ccc-text); background: #fff;
}
.ccc-input textarea:focus { outline: none; border-color: var(--ccc-primary); }
.ccc-send {
    width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; flex-shrink: 0;
    background: var(--ccc-primary); color: #fff; display: flex; align-items: center; justify-content: center;
}
.ccc-send:disabled { opacity: .5; cursor: default; }
.ccc-send svg { width: 18px; height: 18px; }
.ccc-foot { text-align: center; font-size: 10.5px; color: var(--ccc-muted); padding: 0 12px 8px; background: #fff; }
.ccc-foot a { color: var(--ccc-muted); }

/* Portal: sit above the bottom tab bar on mobile */
.ccc.ccc-app .ccc-launcher { bottom: calc(84px + env(safe-area-inset-bottom)); width: 54px; height: 54px; }
.ccc.ccc-app .ccc-tip { bottom: calc(94px + env(safe-area-inset-bottom)); right: 88px; }
@media (min-width: 992px) {
    .ccc.ccc-app .ccc-launcher { bottom: 24px; }
    .ccc.ccc-app .ccc-tip { bottom: 36px; }
}
/* Website: move the back-to-top button above the chat launcher */
body.cc-chat-on .back-to-top { bottom: 96px; }

@media (max-width: 575.98px) {
    .ccc-panel {
        right: 0; bottom: 0; left: 0; width: 100%; max-width: none;
        height: 100%; max-height: none; border-radius: 0;
    }
    .ccc.open .ccc-launcher, .ccc.open .ccc-tip { display: none; }
    /* JS sets top/height to the visible area (keyboard-aware); these are the fallbacks. */
    .ccc-panel { top: 0; height: 100vh; height: 100dvh; transition: opacity .22s ease; transform: none; }
    .ccc.open .ccc-panel { transform: none; }
    /* 16px stops iPhone from zooming into the page when the input is tapped. */
    .ccc-input textarea { font-size: 16px; }
    .ccc-foot { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
    html.ccc-lock, html.ccc-lock body { overflow: hidden; overscroll-behavior: none; }
    .ccc-launcher { right: 16px; bottom: 16px; }
    .ccc-tip { right: 84px; bottom: 26px; }
    body.cc-chat-on .back-to-top { bottom: 84px; }
}
@media (prefers-reduced-motion: reduce) { .ccc-launcher .ccc-dot, .ccc-typing i { animation: none; } }

/* ==========================================================
   Voice call mode (green call button next to Send)
   ========================================================== */
.ccc-callbtn {
    width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; flex-shrink: 0;
    background: #1fb655; color: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(31, 182, 85, .35); transition: transform .15s ease;
}
.ccc-callbtn:hover { transform: scale(1.06); }
.ccc-callbtn svg { width: 19px; height: 19px; }

.ccc-call {
    position: absolute; inset: 0; z-index: 5;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 16px 22px calc(18px + env(safe-area-inset-bottom));
    color: #fff; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
    background:
        radial-gradient(circle at 50% 28%, rgba(255, 255, 255, .10), transparent 55%),
        linear-gradient(170deg, var(--ccc-primary) 0%, var(--ccc-primary-dark) 60%, #06121f 100%);
    opacity: 0; visibility: hidden; transform: scale(1.02);
    transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s;
}
.ccc-panel.ccc-in-call .ccc-call { opacity: 1; visibility: visible; transform: none; transition: opacity .25s ease, transform .25s ease; }
.ccc-call-top { width: 100%; display: flex; justify-content: space-between; align-items: center; font-size: 12px; opacity: .85; }
.ccc-call-secure { display: inline-flex; align-items: center; gap: 6px; }
.ccc-call-secure::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; }
.ccc-call-timer { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: .04em; }

.ccc-call-rings { position: relative; width: 116px; height: 116px; margin: 22px auto 12px; flex-shrink: 0; }
.ccc-call-rings i {
    position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35);
    animation: cccRing 2.2s ease-out infinite; opacity: 0;
}
.ccc-call-rings i + i { animation-delay: 1.1s; }
@keyframes cccRing { 0% { transform: scale(.8); opacity: .8; } 100% { transform: scale(1.45); opacity: 0; } }
.ccc-call-avatar {
    position: absolute; inset: 10px; border-radius: 50%;
    background: var(--ccc-accent); color: var(--ccc-primary-dark);
    display: flex; align-items: center; justify-content: center;
    font-size: 44px; font-weight: 800; overflow: hidden;
    box-shadow: 0 12px 34px rgba(0, 0, 0, .35), 0 0 0 4px rgba(255, 255, 255, .12);
    transition: box-shadow .2s ease, transform .2s ease;
}
.ccc-call-avatar.has-logo { background: #fff; }
.ccc-call-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Speaking / listening feedback */
.ccc-call.bot-talking .ccc-call-avatar { animation: cccTalk .9s ease-in-out infinite; box-shadow: 0 12px 34px rgba(0, 0, 0, .35), 0 0 0 8px rgba(245, 166, 35, .45); }
@keyframes cccTalk { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.ccc-call.me-talking .ccc-call-rings i { border-color: rgba(61, 220, 132, .75); }
.ccc-call.thinking .ccc-call-rings i { animation-duration: 1.1s; }

.ccc-call-name { font-size: 22px; line-height: 1.2; margin-top: 4px; }
.ccc-call-number { font-size: 15px; font-weight: 600; letter-spacing: .04em; margin-top: 2px; font-variant-numeric: tabular-nums; opacity: .92; }
.ccc-call-sub { font-size: 12.5px; opacity: .7; margin-top: 3px; }
.ccc-call-status { margin-top: 10px; font-size: 14px; font-weight: 600; min-height: 20px; color: #ffd58a; }
.ccc-call.ended .ccc-call-status { color: #ffb4b4; }
/* While the assistant talks, the status becomes a "Tap to talk" pill (and the avatar is tappable). */
.ccc-call.bot-talking .ccc-call-status {
    align-self: center; cursor: pointer; padding: 3px 14px; border-radius: 999px;
    background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 213, 138, .45);
}
.ccc-call.bot-talking .ccc-call-status:hover { background: rgba(255, 255, 255, .2); }
.ccc-call.bot-talking .ccc-call-rings { cursor: pointer; }
.ccc-call-caption {
    margin-top: 10px; width: 100%; flex: 1 1 auto; min-height: 44px; overflow-y: auto;
    font-size: 15px; line-height: 1.55; color: rgba(255, 255, 255, .92);
    white-space: pre-wrap; overflow-wrap: anywhere; padding: 0 4px;
}
.ccc-call-caption.me { color: #b9f5cf; font-style: italic; }
.ccc-call-caption { scrollbar-width: none; }
.ccc-call-caption::-webkit-scrollbar { display: none; }

.ccc-call-controls { display: flex; justify-content: center; align-items: flex-start; gap: 30px; margin: 12px 0 2px; flex-shrink: 0; }
.ccc-call-btn { border: 0; background: none; color: #fff; cursor: pointer; font: inherit; display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 0; }
.ccc-call-btn small { font-size: 12px; opacity: .85; }
.ccc-call-ico {
    width: 54px; height: 54px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .14); transition: background .2s ease, color .2s ease;
}
.ccc-call-ico svg { width: 24px; height: 24px; }
.ccc-call-btn:hover .ccc-call-ico { background: rgba(255, 255, 255, .24); }
.ccc-call-btn.on .ccc-call-ico { background: #fff; color: var(--ccc-primary-dark); }
.ccc-end { flex-shrink: 0; }
.ccc-end .ccc-call-ico { width: 60px; height: 60px; background: #e5383b; box-shadow: 0 10px 26px rgba(229, 56, 59, .45); }
.ccc-end:hover .ccc-call-ico { background: #c92a2d; }
.ccc-end .ccc-call-ico svg { width: 30px; height: 30px; }

.ccc-call-note { text-align: center; font-size: 12px; color: var(--ccc-muted); margin: 6px 0 12px; }

/* Short laptop screens (desktop panel is max 100vh - 120px tall): keep End visible. */
.ccc-call::-webkit-scrollbar { display: none; }
@media (max-height: 720px) {
    .ccc-call-rings { width: 92px; height: 92px; margin: 12px auto 8px; }
    .ccc-call-avatar { font-size: 32px; inset: 8px; }
    .ccc-call-name { font-size: 19px; }
    .ccc-call-controls { margin: 8px 0 10px; }
    .ccc-call-ico { width: 48px; height: 48px; }
    .ccc-call-ico svg { width: 21px; height: 21px; }
    .ccc-end .ccc-call-ico { width: 54px; height: 54px; }
}
@media (max-height: 580px) {
    .ccc-call { padding-top: 12px; padding-bottom: 12px; }
    .ccc-call-rings { width: 72px; height: 72px; margin: 8px auto 6px; }
    .ccc-call-avatar { font-size: 26px; inset: 6px; }
    .ccc-call-name { font-size: 17px; }
    .ccc-call-number { font-size: 13.5px; }
    .ccc-call-sub { display: none; }
    .ccc-call-status { margin-top: 6px; font-size: 13px; }
    .ccc-call-caption { margin-top: 6px; font-size: 14px; min-height: 40px; }
    .ccc-call-controls { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    .ccc-call-rings i, .ccc-call.bot-talking .ccc-call-avatar { animation: none; }
}

/* Microphone permission dialog (shown before the call screen when needed) */
.ccc-mic {
    position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center;
    padding: 20px; background: rgba(8, 20, 36, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility 0s linear .2s;
}
.ccc-panel.ccc-mic-open .ccc-mic { opacity: 1; visibility: visible; transition: opacity .2s ease; }
.ccc-mic-card {
    width: 100%; max-width: 320px; background: #fff; border-radius: 18px; padding: 22px 20px 14px;
    text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
    transform: translateY(10px); transition: transform .2s ease;
}
.ccc-panel.ccc-mic-open .ccc-mic-card { transform: none; }
.ccc-mic-ico {
    width: 60px; height: 60px; margin: 0 auto 12px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #e8f8ee; color: #1fb655; box-shadow: 0 0 0 8px rgba(31, 182, 85, .10);
}
.ccc-mic-ico svg { width: 28px; height: 28px; }
.ccc-mic[data-mode="denied"] .ccc-mic-ico { background: #fdecec; color: #e5383b; box-shadow: 0 0 0 8px rgba(229, 56, 59, .10); }
.ccc-mic-title { display: block; font-size: 16px; color: var(--ccc-primary-dark); margin-bottom: 6px; }
.ccc-mic-text { margin: 0 0 10px; font-size: 13.5px; line-height: 1.55; color: var(--ccc-muted); }
.ccc-mic-steps { text-align: left; margin: 0 0 10px; padding-left: 20px; font-size: 13px; line-height: 1.6; color: var(--ccc-text); }
.ccc-mic-steps:empty { display: none; }
.ccc-mic-status { margin: 0 0 10px; font-size: 12.5px; font-weight: 600; color: #b26a00; }
.ccc-mic-status:empty { display: none; }
.ccc-mic-allow {
    width: 100%; border: 0; border-radius: 12px; padding: 12px 16px; cursor: pointer;
    background: #1fb655; color: #fff; font: inherit; font-weight: 700; font-size: 14px;
    box-shadow: 0 8px 20px rgba(31, 182, 85, .3);
}
.ccc-mic-allow:hover { background: #18a049; }
.ccc-mic .ccc-link { margin-top: 8px; }

/* Launcher: filled bubble + live typing dots + soft pulse ring (draws the eye) */
.ccc-launcher::before { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--ccc-primary); opacity: .6; pointer-events: none; animation: cccRing 2.4s ease-out infinite; }
@keyframes cccRing { 0% { transform: scale(1); opacity: .6; } 80%, 100% { transform: scale(1.5); opacity: 0; } }
.ccc-launcher .ccc-fab-ico { width: 30px; height: 30px; }
.ccc-launcher .ccc-fab-ico circle { fill: var(--ccc-primary); animation: cccDot 1.4s infinite ease-in-out; }
.ccc-launcher .ccc-fab-ico .d2 { animation-delay: .18s; }
.ccc-launcher .ccc-fab-ico .d3 { animation-delay: .36s; }
@keyframes cccDot { 0%, 60%, 100% { transform: translateY(0); opacity: .55; } 30% { transform: translateY(-1.6px); opacity: 1; } }
.ccc-launcher .ccc-fab-ico circle { transform-box: fill-box; transform-origin: center; }
.ccc.open .ccc-launcher::before { animation: none; opacity: 0; }

/* Client portal (phones): smaller and clear of the bottom tab bar */
@media (max-width: 991.98px) {
    .ccc.ccc-app .ccc-launcher { bottom: calc(100px + env(safe-area-inset-bottom)); right: 18px; width: 48px; height: 48px; }
    .ccc.ccc-app .ccc-launcher .ccc-fab-ico { width: 25px; height: 25px; }
    .ccc.ccc-app .ccc-launcher .ccc-dot { top: 3px; right: 3px; width: 11px; height: 11px; }
    .ccc.ccc-app .ccc-tip { bottom: calc(108px + env(safe-area-inset-bottom)); right: 76px; }
}
@media (prefers-reduced-motion: reduce) { .ccc-launcher::before, .ccc-launcher .ccc-fab-ico circle { animation: none; } }
