/* DigiWorld Premium Chat V2 - live-chat.css */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --digix-orange: #FF6B00;
    --digix-gradient: linear-gradient(135deg, #FF6B00 0%, #FF8800 100%);
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-lg: 0 10px 40px rgba(255, 107, 0, 0.15);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --text-dark: #1A1A1A;
    --text-gray: #666666;
    --bg-light: #F8F9FA;
    --success: #2ECC71;
}

/* Base Font */
.premium-chat-widget,
#digix-chat-widget {
    font-family: 'Outfit', sans-serif;
}

/* --- Floating Widget Container & Button --- */
#digix-chat-open-button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--digix-gradient);
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: white;
    font-size: 28px;
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    animation: softPulse 2s infinite;
}

/* Mobile: Position above bottom navigation */
@media (max-width: 768px) {
    #digix-chat-open-button {
        bottom: 100px !important;
        right: 20px;
        width: 56px;
        height: 56px;
        z-index: 9998;
    }
}

#digix-chat-open-button:hover {
    transform: scale(1.1);
    animation: none;
}

@keyframes softPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 107, 0, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(255, 107, 0, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 107, 0, 0);
    }
}

#digix-chat-open-button.hidden {
    display: none;
    /* Logic handles hiding this */
}

/* Notification Badge on Button */
.notification-badge-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: #FF3B30;
    border: 2px solid white;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s;
}

/* --- Chat Window --- */
#digix-chat-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    pointer-events: none;
    visibility: hidden;
    z-index: 9999;
}

#digix-chat-window:not(.hidden) {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
    visibility: visible;
    display: flex;
}

/* Mobile: Full viewport for widget */
@media (max-width: 768px) {
    #digix-chat-window {
        position: fixed !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
}

/* --- Premium Header Redesign --- */
.chat-header {
    background: linear-gradient(135deg, #f57224 0%, #ff4d4d 50%, #d4145a 100%);
    padding: 24px 24px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    z-index: 100;
    flex-shrink: 0;
    box-shadow: 0 4px 20px rgba(245, 114, 36, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Subtle background pattern/noise overlay */
.chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 60%);
    pointer-events: none;
    animation: headerGlow 8s infinite linear;
}

@keyframes headerGlow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 2;
}

.header-logo-wrapper {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.chat-header-logo {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(4px);
}

.status-dot-online {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background: #2ecc71;
    border: 2.5px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-title {
    margin: 0;
    font-weight: 800;
    font-size: 1.15rem;
    color: white;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 20px;
    width: fit-content;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: all 0.3s ease;
}

.status-badge:hover {
    background: rgba(255, 255, 255, 0.3);
}

.status-text {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.95);
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 rgba(255, 255, 255, 0.4);
    animation: pulseWhite 2s infinite;
}

@keyframes pulseWhite {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(255, 255, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 2;
}

.header-control-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backdrop-filter: blur(4px);
    position: relative; /* For icon positioning */
    overflow: hidden; /* For icon transitions */
}

.header-control-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.header-control-btn:active {
    transform: scale(0.95);
}

/* --- Icon Toggling for Night Mode --- */
#digix-theme-toggle {
    position: relative;
    overflow: hidden;
}

.theme-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Light Mode: Sun is hidden (rotated out), Moon is visible */
.sun-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(90deg) scale(0.5);
}

.moon-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}

/* Dark Mode: Sun is visible, Moon is hidden (rotated out) */
.dark-mode .sun-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}

.dark-mode .moon-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-90deg) scale(0.5);
}


/* --- Messages Area --- */
#digix-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: scroll !important;
    overflow-x: hidden !important;
    background: var(--bg-light);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-padding-top: 20px;
    -webkit-overflow-scrolling: touch;

    /* FORCE HIDE SCROLLBAR */
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

/* Hide scrollbar for ALL browsers */
#digix-chat-messages::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
}

