:root {
    --font-main: 'Plus Jakarta Sans', sans-serif;
    /* Vibrant Color Palette */
    --primary: #4361ee;
    /* Vibrant Electric Blue */
    --primary-hover: #3a0ca3;
    --primary-gradient: linear-gradient(135deg, #4361ee 0%, #7209b7 100%);
    /* Blue to Purple */

    /* Header Colors (FIXED: White BG, Blue Text) */
    --header-bg: rgba(255, 255, 255, 0.85);
    --header-text: #4361ee;
    /* Blue Title Text */

    --secondary-bg: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-light: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --header-height: 72px;
    --radius-bubble: 18px;
}

/* Global Reset & Typography */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    color: var(--text-primary);
    background-color: #f1f5f9;
    overflow: hidden;
    /* Prevent scrolling on body, handle in wrapper */
    -webkit-font-smoothing: antialiased;
}

/* Vibrant Background Animation */
body::before {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    /* More vibrant background gradients */
    background:
        radial-gradient(circle at 15% 55%, rgba(67, 97, 238, 0.12), transparent 40%),
        radial-gradient(circle at 85% 15%, rgba(247, 37, 133, 0.08), transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(76, 201, 240, 0.05), transparent 60%);
    z-index: -1;
    pointer-events: none;
}

.wrapper {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    /* Dynamic viewport height for mobile browsers */
    width: 100%;
}

/* --- Header Styling (Glassmorphism) --- */
.main-header {
    height: var(--header-height);
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    /* Glass effect */
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    margin-left: 0 !important;
    flex-shrink: 0;
    width: 100%;
    /* Ensure full width */
    box-sizing: border-box;
    /* Ensure padding doesn't affect width */
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    transition: opacity 0.2s;
}

.brand-link:hover {
    opacity: 0.9;
}

.brand-link img {
    height: 90px;
    width: auto;
    transition: transform 0.2s ease;
}

.brand-link:hover img {
    transform: scale(1.05);
}

.header-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Centers text horizontally in the flex column */
    text-align: center;
    /* Ensures multi-line text is centered */
    font-size: 28px;
    color: var(--header-text);
    font-weight: 700;
    flex: 1;
    /* Allows the title to grow and fill the middle space */
}

.sub-title {
    font-size: 16px;
    font-weight: 400;
    opacity: 0.85;
}

/* --- Main Layout --- */
.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    margin-left: 0 !important;
    background: transparent !important;
    overflow: hidden;
    position: relative;
}

.chat-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.8);
    width: 100%;
    /* max-width: 1000px; */
    margin: 0 auto;
    overflow: hidden;
    position: relative;
}

/* --- Internal Chat Header --- */
.card-header-custom {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-light);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.bot-identity {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    /* Allow to take available space */
    min-width: 0;
    /* Prevent flex overflow */
}

.bot-details {
    display: flex;
    row-gap: 3px;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    /* width: 100%; */
    /* Text truncation support */
}

.bot-details h5 {
    margin: 0;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- NEW DROPDOWN STYLING --- */
.dropdown-row {
    display: flex;
    gap: 10px;
    margin-top: 2px;
    width: 100%;
    max-width: 500px;
}

.prompt-dropdown {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    font-size: 0.85rem;
    color: #334155;
    outline: none;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s ease;
}

.prompt-dropdown:hover:not(:disabled) {
    border-color: var(--primary);
    background: #fff;
}

.prompt-dropdown:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.prompt-dropdown:disabled {
    background-color: #e2e8f0;
    cursor: not-allowed;
    color: #94a3b8;
}

/* Tools Buttons */
.btn-tool-custom {
    border: 1px solid var(--border-light);
    background: white;
    color: var(--text-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-tool-custom:hover {
    background: var(--secondary-bg);
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
}

/* --- Chat Messages Area --- */
#chatBox {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background-color: #ffffff;
    /* Modern dot pattern */
    background-image: radial-gradient(#e2e8f0 1.5px, transparent 1.5px);
    background-size: 24px 24px;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
#chatBox::-webkit-scrollbar {
    width: 6px;
}

#chatBox::-webkit-scrollbar-track {
    background: transparent;
}

#chatBox::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 20px;
}

.message-row {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease-out;
    max-width: 80%;
    margin-top: 4px;
}

.message-row.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.bot .msg-avatar {
    background: #e0e7ff;
    color: var(--primary);
    border: 1px solid rgba(79, 70, 229, 0.1);
}

.user .msg-avatar {
    background: var(--primary);
    color: white;
}

.msg-bubble {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-bubble);
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
}

