/**
 * CC AI Concierge — widget styles.
 *
 * Visual language matches the IONOS "Ask Clio" widget on the public site:
 * white pill launcher with an avatar orb, 400×620 card with a 22px radius,
 * accent-tinted user bubbles / grey assistant bubbles, and an "↵ Enter"
 * keycap as the send button. Every selector is prefixed .cc-aic- and
 * scoped under .cc-aic-root so theme (Blocksy) styles don't bleed in.
 *
 * Accent is set per-site via --cc-aic-accent (inline on #cc-aic-root from
 * the PHP settings). Everything else derives from it.
 */

.cc-aic-root {
    --cc-aic-accent:    #1D4F8C;
    --cc-aic-accent-fg: #ffffff;
    --cc-aic-bg:        #ffffff;
    --cc-aic-fg:        #0f172a;
    --cc-aic-muted:     #64748b;
    --cc-aic-danger:    #dc2626;
    --cc-aic-hairline:  rgba(15, 23, 42, 0.08);
    --cc-aic-field:     #f1f5f9;
    --cc-aic-shadow:    0 6px 20px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.06);

    position: fixed;
    z-index: 2147483000;
    bottom: 20px;
    display: flex;
    align-items: flex-end;
    box-sizing: border-box;
    color: var(--cc-aic-fg);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}
.cc-aic-root *,
.cc-aic-root *::before,
.cc-aic-root *::after { box-sizing: border-box; }

.cc-aic-pos-bottom-right  { right: 20px; justify-content: flex-end; }
.cc-aic-pos-bottom-left   { left: 20px;  justify-content: flex-start; }
.cc-aic-pos-bottom-center { left: 50%; transform: translateX(-50%); justify-content: center; }

/* Blocksy resets [hidden] in places; make sure ours always wins. */
.cc-aic-root [hidden] { display: none !important; }