/* Mobile: Ensure messages area is scrollable and visible */
@media (max-width: 768px) {
    #digix-chat-messages {
        padding: 15px;
        gap: 12px;
        min-height: 0;
        /* Allows flex children to shrink */
    }
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    animation: slideUp 0.3s ease-out forwards;
}

.message.bot {
    align-self: flex-start;
    background: white !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    border-bottom-left-radius: 4px;
    color: #2c3e50 !important;
    font-weight: 500;
}

.message.user {
    align-self: flex-end;
    background: var(--digix-gradient) !important;
    color: white !important;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 14px rgba(255, 107, 0, 0.3) !important;
    font-weight: 500;
}

/* Typing Indicator (Premium Glass & Wave) */
#digix-typing-indicator {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    align-self: flex-start;
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.4);
    width: fit-content;
    margin-bottom: 12px;
    margin-left: 20px;
    min-height: 24px;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

.dark-mode #digix-typing-indicator {
    background: rgba(40, 40, 40, 0.6);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

#digix-typing-indicator.hidden {
    display: none !important;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--digix-orange);
    border-radius: 50%;
    animation: typingWave 1.4s infinite ease-in-out both;
}

.dark-mode .typing-dot {
    background: linear-gradient(135deg, #FF6B00 0%, #FF8800 100%);
    box-shadow: 0 0 8px rgba(255, 107, 0, 0.4);
}

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

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

.typing-dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typingWave {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.6;
    }

    40% {
        transform: translateY(-5px);
        opacity: 1;
        box-shadow: 0 4px 8px rgba(255, 107, 0, 0.3);
    }
}

/* --- Input Area --- */
.chat-form {
    padding: 16px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 12px;
    align-items: center;
}

#digix-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #eee;
    border-radius: 24px;
    outline: none;
    font-family: inherit;
    font-size: 16px;
    /* Prevents iOS zoom on focus */
    transition: all 0.3s;
    background: #f8f9fa;
    resize: none;
    min-height: 20px;
    max-height: 100px;
}

#digix-chat-input:focus {
    border-color: var(--digix-orange);
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.1);
}

.send-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--digix-gradient);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    padding: 0;
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 107, 0, 0.3);
}

/* --- Pre Chat Form --- */
.pre-chat-form {
    padding: 40px 30px;
    text-align: center;
    background: white;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.pre-chat-form h4 {
    color: var(--digix-orange);
    font-size: 24px;
    margin-bottom: 8px;
}

.pre-chat-form input {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    /* Prevents iOS zoom */
    border: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 12px;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.submit-button {
    width: 100%;
    padding: 14px;
    background: var(--digix-gradient);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.submit-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 0, 0.3);
}

.submit-button:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

/* Modern Spinner for Loading State */
.submit-button.loading .btn-text {
    opacity: 0;
}

.submit-button.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
}

@keyframes spinner-rotate {
    to {
        transform: rotate(360deg);
    }
}

