:root {
    --wnc-primary: #0056b3; /* Modern Blue */
    --wnc-primary-gradient: linear-gradient(135deg, #0056b3 0%, #004494 100%);
    --wnc-accent: #00a8ff;
    --wnc-text-light: #ffffff;
    --wnc-text-dark: #1c1e21;
    --wnc-glass-bg: rgba(255, 255, 255, 0.85);
    --wnc-glass-blur: blur(12px);
    --wnc-glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --wnc-shadow: 0 12px 28px 0 rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1);
    --wnc-font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

/* Reset & Base */
#wnc-chatbot-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: var(--wnc-font);
    line-height: 1.5;
}

#wnc-chatbot-container * {
    box-sizing: border-box;
}

/* Toggle Button */
#wnc-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--wnc-primary-gradient);
    color: var(--wnc-text-light);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    z-index: 1000001;
    /* Above chat window */
}

#wnc-toggle-btn:not(.wnc-open) {
    animation: wnc-pulse 2s infinite;
}

@keyframes wnc-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 86, 179, 0.4);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(0, 86, 179, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 86, 179, 0);
    }
}

#wnc-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#wnc-toggle-btn svg {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    position: absolute;
}

/* Icon States */
#wnc-toggle-btn.wnc-open .wnc-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

#wnc-toggle-btn.wnc-open .wnc-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

#wnc-toggle-btn .wnc-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

/* Chat Window - Desktop Default */
#wnc-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 360px;
    height: 600px;
    max-height: 80vh;
    background: var(--wnc-glass-bg);
    -webkit-backdrop-filter: var(--wnc-glass-blur);
    backdrop-filter: var(--wnc-glass-blur);
    border: var(--wnc-glass-border);
    border-radius: 16px;
    box-shadow: var(--wnc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 1;
    transform: translateY(0) scale(1);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1000000;
}

#wnc-chat-window.wnc-hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    pointer-events: none;
    visibility: hidden;
}

/* Header */
.wnc-header {
    background: var(--wnc-primary-gradient);
    color: var(--wnc-text-light);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.wnc-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wnc-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.wnc-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.wnc-avatar svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

.wnc-header-title {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.3px;
}

/* #wnc-close-btn removed */

.wnc-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

#wnc-refresh-btn,
#wnc-close-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#wnc-refresh-btn:hover,
#wnc-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Messages Area */
#wnc-messages {
    flex: 1;
    padding: 20px;
    /* padding-bottom removed as suggestions are now flex items */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

/* Scrollbar */
#wnc-messages::-webkit-scrollbar {
    width: 6px;
}

#wnc-messages::-webkit-scrollbar-track {
    background: transparent;
}

#wnc-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

#wnc-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Message Bubbles */
.wnc-message {
    max-width: 95%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    position: relative;
    animation: wnc-fade-in-up 0.2s ease forwards;
    word-wrap: break-word;
    line-height: 1.5;
}

@keyframes wnc-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wnc-message.user {
    align-self: flex-end;
    background: var(--wnc-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
    margin-bottom: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.wnc-message.bot {
    align-self: flex-start;
    background: #f0f2f5;
    color: var(--wnc-text-dark);
    border-bottom-left-radius: 4px;
    margin-bottom: 4px;
}

/* Seen Status */
.wnc-status {
    align-self: flex-end;
    font-size: 11px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.6);
    padding: 0 4px;
    margin-top: -4px;
    margin-bottom: 4px;
    margin-right: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wnc-status.visible {
    opacity: 1;
}

/* Thinking Animation */
.wnc-thinking {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
    background: #f0f2f5;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 10px;
}

.wnc-dot {
    width: 6px;
    height: 6px;
    background: #90949c;
    border-radius: 50%;
    animation: wnc-bounce 1.4s infinite ease-in-out both;
}

.wnc-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.wnc-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes wnc-bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Footer & Input */
.wnc-footer {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.3);
    border-top: var(--wnc-glass-border);
    position: relative;
    z-index: 20;
}

.wnc-input-area {
    display: flex;
    gap: 8px;
    align-items: center;
}

#wnc-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    outline: none;
    font-size: 15px;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.5);
    color: var(--wnc-text-dark);
}

#wnc-input:focus {
    background: #ffffff;
    border-color: var(--wnc-primary);
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.1);
}

#wnc-input:disabled {
    background: #e4e6eb;
    cursor: not-allowed;
    opacity: 0.7;
}

#wnc-send-btn {
    background: transparent;
    color: var(--wnc-primary);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#wnc-send-btn:hover {
    background: #f0f2f5;
}

#wnc-send-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