/* ── Avatar orb ─────────────────────────────────────────────────────────── */
.cc-aic-orb {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: 9999px;
    overflow: hidden;
    flex: 0 0 auto;
    background: color-mix(in srgb, var(--cc-aic-accent) 75%, #000);
}
.cc-aic-orb-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 9999px;
}
/* Fallback when no avatar image is configured: liquid accent blob. */
.cc-aic-orb-blob {
    position: absolute;
    inset: 0;
    border-radius: 58% 42% 63% 37% / 47% 58% 42% 53%;
    background:
        radial-gradient(circle at 30% 30%, rgba(255,255,255,0.55), transparent 55%),
        conic-gradient(from 210deg,
            color-mix(in srgb, var(--cc-aic-accent) 55%, #fff),
            var(--cc-aic-accent),
            color-mix(in srgb, var(--cc-aic-accent) 65%, #000),
            var(--cc-aic-accent),
            color-mix(in srgb, var(--cc-aic-accent) 55%, #fff));
    clip-path: circle(50% at 50% 50%);
    animation: cc-aic-blob 7s ease-in-out infinite;
}
@keyframes cc-aic-blob {
    0%, 100% { border-radius: 58% 42% 63% 37% / 47% 58% 42% 53%; }
    25%      { border-radius: 42% 58% 37% 63% / 53% 42% 58% 47%; }
    50%      { border-radius: 65% 35% 50% 50% / 50% 65% 35% 50%; }
    75%      { border-radius: 35% 65% 55% 45% / 45% 38% 62% 55%; }
}


/* ── Pill launcher ──────────────────────────────────────────────────────── */
.cc-aic-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 52px;
    margin: 0;
    padding: 6px 18px 6px 6px;
    border-radius: 26px;
    background: var(--cc-aic-bg);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: var(--cc-aic-shadow);
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    color: var(--cc-aic-fg);
    text-decoration: none;
    white-space: nowrap;
    max-width: min(360px, calc(100vw - 40px));
    transition: transform 150ms ease, box-shadow 150ms ease;
    -webkit-appearance: none;
    appearance: none;
}
.cc-aic-pill:hover { transform: translateY(-1px); background: var(--cc-aic-bg); color: var(--cc-aic-fg); }
.cc-aic-pill:focus-visible { outline: 3px solid rgba(0, 0, 0, 0.2); outline-offset: 2px; }
.cc-aic-pill-label { overflow: hidden; text-overflow: ellipsis; }


/* ── Card ───────────────────────────────────────────────────────────────── */
.cc-aic-card {
    display: flex;
    flex-direction: column;
    width: min(400px, calc(100vw - 40px));
    height: min(620px, calc(100vh - 100px));
    height: min(620px, calc(100dvh - 100px));
    background: var(--cc-aic-bg);
    border: 1px solid var(--cc-aic-hairline);
    border-radius: 22px;
    box-shadow: var(--cc-aic-shadow);
    overflow: hidden;
    animation: cc-aic-card-in 200ms ease;
}
@keyframes cc-aic-card-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

.cc-aic-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 56px;
    flex: 0 0 auto;
    padding: 0 12px;
    border-bottom: 1px solid var(--cc-aic-hairline);
}
.cc-aic-hdr-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
}
.cc-aic-hdr-title .cc-aic-orb { width: 30px; height: 30px; }
.cc-aic-hdr-right {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
}
.cc-aic-hdr-btn {
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border-radius: 9999px;
    border: none;
    background: var(--cc-aic-field);
    color: var(--cc-aic-fg);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    transition: background 120ms ease;
    -webkit-appearance: none;
    appearance: none;
}
.cc-aic-hdr-btn:hover { background: #e2e8f0; color: var(--cc-aic-fg); }
.cc-aic-hdr-btn:focus-visible { outline: 2px solid rgba(15, 23, 42, 0.3); outline-offset: 2px; }
.cc-aic-hdr-btn svg { width: 18px; height: 18px; }


/* ── Message log ────────────────────────────────────────────────────────── */
.cc-aic-log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}
.cc-aic-msg {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.cc-aic-msg.cc-aic-user {
    align-self: flex-end;
    background: color-mix(in srgb, var(--cc-aic-accent) 16%, transparent);
    color: color-mix(in srgb, var(--cc-aic-accent) 82%, #000);
    border-bottom-right-radius: 6px;
}
.cc-aic-msg.cc-aic-assistant {
    align-self: flex-start;
    background: var(--cc-aic-field);
    color: var(--cc-aic-fg);
    border-bottom-left-radius: 6px;
    white-space: normal;
}
/* Rendered markdown inside assistant bubbles. */
.cc-aic-msg.cc-aic-assistant > :first-child { margin-top: 0; }
.cc-aic-msg.cc-aic-assistant > :last-child  { margin-bottom: 0; }
.cc-aic-msg.cc-aic-assistant p  { margin: 0 0 8px; }
.cc-aic-msg.cc-aic-assistant ul,
.cc-aic-msg.cc-aic-assistant ol { margin: 4px 0 8px; padding-left: 20px; }
.cc-aic-msg.cc-aic-assistant li { margin: 2px 0; }
.cc-aic-msg.cc-aic-assistant a  { color: var(--cc-aic-accent); text-decoration: underline; }
.cc-aic-msg.cc-aic-assistant code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    background: rgba(15, 23, 42, 0.06);
    padding: 1px 4px;
    border-radius: 4px;
}

/* Quick-reply chips (empty state only). */
.cc-aic-options {
    align-self: flex-end;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    max-width: 84%;
}
.cc-aic-option {
    margin: 0;
    text-align: left;
    padding: 9px 14px;
    border: 1px solid var(--cc-aic-accent);
    border-radius: 18px;
    background: var(--cc-aic-bg);
    color: var(--cc-aic-accent);
    font: inherit;
    font-size: 14px;
    line-height: 1.35;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
    -webkit-appearance: none;
    appearance: none;
}
.cc-aic-option:hover { background: var(--cc-aic-accent); color: var(--cc-aic-accent-fg); }
.cc-aic-option:focus-visible { outline: 2px solid var(--cc-aic-accent); outline-offset: 2px; }

/* Typing indicator. */
.cc-aic-typing {
    align-self: flex-start;
    display: inline-flex;
    gap: 4px;
    padding: 14px;
}
.cc-aic-typing span {
    width: 7px;
    height: 7px;
    border-radius: 9999px;
    background: var(--cc-aic-muted);
    opacity: 0.5;
    animation: cc-aic-typing 1.2s infinite ease-in-out;
}
.cc-aic-typing span:nth-child(2) { animation-delay: 0.15s; }
.cc-aic-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cc-aic-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

.cc-aic-error {
    align-self: center;
    color: var(--cc-aic-danger);
    font-size: 13px;
    text-align: center;
    padding: 0 8px;
}


/* ── Composer ───────────────────────────────────────────────────────────── */
.cc-aic-composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px;
    margin: 0;
    flex: 0 0 auto;
}
.cc-aic-field {
    flex: 1 1 auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--cc-aic-bg);
    border: 1px solid var(--cc-aic-hairline);
    border-radius: 22px;
    border-bottom-right-radius: 6px; /* echoes the user bubble's clipped tail */
    padding: 6px 8px 6px 16px;
    transition: border-color 120ms ease;
}
.cc-aic-field:focus-within { border-color: color-mix(in srgb, var(--cc-aic-accent) 45%, var(--cc-aic-hairline)); }
.cc-aic-input {
    flex: 1 1 auto;
    width: 100%;
    min-height: 26px;
    max-height: 120px;
    margin: 0;
    padding: 3px 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    resize: none;
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
    color: var(--cc-aic-fg);
    outline: none;
}
.cc-aic-input:focus { outline: none; box-shadow: none; border: none; }
.cc-aic-input::placeholder { color: var(--cc-aic-muted); }
.cc-aic-input:disabled { opacity: 0.6; }

