/* ═══════════════════════════════════════════════════════════════════════════
   Confianz AI Chat Widget – Styles
   Matches the Next.js VoiceChatWidget (neon launcher, chat drawer, etc.)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset & base ──────────────────────────────────────────────────────── */
.cz-chat-widget,
.cz-chat-widget *,
.cz-chat-widget *::before,
.cz-chat-widget *::after {
    box-sizing: border-box !important;
    margin: 0;
    padding: 0;
}

.cz-chat-widget {
    font-family: 'Inter', 'Poppins', system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Targeted reset — only strip focus outlines that bleed from the main site */
.cz-chat-widget input:focus,
.cz-chat-widget button:focus {
    outline: none !important;
}

.cz-chat-widget input,
.cz-chat-widget button {
    font-family: inherit !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

/* ── Launcher (bottom-right floating button) ───────────────────────────── */
.cz-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9995;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    animation: czChatFadeInUp 0.35s ease-out;
}

.cz-chat-launcher-border {
    position: relative;
    padding: 1.5px;
    border-radius: 9999px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Subtle rotating conic-gradient beam */
.cz-chat-launcher-border::before {
    content: '';
    position: absolute;
    inset: -200%;
    background: conic-gradient(from 0deg, #f3f4f6, #d1d5db, #9ca3af, #d1d5db, #f3f4f6);
    animation: czChatRotate 8s linear infinite;
    pointer-events: none;
}

.cz-chat-launcher-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 9999px;
    background: #fff;
    color: #141B2A;
    padding: 10px 20px 10px 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    z-index: 1;
}

.cz-chat-launcher-btn:hover {
    transform: scale(1.02);
}

.cz-chat-launcher-btn:active {
    transform: scale(0.96);
}

/* Logo avatar */
.cz-chat-launcher-avatar {
    position: relative;
    display: flex;
    height: 32px;
    width: 32px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: linear-gradient(to top right, rgba(159, 27, 113, 0.1), rgba(124, 93, 249, 0.1));
    padding: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #f3f4f6;
    transition: transform 0.3s ease;
    z-index: 10;
}

.cz-chat-launcher-btn:hover .cz-chat-launcher-avatar {
    transform: scale(1.1);
}

.cz-chat-launcher-avatar img {
    height: 100%;
    width: 100%;
    object-fit: contain;
}

/* Pulsing status dot on launcher avatar */
.cz-chat-status-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    display: flex;
    height: 10px;
    width: 10px;
}

.cz-chat-status-dot .ping {
    position: absolute;
    display: inline-flex;
    height: 100%;
    width: 100%;
    border-radius: 9999px;
    background-color: #34d399;
    opacity: 0.75;
    animation: czChatPing 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.cz-chat-status-dot .dot {
    position: relative;
    display: inline-flex;
    height: 10px;
    width: 10px;
    border-radius: 9999px;
    background-color: #10b981;
    border: 2px solid #fff;
}

.cz-chat-launcher-label {
    font-size: 14.5px;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: #141B2A;
    white-space: nowrap;
    z-index: 10;
}

/* ── Chat window (drawer) ──────────────────────────────────────────────── */
.cz-chat-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 390px;
    height: min(740px, calc(100vh - 48px));
    height: min(740px, calc(100dvh - 3rem));
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 3rem);
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    background: #fff !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
    border: 1px solid rgba(228, 228, 231, 0.8) !important;
    overflow: hidden;
    animation: czChatSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Header ────────────────────────────────────────────────────────────── */
.cz-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background-color: #DA1E17;
    color: #fff;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cz-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cz-chat-header-avatar {
    position: relative;
    display: flex;
    height: 32px;
    width: 32px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: #fff;
    padding: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.cz-chat-header-avatar img {
    height: 100%;
    width: 100%;
    object-fit: contain;
}

/* Header status dot */
.cz-chat-header-avatar .cz-chat-status-dot .dot {
    border-color: #9F1B71;
}

.cz-chat-header-name {
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1.2;
    color: #fff;
}

.cz-chat-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    margin-top: 2px;
    color: #e4e4e7;
}

.cz-chat-header-status .pulse-dot {
    height: 6px;
    width: 6px;
    border-radius: 9999px;
    background-color: #34d399;
    animation: czChatPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.cz-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cz-chat-header-actions button {
    border-radius: 9999px !important;
    padding: 6px !important;
    color: rgba(255, 255, 255, 0.8) !important;
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    outline: none !important;
    box-shadow: none !important;
}

.cz-chat-header-actions button:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.15) !important;
}

