/**
 * Cart Bell Widget Styles - Modern Design
 * Clean, minimal, and professional
 */

:root {
    --cbw-primary: #25D366;
    --cbw-primary-dark: #128C7E;
    --cbw-primary-light: #dcfce7;
    --cbw-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    --cbw-shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --cbw-radius: 16px;
    --cbw-radius-lg: 24px;
    --cbw-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ===== Widget Container ===== */
.cart-bell-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: var(--cbw-font);
}

.cart-bell-widget.cart-bell-left {
    right: auto;
    left: 24px;
}

/* ===== Launcher Button ===== */
.cart-bell-launcher {
    width: 60px;
    height: 60px;
    background: var(--cbw-primary);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: none;
}

.cart-bell-launcher::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: var(--cbw-primary);
    opacity: 0.3;
    animation: cbw-pulse 2s ease-in-out infinite;
}

@keyframes cbw-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.15);
        opacity: 0;
    }
}

.cart-bell-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(37, 211, 102, 0.5);
}

.cart-bell-launcher:hover::before {
    animation: none;
    opacity: 0;
}

.cart-bell-launcher svg,
.cart-bell-launcher .dashicons {
    color: #fff;
    font-size: 28px;
    width: 28px;
    height: 28px;
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

/* Active state */
.cart-bell-widget.active .cart-bell-launcher {
    background: #1a1a2e;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transform: rotate(0);
}

.cart-bell-widget.active .cart-bell-launcher::before {
    display: none;
}

.cart-bell-widget.active .cart-bell-launcher svg,
.cart-bell-widget.active .cart-bell-launcher .dashicons {
    transform: rotate(45deg);
}

/* WhatsApp Icon SVG */
.cart-bell-launcher-icon {
    fill: #fff;
    width: 28px;
    height: 28px;
}

/* ===== Popup ===== */
.cart-bell-popup {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 48px);
    background: #fff;
    border-radius: var(--cbw-radius-lg);
    box-shadow: var(--cbw-shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
}

.cart-bell-widget.cart-bell-left .cart-bell-popup {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.cart-bell-popup.active {
    display: flex;
    animation: cbw-slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cbw-slide-up {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===== Header ===== */
.cart-bell-header {
    background: linear-gradient(135deg, var(--cbw-primary) 0%, var(--cbw-primary-dark) 100%);
    padding: 24px;
    color: #fff;
}

.cart-bell-header h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.cart-bell-header p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.cart-bell-close {
    display: none;
}

/* ===== Chat History ===== */
.cart-bell-chat-history {
    padding: 20px;
    background: #f8fafc;
}

.cart-bell-message {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: flex-start;
}

.cart-bell-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--cbw-primary-light) 0%, #d1fae5 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cbw-primary-dark);
    flex-shrink: 0;
}

.cart-bell-avatar svg {
    width: 18px;
    height: 18px;
}

.cart-bell-text {
    background: #fff;
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-size: 14px;
    color: #1e293b;
    line-height: 1.5;
    max-width: calc(100% - 48px);
}

/* ===== Department Selector ===== */
.cart-bell-department-selector {
    padding: 0 20px 16px;
    background: #f8fafc;
}

.cart-bell-department-selector label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cart-bell-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cart-bell-chip {
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.cart-bell-chip:hover {
    border-color: var(--cbw-primary);
    color: var(--cbw-primary-dark);
    background: var(--cbw-primary-light);
}

.cart-bell-chip.active {
    background: var(--cbw-primary);
    color: #fff;
    border-color: var(--cbw-primary);
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.25);
}

/* ===== Input Area ===== */
.cart-bell-input-area {
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cart-bell-input-area textarea {
    flex: 1;
    border: none;
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    height: 44px;
    max-height: 88px;
    transition: all 0.2s ease;
    color: #1e293b;
}

.cart-bell-input-area textarea::placeholder {
    color: #94a3b8;
}

.cart-bell-input-area textarea:focus {
    outline: none;
    background: #fff;
    box-shadow: inset 0 0 0 2px var(--cbw-primary);
}

.cart-bell-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--cbw-primary);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.cart-bell-send-btn:hover {
    background: var(--cbw-primary-dark);
    transform: scale(1.05);
}

.cart-bell-send-btn:active {
    transform: scale(0.95);
}

.cart-bell-send-btn svg,
.cart-bell-send-btn .dashicons {
    width: 20px;
    height: 20px;
    font-size: 20px;
}

/* ===== Footer ===== */
.cart-bell-footer {
    padding: 8px 20px;
    text-align: center;
    background: #f8fafc;
    font-size: 11px;
    color: #94a3b8;
    border-top: 1px solid #f1f5f9;
}

.cart-bell-footer a {
    color: inherit;
    text-decoration: none;
}

.cart-bell-footer a:hover {
    color: var(--cbw-primary);
}

/* ===== Mobile Responsive ===== */
@media (max-width: 480px) {
    .cart-bell-widget {
        bottom: 16px;
        right: 16px;
    }

    .cart-bell-widget.cart-bell-left {
        left: 16px;
    }

    .cart-bell-popup {
        width: calc(100vw - 32px);
        max-height: calc(100vh - 120px);
        border-radius: var(--cbw-radius);
    }

    .cart-bell-launcher {
        width: 56px;
        height: 56px;
    }

    .cart-bell-launcher svg,
    .cart-bell-launcher .dashicons {
        width: 24px;
        height: 24px;
        font-size: 24px;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .cart-bell-launcher::before {
        animation: none;
    }

    .cart-bell-popup.active {
        animation: none;
    }

    .cart-bell-launcher,
    .cart-bell-chip,
    .cart-bell-send-btn {
        transition: none;
    }
}

/* ===== Live Chat Specific Styles ===== */

/* Pre-chat form */
.cart-bell-prechat-form {
    padding: 20px;
    background: #f8fafc;
}

.cart-bell-prechat-intro {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: #475569;
}

.cart-bell-form-field {
    margin-bottom: 12px;
}

.cart-bell-form-field input,
.cart-bell-form-field select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    color: #1e293b;
    background: #fff;
    transition: all 0.2s ease;
}

.cart-bell-form-field input:focus,
.cart-bell-form-field select:focus {
    outline: none;
    border-color: var(--cbw-primary);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.cart-bell-form-field input::placeholder {
    color: #94a3b8;
}

.cart-bell-start-btn {
    width: 100%;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    margin-top: 8px;
    transition: all 0.2s ease;
}

.cart-bell-start-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Chat history for live chat */
.cart-bell-chat-history {
    max-height: 300px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.cart-bell-chat-history::-webkit-scrollbar {
    width: 6px;
}

.cart-bell-chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.cart-bell-chat-history::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.cart-bell-chat-history::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Customer messages (right-aligned) */
.cart-bell-message.customer {
    flex-direction: row-reverse;
}

.cart-bell-message.customer .cart-bell-text {
    background: var(--cbw-primary);
    color: #fff;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
}

/* Message time */
.cart-bell-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 4px;
    display: block;
}

.cart-bell-message.customer .cart-bell-time {
    text-align: right;
}

/* Sending state */
.cart-bell-message.sending .cart-bell-text {
    opacity: 0.7;
}

/* Failed state */
.cart-bell-message.failed .cart-bell-text {
    background: #fecaca;
    color: #dc2626;
}

.cart-bell-message.failed .cart-bell-text::after {
    content: ' (Failed to send)';
    font-size: 11px;
    opacity: 0.8;
}

/* Typing indicator */
.cart-bell-typing-indicator {
    padding: 8px 20px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-bell-typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: cbw-typing-bounce 1.4s infinite ease-in-out both;
}

.cart-bell-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.cart-bell-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes cbw-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.cart-bell-typing-text {
    font-size: 12px;
    color: #64748b;
    font-style: italic;
}

/* ===== Dark Mode Support ===== */
@media (prefers-color-scheme: dark) {
    .cart-bell-popup {
        background: #1e293b;
    }

    .cart-bell-chat-history,
    .cart-bell-department-selector {
        background: #0f172a;
    }

    .cart-bell-text {
        background: #334155;
        color: #f1f5f9;
    }

    .cart-bell-chip {
        background: #334155;
        border-color: #475569;
        color: #e2e8f0;
    }

    .cart-bell-chip:hover {
        background: var(--cbw-primary-dark);
    }

    .cart-bell-input-area {
        background: #1e293b;
        border-top-color: #334155;
    }

    .cart-bell-input-area textarea {
        background: #0f172a;
        color: #f1f5f9;
    }

    .cart-bell-input-area textarea:focus {
        background: #1e293b;
    }

    .cart-bell-footer {
        background: #0f172a;
        border-top-color: #334155;
    }

    /* Dark mode - Live chat specific */
    .cart-bell-prechat-form {
        background: #0f172a;
    }

    .cart-bell-prechat-intro {
        color: #94a3b8;
    }

    .cart-bell-form-field input,
    .cart-bell-form-field select {
        background: #334155;
        border-color: #475569;
        color: #f1f5f9;
    }

    .cart-bell-form-field input::placeholder {
        color: #64748b;
    }

    .cart-bell-typing-indicator {
        background: #0f172a;
    }

    .cart-bell-typing-dot {
        background: #64748b;
    }

    .cart-bell-typing-text {
        color: #94a3b8;
    }

    .cart-bell-time {
        color: #64748b;
    }

    .cart-bell-message.failed .cart-bell-text {
        background: #7f1d1d;
        color: #fca5a5;
    }
}

/* ===== Offline Mode Styles ===== */
.cart-bell-offline-notice {
    padding: 24px 20px;
    text-align: center;
    background: #f8fafc;
}

.cart-bell-offline-icon {
    margin-bottom: 12px;
}

.cart-bell-offline-icon svg {
    opacity: 0.8;
}

.cart-bell-offline-text {
    margin: 0;
    font-size: 14px;
    color: #475569;
    line-height: 1.5;
}

.cart-bell-offline-form {
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
}

.cart-bell-offline-form textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    color: #1e293b;
    background: #fff;
    resize: vertical;
    min-height: 80px;
    transition: all 0.2s ease;
}

.cart-bell-offline-form textarea:focus {
    outline: none;
    border-color: var(--cbw-primary);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.cart-bell-offline-form textarea::placeholder {
    color: #94a3b8;
}

/* ===== CTA Text Badge ===== */
.cart-bell-cta-text {
    position: absolute;
    right: 100%;
    margin-right: 12px;
    padding: 8px 16px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    animation: cbw-cta-bounce 2s ease-in-out infinite;
}

.cart-bell-widget.cart-bell-left .cart-bell-cta-text {
    right: auto;
    left: 100%;
    margin-right: 0;
    margin-left: 12px;
}

@keyframes cbw-cta-bounce {
    0%, 100% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(-4px);
    }
}

/* Hide CTA when widget is active */
.cart-bell-widget.active .cart-bell-cta-text {
    display: none;
}

/* ===== Success State ===== */
.cart-bell-success-message {
    padding: 32px 20px;
    text-align: center;
    background: #f0fdf4;
}

.cart-bell-success-message svg {
    margin-bottom: 12px;
}

.cart-bell-success-message h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #166534;
}

.cart-bell-success-message p {
    margin: 0;
    font-size: 14px;
    color: #15803d;
}

/* ===== Dark Mode - Offline Styles ===== */
@media (prefers-color-scheme: dark) {
    .cart-bell-offline-notice {
        background: #0f172a;
    }

    .cart-bell-offline-text {
        color: #94a3b8;
    }

    .cart-bell-offline-form {
        background: #1e293b;
        border-top-color: #334155;
    }

    .cart-bell-offline-form textarea {
        background: #334155;
        border-color: #475569;
        color: #f1f5f9;
    }

    .cart-bell-cta-text {
        background: #1e293b;
        color: #f1f5f9;
    }

    .cart-bell-success-message {
        background: #052e16;
    }

    .cart-bell-success-message h4 {
        color: #86efac;
    }

    .cart-bell-success-message p {
        color: #4ade80;
    }
}

/* ===== End Chat Button ===== */
.cart-bell-end-chat-area {
    padding: 8px 16px;
    background: #fafafa;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

.cart-bell-end-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cart-bell-end-btn:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

.cart-bell-end-btn svg {
    width: 14px;
    height: 14px;
}

/* Chat Ended State */
.cart-bell-chat-ended {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    text-align: center;
    background: #f9fafb;
}

.cart-bell-chat-ended-icon {
    width: 48px;
    height: 48px;
    background: #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.cart-bell-chat-ended-icon svg {
    width: 24px;
    height: 24px;
    color: #6b7280;
}

.cart-bell-chat-ended h4 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
}

.cart-bell-chat-ended p {
    margin: 0 0 16px;
    font-size: 14px;
    color: #6b7280;
}

.cart-bell-start-new-chat {
    padding: 10px 24px;
    background: var(--cbw-primary, #25D366);
    border: none;
    border-radius: 24px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cart-bell-start-new-chat:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}