/* Send keycap: advertises the Enter shortcut and is itself the send button. */
.cc-aic-enter {
    flex: 0 0 auto;
    align-self: flex-end;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 26px;
    margin: 0;
    padding: 0 9px;
    border: 1px solid var(--cc-aic-hairline);
    border-radius: 8px;
    background: var(--cc-aic-field);
    color: var(--cc-aic-muted);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: opacity 120ms ease, background 120ms ease, color 120ms ease;
    -webkit-appearance: none;
    appearance: none;
}
.cc-aic-enter:not(:disabled):hover { background: #e2e8f0; color: var(--cc-aic-fg); }
.cc-aic-enter:focus-visible { outline: 2px solid var(--cc-aic-accent); outline-offset: 2px; }
.cc-aic-enter:disabled { opacity: 0.5; cursor: default; }
.cc-aic-enter svg { width: 13px; height: 13px; }


/* ── Small screens: card takes the viewport, pill stays put ─────────────── */
@media (max-width: 480px) {
    .cc-aic-root { bottom: 12px; }
    .cc-aic-pos-bottom-right { right: 12px; }
    .cc-aic-pos-bottom-left  { left: 12px; }
    .cc-aic-card {
        width: calc(100vw - 24px);
        height: min(620px, calc(100dvh - 24px));
        border-radius: 18px;
    }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cc-aic-pill:hover { transform: none; }
    .cc-aic-orb-blob { animation: none; }
    .cc-aic-typing span { animation: none; }
    .cc-aic-card { animation: none; }
    .cc-aic-log { scroll-behavior: auto; }
}

/* ─── 1.1.0: public-mode bot check, trouble nudge, Contact-form panel ─── */

.cc-aic-captcha {
    align-self: stretch;
    background: #f6f7f9;
    border: 1px solid #e3e6ea;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    color: #222;
}
.cc-aic-captcha p { margin: 0 0 8px; }
.cc-aic-captcha-box { min-height: 78px; transform-origin: 0 0; }
@media (max-width: 380px) { .cc-aic-captcha-box { transform: scale(.88); } }

.cc-clio-nudge {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 99997;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 32px);
    background: #fff;
    color: #222;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,.18);
    padding: 10px 36px 10px 12px;
    font-size: 14px;
    line-height: 1.35;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s ease, transform .25s ease;
}
.cc-clio-nudge.cc-clio-nudge-in { opacity: 1; transform: none; }
.cc-clio-nudge-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; margin: 0; }
.cc-clio-nudge-text { flex: 1 1 auto; }
.cc-clio-nudge-go {
    flex: 0 0 auto;
    background: var(--cc-aic-accent, #1D4F8C);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.cc-clio-nudge-go:hover, .cc-clio-nudge-go:focus { opacity: .88; }
.cc-clio-nudge-x {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: 0;
    font-size: 18px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 4px;
}

.cc-clio-contact {
    margin: 12px 0 16px;
    padding: 14px 16px;
    background: #eef3fa;
    border: 1px solid #c9d7ea;
    border-left: 4px solid #1D4F8C;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.45;
    color: #1d2327;
}
.cc-clio-contact-title { margin: 0 0 8px; }
.cc-clio-contact-tips { margin: 0 0 10px; padding-left: 20px; }
.cc-clio-contact-tips li { margin: 4px 0; }
.cc-clio-contact-tips a { color: #1D4F8C; text-decoration: underline; }
.cc-clio-contact-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cc-clio-contact-actions button {
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid #1D4F8C;
}
.cc-clio-contact-ask { background: #1D4F8C; color: #fff; }
.cc-clio-contact-send { background: #fff; color: #1D4F8C; }