.cz-chat-header-actions button:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

.cz-chat-header-actions button svg {
    width: 16px !important;
    height: 16px !important;
}

/* ── Message body ──────────────────────────────────────────────────────── */
.cz-chat-body {
    flex: 1 1 0%;
    overflow-y: auto;
    background: rgba(250, 250, 250, 0.5);
    padding: 16px;
    min-height: 0;
}

/* Custom scrollbar */
.cz-chat-body::-webkit-scrollbar {
    width: 5px;
}

.cz-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.cz-chat-body::-webkit-scrollbar-thumb {
    background: #d4d4d8;
    border-radius: 9999px;
}

.cz-chat-body::-webkit-scrollbar-thumb:hover {
    background: #a1a1aa;
}

/* Welcome section */
.cz-chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    padding-bottom: 8px;
    text-align: center;
}

.cz-chat-welcome-avatar {
    margin-bottom: 12px;
    display: flex;
    height: 56px;
    width: 56px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 9999px;
    background: #fff;
    padding: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e4e4e7;
}

.cz-chat-welcome-avatar img {
    height: 100%;
    width: 100%;
    object-fit: contain;
}

.cz-chat-welcome-name {
    font-size: 14px;
    font-weight: 700;
    color: #18181b;
}

.cz-chat-welcome-sub {
    margin-top: 2px;
    font-size: 12px;
    color: #71717a;
}

/* Messages container */
.cz-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