.bot .msg-bubble {
    background: white;
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    border-top-left-radius: 4px;
}

.user .msg-bubble {
    background: var(--primary-gradient);
    color: white;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

/* Markdown Content Styling */
.msg-bubble p {
    margin-bottom: 0.75rem;
}

.msg-bubble p:last-child {
    margin-bottom: 0;
}

.msg-bubble strong {
    font-weight: 700;
}

.msg-bubble ul,
.msg-bubble ol {
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.msg-bubble li {
    margin-bottom: 0.25rem;
}

.msg-bubble pre {
    background: #0f172a;
    color: #f8fafc;
    padding: 1rem;
    border-radius: 12px;
    overflow-x: auto;
    margin-top: 0.75rem;
    font-size: 0.85em;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.msg-bubble pre {
    background: #f9fafb;
    /* light background */
    color: #0f172a;
    /* dark readable text */
    padding: 1rem 1.25rem;
    border-radius: 12px;
    overflow-x: auto;
    margin-top: 0.75rem;
    font-size: 0.85em;
    border: 1px solid #e2e8f0;
    font-family: "JetBrains Mono", "Consolas", monospace;
}

/* Optional: inline code if any */
.msg-bubble code {
    background: transparent;
    color: inherit;
}

.msg-bubble pre {
    border-left: 4px solid var(--primary);
}

/* --- Typing Indicator --- */
.typing-container {
    display: none;
    margin-left: 58px;
    margin-bottom: 2rem;
}

.typing-bubble {
    background: white;
    border: 1px solid var(--border-light);
    padding: 12px 20px;
    border-radius: 20px;
    border-top-left-radius: 4px;
    display: inline-flex;
    gap: 6px;
    box-shadow: var(--shadow-sm);
}

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

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

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

/* --- Footer (Input Area) --- */
.chat-footer {
    background: white;
    padding: 1rem 1.5rem 0.5rem 1.5rem;
    /* Reduced bottom padding to accommodate disclaimer */
    /* Mobile Safe Area Fix */
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    z-index: 50;
}

/* Top Bar of Footer: Language */
.footer-tools {
    display: flex;
    align-items: center;
    gap: 12px;
}

.language-wrapper {
    flex-shrink: 0;
    position: relative;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 0 12px;
    height: 36px;
    display: flex;
    align-items: center;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.language-wrapper:hover,
.language-wrapper:focus-within {
    border-color: var(--primary);
    background: white;
}

#langSelect {
    background: transparent;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    padding-right: 4px;
}

/* Input Bar */
.input-group-custom {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 6px 8px 6px 12px;
    transition: all 0.2s;
    position: relative;
    column-gap: 10px;
}

.input-group-custom:focus-within {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

#questionInput {
    border: none;
    background: transparent;
    flex: 1;
    padding: 0 0;
    outline: none;
    font-size: 0.8rem;
    color: var(--text-primary);
    min-width: 0;
    /* Flexbox fix */
}

#questionInput::placeholder {
    color: #94a3b8;
}

.send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
    /* margin-left: 8px; */
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(67, 97, 238, 0.2);
}

.send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(67, 97, 238, 0.3);
}

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

.send-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Disclaimer Styling */
.ai-disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: #94a3b8;
    /* padding-top: 4px; */
    padding-bottom: 1px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.ai-disclaimer i {
    color: var(--primary);
    font-size: 0.8rem;
}

