/* =============================================
   Claude AI Chatbot — Frontend Widget Styles
   ============================================= */

#cac-chatbot-root {
    --cac-primary: #6c5ce7;
    --cac-radius: 16px;
    --cac-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --cac-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-family: var(--cac-font);
    z-index: 999999;
}

/* Toggle wrapper — holds greeting + button */
.cac-toggle-wrap {
    position: fixed;
    bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 999999;
}
.cac-toggle-wrap.cac-pos-bottom-right {
    right: 24px;
    flex-direction: row;
}
.cac-toggle-wrap.cac-pos-bottom-left {
    left: 24px;
    flex-direction: row;
}

/* Greeting bubble */
.cac-greeting {
    background: #fff;
    color: #2d3436;
    padding: 10px 16px;
    border-radius: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    white-space: nowrap;
    animation: cacGreetingIn 0.5s ease 1s both;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.cac-greeting span {
    font-size: 14px;
    font-weight: 700;
    font-family: var(--cac-font);
}
.cac-greeting-close {
    background: none;
    border: none;
    color: #b2bec3;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 0 0 4px;
    font-weight: 700;
    transition: color 0.2s;
}
.cac-greeting-close:hover {
    color: #636e72;
}
.cac-greeting-hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}
@keyframes cacGreetingIn {
    from { opacity: 0; transform: translateY(8px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Toggle Button */
.cac-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--cac-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: var(--cac-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding: 0;
    overflow: hidden;
    flex-shrink: 0;
}
.cac-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}
.cac-toggle svg { width: 28px; height: 28px; fill: currentColor; }
.cac-toggle.cac-toggle-close {
    background: #636e72;
}
.cac-toggle.cac-toggle-close svg {
    width: 24px;
    height: 24px;
}

/* Chat Window */
.cac-window {
    position: fixed;
    width: 400px;
    height: 600px;
    min-width: 300px;
    min-height: 400px;
    max-width: 90vw;
    max-height: 90vh;
    background: #fff;
    border-radius: var(--cac-radius);
    box-shadow: var(--cac-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    resize: both;
}
.cac-window.cac-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Landing page shown first */
.cac-landing {
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
.cac-landing-hero {
    position: relative;
    background-color: var(--cac-primary);
    padding: 28px 24px 60px 24px;
    color: #fff;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background-size: cover;
    background-position: center;
}
.cac-landing-overlay {
    position: absolute;
    inset: 0;
    background: var(--cac-primary);
    opacity: 0.7;
    z-index: 0;
}
/* If no bg image, hide overlay and just use solid color */
.cac-landing-hero:not([style*="background-image"]) .cac-landing-overlay {
    display: none;
}
.cac-landing-logo {
    position: absolute;
    top: 16px;
    left: 20px;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    overflow: hidden;
}
.cac-landing-logo-text {
    width: 100%;
    height: 100%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    color: var(--cac-primary);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.cac-landing-logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.cac-landing-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.8;
    z-index: 2;
    padding: 4px;
    line-height: 1;
}
.cac-landing-close:hover { opacity: 1; }
.cac-landing-heading {
    position: relative;
    z-index: 1;
    font-size: 26px;
    font-weight: 800;
    line-height: 1.2;
    margin: 0 0 6px 0;
}
.cac-landing-sub {
    position: relative;
    z-index: 1;
    font-size: 15px;
    font-weight: 500;
    opacity: 0.9;
}

/* Chat prompt card overlapping hero */
.cac-landing-card {
    position: relative;
    margin: -32px 16px 0 16px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
    z-index: 2;
}
.cac-landing-card:hover {
    box-shadow: 0 6px 28px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}
.cac-landing-card-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cac-landing-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #2d3436;
}
.cac-landing-card-desc {
    font-size: 12px;
    font-weight: 500;
    color: #999;
}
.cac-landing-card-arrow {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--cac-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cac-landing-card-arrow svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* Bottom nav tabs */
.cac-landing-nav {
    display: flex;
    justify-content: center;
    gap: 48px;
    padding: 18px 16px 10px 16px;
}
.cac-landing-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    font-family: var(--cac-font);
    transition: color 0.2s;
}
.cac-landing-nav-item span {
    font-size: 12px;
    font-weight: 700;
}
.cac-landing-nav-item svg {
    width: 22px;
    height: 22px;
}
.cac-landing-nav-item.active svg { fill: var(--cac-primary); }
.cac-landing-nav-item.active span { color: var(--cac-primary); }
.cac-landing-nav-item:not(.active) svg { fill: #b2bec3; }
.cac-landing-nav-item:not(.active) span { color: #b2bec3; }

/* Chat view (hidden when landing is shown) */
.cac-chat-view {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.cac-chat-view.cac-active {
    display: flex;
}

/* Header — draggable (used in chat view) */
.cac-header {
    background: var(--cac-primary);
    color: #fff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}
.cac-header.cac-dragging {
    cursor: grabbing;
}
.cac-header-title {
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.cac-header-title::before {
    content: '';
    width: 10px;
    height: 10px;
    background: #55efc4;
    border-radius: 50%;
    display: inline-block;
}
.cac-back-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    padding: 4px 8px 4px 0;
    opacity: 0.8;
    line-height: 1;
}
.cac-back-btn:hover { opacity: 1; }
.cac-close-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    font-size: 22px;
    line-height: 1;
    font-weight: 700;
}
.cac-close-btn:hover { opacity: 1; }

/* Messages area */
.cac-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}
.cac-messages::-webkit-scrollbar { width: 5px; }
.cac-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.cac-bubble {
    max-width: 82%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.cac-bubble-user {
    align-self: flex-end;
    background: var(--cac-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.cac-bubble-assistant,
.cac-bubble-admin {
    align-self: flex-start;
    background: #fff;
    color: #2d3436;
    border: 1px solid #eee;
    border-bottom-left-radius: 4px;
}
.cac-bubble-admin {
    border-left: 3px solid #fdcb6e;
}
.cac-bubble-admin::before {
    content: '👤 Admin: ';
    font-weight: 700;
    font-size: 12px;
    color: #636e72;
}

/* Typing indicator */
.cac-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #eee;
}
.cac-typing span {
    width: 8px;
    height: 8px;
    background: #b2bec3;
    border-radius: 50%;
    animation: cacBounce 1.4s infinite ease-in-out both;
}
.cac-typing span:nth-child(1) { animation-delay: -0.32s; }
.cac-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes cacBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input area */
.cac-input-area {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
    gap: 8px;
}
.cac-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 600;
    outline: none;
    font-family: var(--cac-font);
    resize: none;
    max-height: 80px;
    line-height: 1.4;
}
.cac-input:focus {
    border-color: var(--cac-primary);
}
.cac-input::placeholder {
    font-weight: 500;
}
.cac-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--cac-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
}
.cac-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cac-send-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* Powered by */
.cac-powered {
    text-align: center;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #636e72;
    background: #fff;
    flex-shrink: 0;
    border-top: 1px solid #f0f0f0;
}
.cac-powered a {
    color: var(--cac-primary);
    text-decoration: none;
    font-weight: 700;
}
.cac-powered a:hover {
    text-decoration: underline;
}

/* Visitor info collection form */
.cac-info-form {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.cac-info-title {
    font-size: 14px;
    font-weight: 700;
    color: #2d3436;
    text-align: center;
}
.cac-info-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cac-info-field label {
    font-size: 12px;
    font-weight: 700;
    color: #636e72;
}
.cac-required {
    color: #e74c3c;
}
.cac-info-field input {
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--cac-font);
    outline: none;
    transition: border-color 0.2s;
}
.cac-info-field input:focus {
    border-color: var(--cac-primary);
}
.cac-info-error {
    font-size: 12px;
    font-weight: 600;
    color: #e74c3c;
    min-height: 16px;
    text-align: center;
}
.cac-info-submit {
    flex: 1;
    padding: 10px;
    background: var(--cac-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--cac-font);
    transition: opacity 0.2s;
}
.cac-info-submit:hover {
    opacity: 0.88;
}
.cac-info-actions {
    display: flex;
    gap: 8px;
}
.cac-info-cancel {
    flex: 1;
    padding: 10px;
    background: #f1f2f6;
    color: #2d3436;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--cac-font);
    transition: opacity 0.2s;
}
.cac-info-cancel:hover {
    opacity: 0.75;
}

/* Talk to Human bar */
.cac-human-bar {
    padding: 6px 16px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    text-align: center;
}
.cac-human-btn {
    background: none;
    border: 1px dashed #b2bec3;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 700;
    color: #636e72;
    cursor: pointer;
    font-family: var(--cac-font);
    transition: all 0.2s;
    width: 100%;
}
.cac-human-btn:hover {
    border-color: var(--cac-primary);
    color: var(--cac-primary);
    background: #f8f7ff;
}
.cac-human-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Waiting for human card */
.cac-waiting-card {
    background: linear-gradient(135deg, #f8f7ff, #eef0ff);
    border: 1px solid #d5d5ff;
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.cac-waiting-icon {
    font-size: 32px;
    position: relative;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cac-pulse {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--cac-primary);
    opacity: 0.2;
    animation: cacPulse 2s ease-in-out infinite;
}
@keyframes cacPulse {
    0%, 100% { transform: scale(0.8); opacity: 0.2; }
    50% { transform: scale(1.2); opacity: 0.1; }
}
.cac-waiting-title {
    font-size: 15px;
    font-weight: 700;
    color: #2d3436;
}
.cac-waiting-text {
    font-size: 13px;
    font-weight: 500;
    color: #636e72;
    line-height: 1.5;
}

/* Offline card */
.cac-offline-card {
    background: linear-gradient(135deg, #fff9e6, #fff4cc);
    border: 1px solid #ffeaa7;
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.cac-offline-icon {
    font-size: 32px;
}
.cac-offline-title {
    font-size: 15px;
    font-weight: 700;
    color: #2d3436;
}
.cac-offline-text {
    font-size: 13px;
    font-weight: 500;
    color: #636e72;
    line-height: 1.5;
}
.cac-offline-email-btn {
    display: inline-block;
    margin-top: 4px;
    padding: 8px 18px;
    background: var(--cac-primary);
    color: #fff !important;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    font-family: var(--cac-font);
    transition: opacity 0.2s;
}
.cac-offline-email-btn:hover {
    opacity: 0.85;
}

/* System messages */
.cac-system-msg {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #b2bec3;
    padding: 4px 8px;
    font-style: italic;
}

/* Restore conversation banner */
.cac-restore-banner {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.cac-restore-icon {
    font-size: 28px;
    line-height: 1;
}
.cac-restore-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cac-restore-text strong {
    font-size: 15px;
    font-weight: 700;
    color: #2d3436;
}
.cac-restore-text span {
    font-size: 13px;
    color: #636e72;
    font-weight: 500;
}
.cac-restore-actions {
    display: flex;
    gap: 8px;
    width: 100%;
}
.cac-restore-btn {
    flex: 1;
    padding: 9px 14px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    font-family: var(--cac-font);
    transition: opacity 0.2s;
}
.cac-restore-btn:hover {
    opacity: 0.85;
}
.cac-restore-load {
    background: var(--cac-primary);
    color: #fff;
}
.cac-restore-new {
    background: #f1f2f6;
    color: #2d3436;
}

/* History separator */
.cac-history-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0;
}
.cac-history-separator::before,
.cac-history-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ddd;
}
.cac-history-separator span {
    font-size: 11px;
    font-weight: 700;
    color: #b2bec3;
    text-transform: uppercase;
    white-space: nowrap;
}

/* History loader */
.cac-history-loader {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    align-self: flex-start;
}
.cac-loader-text {
    font-size: 13px;
    font-weight: 600;
    color: #636e72;
}

/* Resize handle hint */
.cac-window::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    z-index: 10;
}

/* Responsive */
@media (max-width: 480px) {
    .cac-window {
        width: calc(100vw - 16px) !important;
        height: calc(100vh - 80px) !important;
        top: 8px !important;
        left: 8px !important;
        right: auto !important;
        bottom: auto !important;
        border-radius: 12px;
        resize: none;
    }
    .cac-toggle-wrap { bottom: 16px; }
    .cac-toggle-wrap.cac-pos-bottom-right { right: 16px; }
    .cac-toggle-wrap.cac-pos-bottom-left { left: 16px; }
    .cac-greeting { display: none; }
}