/* User bubble */
.cz-chat-msg-user {
    margin-left: auto;
    width: fit-content;
    max-width: 82%;
    border-radius: 16px;
    border-top-right-radius: 4px;
    padding: 10px 14px;
    font-size: 14px;
    color: #fff;
    background: linear-gradient(to right, #1B1733, #9F1B71);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    word-break: break-word;
}

/* Agent bubble */
.cz-chat-msg-agent {
    margin-right: auto;
    width: fit-content;
    max-width: 84%;
    border-radius: 16px;
    border-top-left-radius: 4px;
    background: #fff;
    border: 1px solid rgba(228, 228, 231, 0.8);
    padding: 10px 14px;
    font-size: 14px;
    color: #27272a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    line-height: 1.625;
    word-break: break-word;
}

.cz-chat-msg-agent p {
    margin-bottom: 8px;
}

.cz-chat-msg-agent p:last-child {
    margin-bottom: 0;
}

.cz-chat-msg-agent strong {
    font-weight: 600;
}

.cz-chat-msg-agent ol {
    padding-left: 20px;
    list-style-type: decimal;
}

.cz-chat-msg-agent ul {
    padding-left: 20px;
    list-style-type: disc;
}

.cz-chat-msg-agent li {
    margin-bottom: 4px;
}

.cz-chat-msg-agent li:last-child {
    margin-bottom: 0;
}

/* System bubble */
.cz-chat-msg-system {
    margin: 0 auto;
    width: fit-content;
    max-width: 90%;
    border-radius: 9999px;
    background: #e4e4e7;
    padding: 4px 12px;
    text-align: center;
    font-size: 12px;
    color: #52525b;
}

/* Quick-reply buttons */
.cz-chat-quick-replies {
    margin-right: auto;
    margin-top: 8px;
    display: flex;
    max-width: 90%;
    flex-wrap: wrap;
    gap: 8px;
}

.cz-chat-quick-reply {
    border-radius: 9999px !important;
    background: #fff !important;
    border: 1px solid #d4d4d8 !important;
    padding: 6px 14px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: #27272a !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
    font-family: inherit !important;
    outline: none !important;
}

.cz-chat-quick-reply:hover {
    border-color: #171717 !important;
    color: #171717 !important;
    background: #fdf2f8 !important;
}

.cz-chat-quick-reply:focus {
    border-color: #d4d4d8 !important;
    outline: none !important;
    box-shadow: none !important;
}

.cz-chat-quick-reply:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* Thinking indicator */
.cz-chat-thinking {
    margin-right: auto;
    display: flex;
    width: fit-content;
    align-items: center;
    gap: 8px;
    border-radius: 9999px;
    background: #fff;
    border: 1px solid #e4e4e7;
    padding: 8px 14px;
    font-size: 12px;
    color: #71717a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.cz-chat-thinking-dots {
    display: flex;
    gap: 4px;
}

.cz-chat-thinking-dots span {
    height: 6px;
    width: 6px;
    border-radius: 9999px;
    background-color: #a1a1aa;
    animation: czChatBounce 0.6s infinite alternate;
}

.cz-chat-thinking-dots span:nth-child(1) {
    animation-delay: -0.3s;
}

.cz-chat-thinking-dots span:nth-child(2) {
    animation-delay: -0.15s;
}

.cz-chat-thinking-dots span:nth-child(3) {
    animation-delay: 0s;
}

/* Re-verification banner */
.cz-chat-reverify {
    margin: 0 auto;
    display: flex;
    width: fit-content;
    max-width: 90%;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border-radius: 12px;
    border: 1px solid #fde68a;
    background: #fffbeb;
    padding: 12px 16px;
    text-align: center;
    font-size: 12px;
    color: #92400e;
}

.cz-chat-reverify p {
    font-weight: 500;
}

.cz-chat-reverify button {
    border-radius: 9999px;
    background: #d97706;
    padding: 4px 12px;
    font-weight: 600;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    font-family: inherit;
    font-size: 12px;
}

.cz-chat-reverify button:hover {
    background: #b45309;
}

/* Error banner */
.cz-chat-error {
    margin: 0 auto;
    width: fit-content;
    max-width: 90%;
    border-radius: 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 8px 12px;
    text-align: center;
    font-size: 12px;
    color: #dc2626;
}

/* ── Footer / input area ───────────────────────────────────────────────── */
.cz-chat-footer {
    border-top: 1px solid #e4e4e7;
    background: #fff;
    padding: 12px 14px;
    flex-shrink: 0;
}

.cz-chat-remaining {
    margin-bottom: 6px;
    text-align: center;
    font-size: 11px;
    color: #a1a1aa;
}

.cz-chat-input-row {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    border-radius: 9999px !important;
    border: 1px solid #d4d4d8 !important;
    background: #fafafa !important;
    padding: 6px 14px !important;
    transition: all 0.2s ease !important;
    box-shadow: none !important;
    outline: none !important;
}

.cz-chat-input-row:focus-within {
    background: #fff !important;
    border-color: #a7a7a7 !important;
}

.cz-chat-input-row input {
    flex: 1 !important;
    background: transparent !important;
    font-size: 14px !important;
    color: #27272a !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    font-family: inherit !important;
    min-width: 0 !important;
    height: auto !important;
    padding: 4px 0 !important;
    margin: 0 !important;
    line-height: 1.5 !important;
}

.cz-chat-input-row input:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.cz-chat-input-row input::placeholder {
    color: #a1a1aa !important;
}

.cz-chat-input-row input:disabled {
    cursor: not-allowed !important;
}

.cz-chat-send-btn {
    display: flex !important;
    height: 28px !important;
    width: 28px !important;
    flex-shrink: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 9999px !important;
    background: #171717 !important;
    color: #fff !important;
    border: none !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
    outline: none !important;
    padding: 0 !important;
}

.cz-chat-send-btn:hover {
    background: #80155a !important;
}

.cz-chat-send-btn:active {
    transform: scale(0.95) !important;
}

.cz-chat-send-btn:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
}

.cz-chat-send-btn svg {
    width: 14px !important;
    height: 14px !important;
}

.cz-chat-powered {
    margin-top: 8px;
    text-align: center;
    font-size: 10px;
    color: #a1a1aa;
}

/* ── Hidden Turnstile container ────────────────────────────────────────── */
.cz-chat-turnstile {
    position: fixed;
    left: -9999px;
    top: -9999px;
    width: 300px;
    height: 65px;
    pointer-events: none;
    opacity: 0;
}

/* ── Animations ────────────────────────────────────────────────────────── */
@keyframes czChatRotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes czChatPing {

    75%,
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

@keyframes czChatPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes czChatBounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-6px);
    }
}

@keyframes czChatFadeInUp {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes czChatSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes czChatSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ── Mobile responsive ─────────────────────────────────────────────────── */
@media (max-width: 639px) {
    .cz-chat-window {
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        right: 0 !important;
        bottom: 0 !important;
        border-radius: 0 !important;
        border: none !important;
    }

    .cz-chat-launcher {
        bottom: 16px;
        right: 16px;
    }
}