/* ============================================================
   C2A Compliance – Chatbot Widget Styles
   Premium glassmorphism chatbot window
   ============================================================ */

/* ----- Custom Properties ----- */
:root {
    --c2a-chat-primary: #78B52F;
    --c2a-chat-primary-dark: #5a8a1e;
    --c2a-chat-primary-light: #a3d465;
    --c2a-chat-secondary: #008BC2;
    --c2a-chat-secondary-dark: #006a94;
    --c2a-chat-accent: #d4a574;
    --c2a-chat-white: #ffffff;
    --c2a-chat-bg: rgba(255, 255, 255, 0.88);
    --c2a-chat-bg-solid: #f8faf5;
    --c2a-chat-text: #1e293b;
    --c2a-chat-text-muted: #64748b;
    --c2a-chat-border: rgba(120, 181, 47, 0.15);
    --c2a-chat-shadow: 0 20px 60px rgba(0, 0, 0, 0.18),
                       0 8px 24px rgba(0, 0, 0, 0.10),
                       0 0 0 1px rgba(120, 181, 47, 0.08);
    --c2a-chat-radius: 24px;
    --c2a-chat-radius-sm: 14px;
    --c2a-chat-radius-pill: 9999px;
    --c2a-chat-width: 400px;
    --c2a-chat-height: 600px;
    --c2a-chat-z: 10000;
    --c2a-chat-transition: cubic-bezier(0.34, 1.56, 0.64, 1);
    --c2a-chat-transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --c2a-chat-font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ============================================================
   Keyframes
   ============================================================ */
@keyframes c2a-chatbot-slideUp {
    0% {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes c2a-chatbot-slideDown {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }
}

@keyframes c2a-chatbot-fadeIn {
    0% {
        opacity: 0;
        transform: translateY(8px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes c2a-chatbot-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

@keyframes c2a-chatbot-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

@keyframes c2a-chatbot-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ============================================================
   1. Backdrop Overlay (mobile)
   ============================================================ */
.c2a-chatbot-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: calc(var(--c2a-chat-z) - 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s var(--c2a-chat-transition-smooth),
                visibility 0.3s var(--c2a-chat-transition-smooth);
    display: none;
}

.c2a-chatbot-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ============================================================
   2. Chat Window Container
   ============================================================ */
.c2a-chatbot-window {
    position: fixed;
    bottom: 110px;          /* above contact hub (32px + hub height ~60px + gap) */
    right: 32px;
    width: var(--c2a-chat-width);
    height: var(--c2a-chat-height);
    max-height: 80vh;
    z-index: var(--c2a-chat-z);
    display: flex;
    flex-direction: column;
    border-radius: var(--c2a-chat-radius);
    background: var(--c2a-chat-bg);
    backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border: 1px solid var(--c2a-chat-border);
    box-shadow: var(--c2a-chat-shadow);
    font-family: var(--c2a-chat-font);
    overflow: hidden;

    /* hidden by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(24px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.35s var(--c2a-chat-transition-smooth),
                visibility 0.35s var(--c2a-chat-transition-smooth),
                transform 0.35s var(--c2a-chat-transition-smooth);
}

.c2a-chatbot-window.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    animation: c2a-chatbot-slideUp 0.45s var(--c2a-chat-transition) both;
}

.c2a-chatbot-window.is-closing {
    animation: c2a-chatbot-slideDown 0.3s var(--c2a-chat-transition-smooth) both;
}

/* ============================================================
   3. Header
   ============================================================ */
.c2a-chatbot-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--c2a-chat-primary) 0%, var(--c2a-chat-primary-dark) 60%, #4a7a12 100%);
    color: var(--c2a-chat-white);
    position: relative;
    overflow: hidden;
}

/* subtle decorative gradient overlay */
.c2a-chatbot-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(255,255,255,0.08) 0%, transparent 50%, rgba(255,255,255,0.04) 100%);
    pointer-events: none;
}

/* bot avatar */
.c2a-chatbot-header__avatar {
    position: relative;
    z-index: 1;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 2px solid rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.c2a-chatbot-header__avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* header info */
.c2a-chatbot-header__info {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
}

.c2a-chatbot-header__name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.3;
}

.c2a-chatbot-header__status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.9;
    margin-top: 2px;
}

.c2a-chatbot-header__status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #a3f05e;
    box-shadow: 0 0 6px rgba(163, 240, 94, 0.6);
    animation: c2a-chatbot-pulse 2s ease-in-out infinite;
}

/* header action buttons */
.c2a-chatbot-header__actions {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}

.c2a-chatbot-header__btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: var(--c2a-chat-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s ease, transform 0.15s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.c2a-chatbot-header__btn:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: scale(1.08);
}