/* --- Responsive Design --- */
@media (max-width: 992px) {
    .content-wrapper {
        padding: 1rem;
    }
}

@media (max-width: 828px) {

    /* --- FORCE HEADER VISIBILITY FIX --- */
    .main-header {
        padding: 0 0.2rem;
        justify-content: space-between;
        /* Adjusted to keep logo and right icons apart */
        gap: 5px;
        display: flex !important;
        /* height: auto; */
        /* Force display in case adminlte hides it */
    }

    /* Override the inline style flex: 0 0 200px which was too wide for mobile */
    .main-header>div,
    .main-header>.right-actions {
        flex: 0 1 auto !important;
        /* Allow shrinking */
        width: auto !important;
        /* Reset fixed width */
        min-width: 0;
        /* Allow content to scale down */
    }

    .header-title {
        /* display: block; */
        font-size: 0.9rem;
        max-width: 100%;
        /* Allow full width available */
        overflow: hidden;
        text-overflow: ellipsis;
        position: static;
        transform: none;
        margin: 0 8px;
        /* Small gap between logo/icons */
        flex: 1;
        /* Make title take remaining space */
        line-height: 1.2;
    }

    .sub-title {
        font-size: 0.9rem;
        font-weight: 800;
        /* display: none; */
        /* Hide subtitle on mobile to save space */
    }

    .right-actions {
        margin-left: 0;
        /* Reset margins */
    }

    .brand-link img {
        height: 52px;
        padding: 0
            /* Smaller logo */
    }

    .content-wrapper {
        padding: 0;
        margin: 0 !important;
        height: calc(100dvh - var(--header-height));
        /* Ensure it fits exactly below header */
    }

    .chat-card {
        height: 100%;
        border-radius: 0;
        border: none;
        box-shadow: none;
        max-width: none;
    }

    .card-header-custom {
        padding: 0.3rem 0.5rem 0.5rem;
    }

    .bot-details h5 {
        font-size: 0.8rem;
        margin-bottom: 2px;
    }

    /* Responsive Dropdown */
    .dropdown-row {
        flex-direction: column;
        gap: 5px;
        width: 100%;
    }

    .prompt-dropdown {
        font-size: 0.75rem;
        padding: 4px 6px;
        width: 100%;
        margin: 0;
    }

    #chatBox {
        padding: 0.1rem;
    }

    .message-row {
        max-width: 98%;
        margin-bottom: 20px;
        gap: 5px
    }

    .msg-bubble {
        padding: 0.2rem 0.4rem;
        font-size: 0.8rem;
    }

    .chat-footer {
        padding: 0 0.2rem;
        gap: 0px
    }

    .input-group-custom {
        padding: 4px 6px 4px 10px;
        column-gap: 4px;
    }

    .send-btn {
        width: 34px;
        height: 34px;
        border-radius: 8px;
        margin-left: 0;
    }

    /* Stack tools on mobile */
    .footer-tools {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .language-wrapper {
        width: auto;
        max-width: 100%;
        height: 24px;
        padding: 0 4px;
    }
}

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

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