/* --- Secondary Button (View History) --- */
.secondary-button {
    background: transparent;
    border: 2px solid #eee;
    color: var(--text-gray);
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-button:hover {
    background: #f8f9fa;
    color: var(--digix-orange);
    border-color: var(--digix-orange);
}


/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    100% {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

/* Helper Class */
.hidden {
    display: none !important;
}

/* --- Dark Mode Styles --- */
.dark-mode#digix-chat-window {
    background: rgba(20, 20, 20, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
}

.dark-mode .pre-chat-form,
.dark-mode .chat-history {
    background: transparent !important;
    /* Let glass bg show */
    color: white;
}

.dark-mode .pre-chat-form h4 {
    color: white;
}

.dark-mode .pre-chat-form input {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.dark-mode .secondary-button {
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

.dark-mode .secondary-button:hover {
    border-color: var(--digix-orange);
    color: var(--digix-orange);
    background: rgba(255, 107, 0, 0.1);
}

.dark-mode #digix-chat-messages {
    background: transparent;
}

.dark-mode .message.bot {
    background: #2a2a2a;
    color: #eee;
    box-shadow: none;
}

.dark-mode .chat-form {
    background: rgba(0, 0, 0, 0.2);
    border-top-color: rgba(255, 255, 255, 0.1);
}

.dark-mode #digix-chat-input {
    background: rgba(255, 255, 255, 0.1);
    border-color: transparent;
    color: white;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 480px) {
    #digix-chat-open-button {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    #digix-chat-window {
        width: 100vw;
        /* Use fixed positioning with 0 insets for better mobile keyboard handling */
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100%;
        /* Fallback */
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        transform-origin: bottom center;
        /* Mobile Slide Up */
        transform: translateY(100%);
        z-index: 99999;
        /* Ensure it's on top */
    }

    #digix-chat-window:not(.hidden) {
        transform: translateY(0);
    }

    .chat-header {
        padding: 16px 20px;
        padding-top: max(16px, env(safe-area-inset-top));
        /* Safe area for Notch */
    }

    #digix-chat-messages {
        /* padding-bottom removed to allow flex layout to handle spacing */
        padding-bottom: 20px;
    }

    .chat-form {
        /* Position relative in flex container to sit above keyboard */
        position: relative;
        width: 100%;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid rgba(255, 255, 255, 0.5);
        box-sizing: border-box;
        padding: 12px 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        /* Safe area for Home Indicator */
        flex-shrink: 0;
    }

    .dark-mode .chat-form {
        background: rgba(20, 20, 20, 0.9);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .pre-chat-form {
        padding: 24px;
    }

    /* Fix Typing Indicator on Mobile (Float above Input) */
    #digix-typing-indicator {
        position: absolute;
        bottom: 85px;
        /* Sits above the absolute .chat-form */
        left: 20px;
        z-index: 200;
        margin: 0;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        /* Stronger shadow for floating element */
    }
}

/* --- Premium Chips (Quick Actions) --- */
.digix-options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    padding: 0 4px;
}

.digix-option-chip {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--text-dark);
    padding: 10px 18px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
    display: flex;
    align-items: center;
    gap: 6px;
    animation: fadeInUp 0.4s ease forwards;
    opacity: 0;
    transform: translateY(10px);
}

/* Staggered Animation */
.digix-option-chip:nth-child(1) {
    animation-delay: 0.1s;
}

.digix-option-chip:nth-child(2) {
    animation-delay: 0.2s;
}

.digix-option-chip:nth-child(3) {
    animation-delay: 0.3s;
}

.digix-option-chip:nth-child(4) {
    animation-delay: 0.4s;
}

.digix-option-chip:nth-child(5) {
    animation-delay: 0.5s;
}

.digix-option-chip:hover {
    background: var(--digix-gradient);
    color: white;
    border-color: transparent;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 15px rgba(255, 107, 0, 0.25);
}

.digix-option-chip:active {
    transform: translateY(-1px);
}

/* Dark Mode Chips */
.dark-mode .digix-option-chip {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
    backdrop-filter: blur(10px);
}

.dark-mode .digix-option-chip:hover {
    background: var(--digix-gradient);
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(255, 107, 0, 0.4);
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Reaction Picker --- */
.reaction-picker {
    display: flex;
    gap: 4px;
    background: white;
    border-radius: 20px;
    padding: 6px 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.reaction-emoji {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: transform 0.15s, background 0.15s;
}

.reaction-emoji:hover {
    transform: scale(1.3);
    background: rgba(255, 107, 0, 0.1);
}

.reactions-container {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.reaction {
    font-size: 12px;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.reaction:hover {
    background: #e0e0e0;
}

.reaction.user-reacted {
    background: rgba(255, 107, 0, 0.15);
    color: var(--digix-orange);
}

.dark-mode .reaction-picker {
    background: #2a2a2a;
}

.dark-mode .reaction {
    background: #333;
    color: #ccc;
}

.dark-mode .reaction.user-reacted {
    background: rgba(255, 107, 0, 0.25);
}