.c2a-chatbot-header__btn:active {
    transform: scale(0.95);
}

/* ============================================================
   4. Messages Area
   ============================================================ */
.c2a-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--c2a-chat-bg-solid);
    scroll-behavior: smooth;
}

/* custom scrollbar */
.c2a-chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

.c2a-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.c2a-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(120, 181, 47, 0.25);
    border-radius: 10px;
}

.c2a-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 181, 47, 0.45);
}

/* Firefox scrollbar */
.c2a-chatbot-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(120, 181, 47, 0.25) transparent;
}

/* ============================================================
   5. Individual Messages
   ============================================================ */
.c2a-chatbot-message {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: c2a-chatbot-fadeIn 0.35s var(--c2a-chat-transition-smooth) both;
}

/* bot message – left */
.c2a-chatbot-message--bot {
    align-self: flex-start;
}

.c2a-chatbot-message--bot .c2a-chatbot-message__bubble {
    background: var(--c2a-chat-white);
    color: var(--c2a-chat-text);
    border-radius: 4px 18px 18px 18px;
    border: 1px solid rgba(120, 181, 47, 0.1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* user message – right */
.c2a-chatbot-message--user {
    align-self: flex-end;
}

.c2a-chatbot-message--user .c2a-chatbot-message__bubble {
    background: linear-gradient(135deg, var(--c2a-chat-primary) 0%, var(--c2a-chat-primary-dark) 100%);
    color: var(--c2a-chat-white);
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 8px rgba(120, 181, 47, 0.25);
}

.c2a-chatbot-message__bubble {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.c2a-chatbot-message__bubble p {
    margin: 0;
}

.c2a-chatbot-message__bubble p + p {
    margin-top: 8px;
}

.c2a-chatbot-message__bubble a {
    color: var(--c2a-chat-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.c2a-chatbot-message--user .c2a-chatbot-message__bubble a {
    color: var(--c2a-chat-white);
    text-decoration-color: rgba(255, 255, 255, 0.5);
}

/* message avatar (for bot messages) */
.c2a-chatbot-message__avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c2a-chat-primary), var(--c2a-chat-primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--c2a-chat-white);
    margin-bottom: 4px;
    flex-shrink: 0;
}

/* timestamp */
.c2a-chatbot-message__time {
    font-size: 11px;
    color: var(--c2a-chat-text-muted);
    margin-top: 4px;
    padding: 0 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.c2a-chatbot-message:hover .c2a-chatbot-message__time {
    opacity: 1;
}

.c2a-chatbot-message--user .c2a-chatbot-message__time {
    text-align: right;
}

/* ============================================================
   6. Typing Indicator
   ============================================================ */
.c2a-chatbot-typing {
    display: none;
    align-self: flex-start;
    align-items: center;
    gap: 4px;
    padding: 14px 20px;
    background: var(--c2a-chat-white);
    border-radius: 4px 18px 18px 18px;
    border: 1px solid rgba(120, 181, 47, 0.1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    animation: c2a-chatbot-fadeIn 0.3s var(--c2a-chat-transition-smooth) both;
}

.c2a-chatbot-typing.is-visible {
    display: flex;
}

.c2a-chatbot-typing__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--c2a-chat-primary);
    animation: c2a-chatbot-typing-bounce 1.4s ease-in-out infinite;
}

.c2a-chatbot-typing__dot:nth-child(2) {
    animation-delay: 0.15s;
}

.c2a-chatbot-typing__dot:nth-child(3) {
    animation-delay: 0.3s;
}

/* ============================================================
   7. Quick Actions
   ============================================================ */
.c2a-chatbot-quick-actions {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    overflow-y: hidden;
    background: var(--c2a-chat-bg-solid);
    border-top: 1px solid var(--c2a-chat-border);
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

/* hide scrollbar but keep scrollable */
.c2a-chatbot-quick-actions::-webkit-scrollbar {
    height: 0;
    display: none;
}

.c2a-chatbot-quick-actions {
    scrollbar-width: none;
}

.c2a-chatbot-quick-actions__btn {
    flex-shrink: 0;
    padding: 7px 16px;
    border: 1.5px solid var(--c2a-chat-border);
    border-radius: var(--c2a-chat-radius-pill);
    background: var(--c2a-chat-white);
    color: var(--c2a-chat-primary-dark);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--c2a-chat-font);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    scroll-snap-align: start;
    user-select: none;
}

.c2a-chatbot-quick-actions__btn:hover {
    background: var(--c2a-chat-primary);
    color: var(--c2a-chat-white);
    border-color: var(--c2a-chat-primary);
    box-shadow: 0 2px 8px rgba(120, 181, 47, 0.3);
    transform: translateY(-1px);
}

.c2a-chatbot-quick-actions__btn:active {
    transform: translateY(0) scale(0.97);
}

.c2a-chatbot-quick-actions__btn i,
.c2a-chatbot-quick-actions__btn svg {
    margin-right: 4px;
    font-size: 12px;
}

/* ============================================================
   8. Input Area
   ============================================================ */
.c2a-chatbot-input-area {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 16px;
    background: var(--c2a-chat-white);
    border-top: 1px solid var(--c2a-chat-border);
    border-radius: 0 0 var(--c2a-chat-radius) var(--c2a-chat-radius);
}

.c2a-chatbot-input-area__field {
    flex: 1;
    min-height: 42px;
    max-height: 100px;
    padding: 10px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 21px;
    background: var(--c2a-chat-bg-solid);
    color: var(--c2a-chat-text);
    font-size: 14px;
    font-family: var(--c2a-chat-font);
    line-height: 1.45;
    resize: none;
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.c2a-chatbot-input-area__field::placeholder {
    color: var(--c2a-chat-text-muted);
    opacity: 0.7;
}

.c2a-chatbot-input-area__field:focus {
    border-color: var(--c2a-chat-primary);
    background: var(--c2a-chat-white);
    box-shadow: 0 0 0 3px rgba(120, 181, 47, 0.12);
}

.c2a-chatbot-input-area__send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c2a-chat-primary) 0%, var(--c2a-chat-primary-dark) 100%);
    color: var(--c2a-chat-white);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 2px 8px rgba(120, 181, 47, 0.3);
}

.c2a-chatbot-input-area__send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(120, 181, 47, 0.4);
}