@keyframes bounce {

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

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

/* Powered By Watermark Styling */
.powered-by-watermark {
    position: fixed;
    bottom: 15px;
    left: 20px;
    /* ⬅ move to left */
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.8;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.powered-by-watermark:hover {
    opacity: 1;
}

.powered-by-text {
    font-size: 0.6rem;
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.powered-by-logo {
    height: 36px;
    /* ⬆ 50% bigger (24px → 36px) */
    width: auto;
    display: block;
}


/* Disclaimer Button Styling - FIXED Z-INDEX */
.btn-disclaimer-custom {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #6c757d;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
    height: 38px;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    /* Added */
    z-index: 5;
    /* Ensure it sits above adjacent elements */
    cursor: pointer;
}

.btn-disclaimer-custom:hover {
    background-color: #e9ecef;
    color: #343a40;
    border-color: #ced4da;
}

.dropdown-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    /* margin-top: 10px; */
    position: relative;
}

/* --- MEGA MENU STYLES --- */
.mega-dropdown-wrapper {
    position: relative;
    flex: 2;
    min-width: 150px;
    z-index: 4;
    /* Lower than disclaimer button */
}

.btn-mega-trigger {
    width: 100%;
    background-color: #fff;
    border: 1px solid #ced4da;
    padding: 2px 8px;
    /* Reduced padding slightly */
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #495057;
    font-weight: 500;
    font-size: 0.9rem;
    /* Slightly smaller trigger text */
    height: 38px;
}

.btn-mega-trigger:after {
    content: '\f078';
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 0.75em;
    color: #999;
}

.mega-menu-panel {
    display: none;
    position: absolute;
    top: 105%;
    left: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    width: 100%;
    min-width: 500px;
    height: 350px;
    overflow: hidden;
}

.mega-menu-flex {
    display: flex;
    height: 100%;
}

/* Left Column: Categories */
.categories-col {
    width: 35%;
    background-color: #f8f9fa;
    border-right: 1px solid #eee;
    overflow-y: auto;
    padding: 8px 0;
    /* Reduced padding */
}

.category-item {
    padding: 8px 12px;
    /* Smaller padding */
    cursor: pointer;
    font-size: 0.85rem;
    /* Smaller text */
    color: #555;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.category-item:hover,
.category-item.active {
    background-color: #fff;
    color: #007bff;
    border-left-color: #007bff;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

/* Right Column: Questions/Input */
.questions-col {
    width: 65%;
    padding: 12px;
    /* Reduced padding */
    overflow-y: auto;
    background-color: #fff;
}

.question-item {
    display: block;
    padding: 6px 10px;
    /* Smaller padding */
    margin-bottom: 5px;
    border-radius: 6px;
    background-color: #fff;
    border: 1px solid #eee;
    color: #333;
    font-size: 0.8rem;
    /* Smaller text */
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.question-item:hover {
    background-color: #f0f7ff;
    border-color: #cce5ff;
    color: #0056b3;
}

.empty-state-text {
    color: #999;
    text-align: center;
    margin-top: 50px;
    font-size: 0.85rem;
}

/* Show menu on hover */
.mega-dropdown-wrapper:hover .mega-menu-panel {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

/* Tax Calculator Styles inside Menu */
.tax-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}

.tax-input-label {
    font-size: 0.85rem;
    color: #495057;
    font-weight: 600;
}

.tax-helper-text {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 5px;
}





/* CSS BY FRONTEND TEAM */
/* ====================== */
/* ======================= */

.flex {
    display: flex;
    /* flex-direction: row; */
}

.align-flex-items-center {
    align-items: center
}

.mega-dropdown-wrapper.force-close .mega-menu-panel {
    display: none !important;
}

.question-item {
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.question-item.selected {
    background-color: rgba(59, 130, 246, 0.12);
    /* soft blue */
    color: #1e3a8a;
    font-weight: 500;
}

.question-item:hover {
    background-color: rgba(59, 130, 246, 0.08);
}


@media (max-width: 600px) {

    .flex {
        flex-direction: column;
    }

    .flex-row {
        flex-direction: row;
    }

    .btn-mega-trigger {
        width: 100%;
        font-size: 0.7rem;
        height: 24px;
    }

    .mega-menu-panel {
        min-width: 300px;
    }

    .category-item {
        padding: 4px;
        font-size: 0.8rem;
    }

    .brand-link {
        padding: 0;
    }

    .bot-details {
        row-gap: 5px
    }

    .mb-0 {
        margin-bottom: 0;
    }

    .ai-disclaimer {
        padding-bottom: 0;
    }
}

.padding-bottom-0-2rem {
    padding-bottom: 0;
}

.disclaimer-button {
    flex: 0 0 0;
}

.ml-38 {
    margin-left: 38px;
}