#wnc-send-btn:disabled {
    color: #bcc0c4;
    cursor: not-allowed;
    background: transparent;
}

.wnc-powered-by {
    text-align: center;
    font-size: 10px;
    color: #aaa;
    margin-top: 5px;
}

.wnc-powered-by a {
    color: #888;
    text-decoration: none;
    font-weight: 500;
}

.wnc-powered-by a:hover {
    text-decoration: underline;
    color: var(--wnc-primary);
}

/* Suggestions Container - Horizontal Layout */
.wnc-suggestions-container {
    /* Position static for flex layout */
    width: 100%;
    padding: 8px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: transparent;
    max-height: 120px;
    overflow-x: hidden;
    overflow-y: auto;
    flex-shrink: 0;
}

.wnc-suggestions-container::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.wnc-suggestions-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.wnc-chip {
    background: transparent;
    border: 1px solid var(--wnc-primary);
    color: var(--wnc-primary);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    white-space: nowrap;
    display: inline-block;
}

.wnc-chip:hover {
    background: var(--wnc-primary);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Markdown List Styling */
.wnc-message.bot ul,
.wnc-message.bot ol {
    margin: 4px 0 4px 5px;
    padding-left: 20px;
}

.wnc-message.bot ul {
    list-style-type: disc;
}

.wnc-message.bot ol {
    list-style-type: decimal;
}

.wnc-message.bot li {
    margin-bottom: 4px;
}

.wnc-message.bot p {
    margin: 0 0 8px 0;
}

/* Markdown Link Styling */
.wnc-message.bot a {
    color: var(--wnc-primary);
    text-decoration: underline;
    font-weight: 500;
    transition: all 0.2s ease;
}

.wnc-message.bot a:hover {
    color: #64ffda;
    text-decoration: none;
}

/* Markdown Italic Styling */
.wnc-message.bot em {
    font-style: italic;
    color: inherit;
}

/* Markdown Bold Styling */
.wnc-message.bot strong {
    font-weight: 700;
    color: var(--wnc-primary);
}

/* Responsive & Mobile Optimization */
@media screen and (max-width: 768px) {
    /* 1. Container remains minimal for button positioning only */
    #wnc-chatbot-container {
        bottom: 20px;
        right: 20px;
    }

    /* 2. Toggle Button adjustments */
    #wnc-toggle-btn {
        width: 56px;
        height: 56px;
    }

    #wnc-toggle-btn.wnc-open {
        display: none !important;
    }

    /* 3. Chat Window - Bottom Sheet Style */
    #wnc-chat-window {
        /* Break out of parent container positioning */
        position: fixed !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        
        /* Bottom Sheet Dimensions */
        width: 100vw !important;
        height: 85vh !important;
        height: 85dvh !important; /* Modern browsers */
        max-height: 100% !important;
        
        /* Reset all transforms and animations */
        transform: translateY(0) !important;
        transform-origin: bottom center !important;
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
        
        /* Force visibility when not hidden */
        opacity: 1 !important;
        visibility: visible !important;
        
        /* Styling */
        border-radius: 20px 20px 0 0 !important;
        border: none !important;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15) !important;
        
        /* Solid background */
        background: #ffffff !important;
        
        /* Ensure highest stacking */
        z-index: 2147483647 !important;
        
        /* Layout */
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    /* Hidden state - Slide down */
    #wnc-chat-window.wnc-hidden {
        transform: translateY(100%) !important;
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: none !important;
    }

    /* 4. Inner components adjustments */
    .wnc-header {
        flex-shrink: 0;
        padding: 14px 16px;
        padding-top: max(14px, env(safe-area-inset-top));
        border-radius: 20px 20px 0 0;
    }

    #wnc-messages {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto !important;
        overflow-x: hidden;
        padding: 16px;
        /* padding-bottom removed */
    }

    .wnc-footer {
        flex-shrink: 0;
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        background: #fff;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
    }

    .wnc-input-area input {
        font-size: 16px !important; /* Prevent iOS zoom */
    }
    
    /* Suggestions are now flex items */
    .wnc-suggestions-container {
        position: static;
        bottom: auto;
        left: auto;
        right: auto;
        padding: 8px 16px;
        justify-content: flex-start;
        z-index: auto;
        flex-shrink: 0;
    }

    .wnc-chip {
        font-size: 13px;
        padding: 8px 14px;
    }
}

/* Tablet Optimization */
@media screen and (min-width: 601px) and (max-width: 1024px) {
    #wnc-chat-window {
        width: 380px;
        max-width: calc(100vw - 40px);
        bottom: 90px;
        right: 20px;
    }
}