.c2a-chatbot-input-area__send:active {
    transform: scale(0.94);
}

.c2a-chatbot-input-area__send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============================================================
   9. Welcome Message
   ============================================================ */
.c2a-chatbot-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 28px 24px 20px;
    animation: c2a-chatbot-fadeIn 0.5s 0.15s var(--c2a-chat-transition-smooth) both;
}

.c2a-chatbot-welcome__avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c2a-chat-primary), var(--c2a-chat-primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: var(--c2a-chat-white);
    margin-bottom: 14px;
    box-shadow: 0 4px 16px rgba(120, 181, 47, 0.3);
}

.c2a-chatbot-welcome__avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.c2a-chatbot-welcome__title {
    font-size: 17px;
    font-weight: 700;
    color: var(--c2a-chat-text);
    margin-bottom: 6px;
}

.c2a-chatbot-welcome__text {
    font-size: 13.5px;
    color: var(--c2a-chat-text-muted);
    line-height: 1.55;
    max-width: 300px;
}

/* ============================================================
   10. Utility & State Helpers
   ============================================================ */

/* stagger animation delay for multiple messages */
.c2a-chatbot-message:nth-child(1) { animation-delay: 0.05s; }
.c2a-chatbot-message:nth-child(2) { animation-delay: 0.12s; }
.c2a-chatbot-message:nth-child(3) { animation-delay: 0.19s; }
.c2a-chatbot-message:nth-child(4) { animation-delay: 0.26s; }

/* loading shimmer for bot messages */
.c2a-chatbot-message--loading .c2a-chatbot-message__bubble {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: c2a-chatbot-shimmer 1.5s ease-in-out infinite;
    min-height: 40px;
}

/* unread badge (for minimised state) */
.c2a-chatbot-unread-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #ef4444;
    color: var(--c2a-chat-white);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

/* ============================================================
   11. Responsive – Mobile
   ============================================================ */
@media (max-width: 768px) {
    .c2a-chatbot-overlay {
        display: block;
    }

    .c2a-chatbot-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .c2a-chatbot-window.is-open {
        border-radius: 0;
    }

    .c2a-chatbot-input-area {
        border-radius: 0;
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }

    .c2a-chatbot-header {
        padding: 14px 16px;
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .c2a-chatbot-messages {
        padding: 16px 12px;
    }

    .c2a-chatbot-message {
        max-width: 88%;
    }

    .c2a-chatbot-quick-actions {
        padding: 8px 12px;
    }

    .c2a-chatbot-input-area__field {
        font-size: 16px;       /* prevents iOS zoom on focus */
    }
}

/* ============================================================
   12. Reduced Motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .c2a-chatbot-window,
    .c2a-chatbot-window.is-open,
    .c2a-chatbot-message,
    .c2a-chatbot-typing__dot,
    .c2a-chatbot-welcome,
    .c2a-chatbot-header__status-dot {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
