/* 0. GLOBAL RESET FOR PLUGIN */
.ai-popup *,
.ai-popup *::before,
.ai-popup *::after {
    box-sizing: border-box !important;
}

/* 1. FLOATING ROBOT BUTTON */
.ai-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, #3A0CA3, #4361EE);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    z-index: 999999 !important;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.ai-btn:hover {
    transform: scale(1.1);
}

.ai-btn.pulse {
    animation: pulse-blue 2s infinite;
}

@keyframes pulse-blue {
    0% {
        box-shadow: 0 0 0 0 rgba(58, 12, 163, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(58, 12, 163, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(58, 12, 163, 0);
    }
}

/* 2. CHAT WINDOW CONTAINER - STRICT HEIGHT */
.ai-popup {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 550px !important;
    /* Fixed total height */
    background: white;
    border-radius: 15px;
    display: none;
    flex-direction: column !important;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
    z-index: 1000000 !important;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden !important;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

/* Expanded State */
.ai-popup.ai-expanded {
    width: 90% !important;
    height: 90% !important;
    bottom: 5% !important;
    right: 5% !important;
    border-radius: 20px;
    max-width: 1400px;
}

.ai-popup.ai-expanded #aiassistant-history,
.ai-popup.ai-expanded #ai-history-items {
    max-height: none !important;
    /* Allow the chat area to fill the screen */
}

.ai-popup.ai-expanded .ai-footer::after {
    display: none;
    /* Hide hints to save vertical space in dashboard mode */
}

.ai-popup.ai-expanded .ai-footer {
    padding: 10px 20px;
    /* Slimmer footer in expanded mode */
}

.ai-main-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Fill the 550px */
    width: 100%;
    overflow: hidden;
}

/* 3. HEADER & QUICK ACTIONS - FIXED (NO SHRINK) */
.ai-header {
    background: #3A0CA3;
    color: white;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 0 0 auto !important;
}

.ai-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bot-name {
    font-weight: 600;
    font-size: 15px;
}

.ai-quick-actions {
    display: flex;
    gap: 8px;
    padding: 10px;
    background: #fff;
    border-bottom: 1px solid #eee;
    overflow-x: auto;
    flex: 0 0 auto !important;
    /* Cannot grow, cannot shrink */
}

/* 4. THE VIEWS CONTAINER */
.ai-view {
    flex: 1 1 auto !important;
    /* Take remaining space */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent the view itself from scrolling */
    height: 100%;
}

/* 5. THE SCROLLABLE CHAT AREA - THE FIX IS HERE */
#aiassistant-history,
#ai-history-items {
    flex: 1 1 0% !important;
    /* Force take all available space */
    overflow-y: scroll !important;
    /* Force scrollbar */
    overflow-x: hidden;
    padding: 15px;
    background: #f4f7f6;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-bottom: 1px solid #eee;
}

/* Custom Scrollbar Visibility */
#aiassistant-history::-webkit-scrollbar {
    width: 6px;
}

#aiassistant-history::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#aiassistant-history::-webkit-scrollbar-thumb {
    background: #bbb;
    border-radius: 10px;
}

#aiassistant-history::-webkit-scrollbar-thumb:hover {
    background: #3A0CA3;
}

/* 6. MESSAGE BUBBLES */
.msg {
    padding: 10px 14px;
    border-radius: 15px;
    font-size: 14px;
    max-width: 85%;
    line-height: 1.5;
    animation: slideIn 0.2s ease-out;
    word-wrap: break-word;
}

/* Table Container for scrolling */
.ai-table-container {
    width: 100% !important;
    overflow-x: auto !important;
    margin: 10px 0;
    border-radius: 8px;
    border: 1px solid #eee;
    background: #fff;
}

.ai-table-container table {
    width: 100%;
    min-width: 500px;
    /* Force minimum width to trigger scroll if needed */
    border-collapse: collapse;
}

.ai-table-container th,
.ai-table-container td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    /* Prevent text wrapping in tables to keep them wide */
}

.ai-table-container th {
    background: #f8f9fa;
    font-weight: 600;
    color: #3A0CA3;
}

/* Custom horizontal scrollbar for tables */
.ai-table-container::-webkit-scrollbar {
    height: 6px;
}

.ai-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ai-table-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.ai-table-container::-webkit-scrollbar-thumb:hover {
    background: #3A0CA3;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-ai {
    align-self: flex-start;
    background: white;
    color: #333;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.msg-user {
    align-self: flex-end;
    background: #3A0CA3;
    color: white;
    border-bottom-right-radius: 2px;
}

.msg-time {
    display: block;
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.6;
}

/* 7. FOOTER - FIXED AT BOTTOM */
.ai-footer {
    padding: 12px 15px;
    background: white;
    flex: 0 0 auto !important;
    /* Cannot grow, cannot shrink */
}

.ai-input-wrapper {
    display: flex !important;
    gap: 8px;
    align-items: center;
}

#aiassistant-input {
    flex: 1 !important;
    border: 1px solid #ddd !important;
    border-radius: 20px !important;
    padding: 8px 15px !important;
    font-size: 14px;
    outline: none !important;
    margin: 0 !important;
}

#aiassistant-send {
    background: #1BB9C9 !important;
    color: white !important;
    border: none !important;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Copy Button for AI Messages */
.ai-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.msg-ai {
    position: relative;
}

.msg-ai:hover .ai-copy-btn {
    opacity: 1;
}

.ai-copy-btn:hover {
    background: #f0f0f0;
    border-color: #3A0CA3;
}

.ai-copy-btn i {
    color: #3A0CA3;
}

/* Enhanced Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    font-size: 13px;
    color: #666;
}

.typing-indicator .dots {
    animation: dots-pulse 1.5s infinite;
}

.typing-indicator .eta {
    font-size: 11px;
    color: #999;
    margin-left: 5px;
}

@keyframes dots-pulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

/* 8. ROBOT ANIMATIONS */
.eye {
    width: 5px;
    height: 5px;
    background: #00ff00;
    border-radius: 50%;
    animation: blink 4s infinite;
}

@keyframes blink {

    0%,
    90%,
    100% {
        transform: scaleY(1);
    }

    95% {
        transform: scaleY(0.1);
    }
}

/* Keyboard Shortcut Hints */
.ai-footer::after {
    content: "Ctrl+K to toggle • Esc to close • Ctrl+L to clear";
    display: block;
    font-size: 10px;
    color: #999;
    text-align: center;
    padding: 4px 0;
    opacity: 0.7;
}

.bot-status {
    font-size: 10px;
    color: #00ff00;
}

.typing-indicator {
    display: none;
    margin-bottom: 5px;
}

.ai-quick-actions {
    display: flex;
    gap: 8px;
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    overflow-x: auto;
}

.quick-btn {
    white-space: nowrap;
    background: #ffffff;
    border: 1px solid #3A0CA3;
    color: #3A0CA3;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.quick-btn:hover {
    background: #3A0CA3;
    color: #ffffff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}


.eye {
    width: 6px;
    height: 6px;
    background: #00ff00;
    border-radius: 50%;
    box-shadow: 0 0 8px #00ff00;
}

/* Eyes Scanning Animation */
.left-eye {
    animation: robot-blink 3s infinite;
}

.right-eye {
    animation: robot-blink 3s infinite;
    animation-delay: 0.5s;
}

@keyframes robot-blink {

    0%,
    90%,
    100% {
        transform: scaleY(1);
        opacity: 1;
    }

    95% {
        transform: scaleY(0.1);
        opacity: 0.5;
    }
}

/* Navigation Icons Interaction */
.nav-icon {
    font-size: 18px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-icon:hover {
    color: #1BB9C9;
    transform: scale(1.2);
}

.nav-icon.active {
    color: white;
    transform: scale(1.1);
    filter: drop-shadow(0 0 5px #fff);
}

/* Header Profile Account */
.header-account {
    display: flex;
    align-items: center;
    position: relative;
    /* Removed scale to prevent flashing with dropdown */
}

#ai-header-avatar {
    object-fit: cover;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: transform 0.2s;
}

#ai-header-avatar:hover {
    transform: scale(1.1);
}

/* AI Dropdown Menu */
.ai-dropdown-menu {
    position: absolute;
    top: 40px;
    left: -56px;
    background: #ffffff !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.1) !important;
    width: 300px !important;
    /* Increased width for long emails */
    display: none;
    flex-direction: column;
    z-index: 1000100 !important;
    /* Extremely high z-index */
    overflow: hidden;
    animation: dropdownOpen 0.2s cubic-bezier(0.19, 1, 0.22, 1);
}

@keyframes dropdownOpen {
    from {
        opacity: 0;
        transform: translateY(-5px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ai-dropdown-menu.show {
    display: flex !important;
}

.dropdown-header {
    padding: 15px !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    background: #f8f9fa !important;
    border-bottom: 1px solid #eee !important;
}

.dropdown-header img {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    border: 2px solid white !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
}

.dropdown-header .user-info {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.dropdown-header .email {
    font-weight: 700 !important;
    font-size: 13px !important;
    color: #1a1a1a !important;
    word-break: break-all !important;
    /* Allow wrapping for long emails */
    white-space: normal !important;
    line-height: 1.3 !important;
}

.dropdown-header .status {
    font-size: 10px !important;
    color: #28a745 !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

/* Account List Styles */
#ai-accounts-list {
    max-height: 250px;
    overflow-y: auto;
}

.account-item {
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.account-item:last-child {
    border-bottom: none;
}

.account-item:hover {
    background: #f8f9fa;
}

.account-item.active {
    background: #eef2ff;
    border-left: 3px solid #3A0CA3;
}

.account-item .remove-account:hover {
    background: #fee;
    border-radius: 4px;
}

.dropdown-item {
    padding: 14px 18px !important;
    color: #333333 !important;
    /* High contrast black/gray */
    text-decoration: none !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    transition: all 0.2s !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    background: transparent !important;
    border: none !important;
}

.dropdown-item i {
    width: 18px !important;
    color: #4A5568 !important;
    /* Darker icons */
    font-size: 16px !important;
}

.dropdown-item:hover {
    background: #f0f4f8 !important;
    color: #3A0CA3 !important;
    text-decoration: none !important;
}

.dropdown-item.logout {
    color: #dc3545 !important;
    /* Red for logout */
    border-top: 1px solid #f0f0f0 !important;
}

.dropdown-item.logout:hover {
    background: #fff5f5 !important;
    color: #bd2130 !important;
}

.dropdown-item.logout i {
    color: #dc3545 !important;
}

/* Online status pulse */
.bot-status {
    font-size: 10px;
    color: #00ff00;
    font-weight: bold;
    margin-left: 2px;
}

@keyframes glow {
    from {
        opacity: 0.3;
    }

    to {
        opacity: 1;
    }
}

/* Quick Buttons Hover */
.quick-btn {
    cursor: pointer;
    transition: 0.3s;
}

.quick-btn:active {
    transform: scale(0.95);
}

/* Interactive Status Dot */

@keyframes status-pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Fix View Switching */
.ai-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Navigation Icons */
.nav-icon {
    font-size: 18px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    transition: 0.3s;
}

.nav-icon.active,
.nav-icon:hover {
    color: #ffffff;
    transform: scale(1.1);
}

/* History List Styling */
#ai-history-items {
    background: #f0f2f5;
}

.ai-history-item {
    background: white;
    padding: 12px 15px;
    border-radius: 10px;
    border: 1px solid #edf2f7;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-history-item:hover {
    border-color: #4361EE;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.1);
}

.ai-history-topic {
    font-weight: 600;
    color: #2D3748;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-history-meta {
    font-size: 11px;
    color: #718096;
}

#ai-history-detail {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding: 15px;
    background: #f4f7f6;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#ai-history-detail::-webkit-scrollbar {
    width: 4px;
}

#ai-history-detail::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.ai-stop-btn {
    align-self: center;
    margin: 10px 0;
    background: #d9534f;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

#aiassistant-history.drag-over,
#ai-history-detail.drag-over {
    background: #e9ecef !important;
    border: 2px dashed #4361EE !important;
}

#aiassistant-send.ai-stop-mode {
    background: #FF9F1C !important;
    /* Warning/Pause color */
    animation: pulse 1.5s infinite;
    cursor: pointer;
}

#aiassistant-send.ai-stop-mode i {
    transform: scale(1.1);
}

.ai-loading {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Robot Face */
.eye {
    width: 6px;
    height: 6px;
    background: #00ff00;
    border-radius: 50%;
    animation: blink 4s infinite;
}

@keyframes blink {

    0%,
    90%,
    100% {
        transform: scaleY(1);
    }

    95% {
        transform: scaleY(0.1);
    }
}

.quick-btn {
    white-space: nowrap;
    background: #fff;
    border: 1.5px solid #3A0CA3;
    color: #3A0CA3;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.quick-btn:hover,
.quick-btn:active {
    background: #3A0CA3;
    color: #fff;
}

/* Ensure the chat history doesn't hide behind the footer */
#aiassistant-history {
    padding-bottom: 20px;
}

/* Duplicates removed */

/* 1. The Container: Enable Horizontal Scroll */
.ai-quick-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    /* Force them to stay in one line */
    overflow-x: auto !important;
    /* Allow horizontal scrolling */
    overflow-y: hidden;
    gap: 12px;
    padding: 12px 15px;
    background: #fff;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;

    /* Smooth scrolling */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;

    /* Ensure it takes full width */
    width: 100%;
    box-sizing: border-box;
}

/* 2. Custom Thin Scrollbar (Visible for Desktop Users) */
.ai-quick-actions::-webkit-scrollbar {
    height: 6px;
    display: block !important;
    /* Force visibility */
}

.ai-quick-actions::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.ai-quick-actions::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.ai-quick-actions::-webkit-scrollbar-thumb:hover {
    background: #3A0CA3;
}

/* 3. The Buttons: Prevent squashing */
.quick-btn {
    flex: 0 0 auto !important;
    /* Don't grow, don't shrink */
    white-space: nowrap !important;
    /* Keep text on one line */
    background: #ffffff;
    border: 1px solid #e1e4e8;
    color: #444;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: none !important;
    /* Allow full sentence width */
    height: 36px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.quick-btn:hover {
    border-color: #3A0CA3;
    background: #f4f0ff;
    color: #3A0CA3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(58, 12, 163, 0.15);
}

/* Add a small purple pulse dot before the text */
.quick-btn::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #3A0CA3;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* 4. Visual Hint: Fade effect to show there is more to scroll */
.ai-quick-actions::after {
    content: "";
    padding-right: 20px;
    /* Adds space at the end so the last button isn't cut */
}

/* Mature Bubble Styling */
.msg-ai {
    background: #ffffff;
    border: 1px solid #edf2f7;
    border-radius: 18px 18px 18px 4px;
    /* Modern asymmetric shape */
    font-size: 14.5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.msg-user {
    background: linear-gradient(135deg, #3A0CA3, #4361EE);
    border-radius: 18px 18px 4px 18px;
    font-weight: 500;
    position: relative;
}

.ai-undo-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #FF9F1C;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.msg-user:hover .ai-undo-btn {
    display: flex;
}

/* Glassmorphism Quick Actions */
.ai-quick-actions {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    padding: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Better Scrollbar for the whole Chat */
#aiassistant-history::-webkit-scrollbar {
    width: 4px;
}

#aiassistant-history::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

/* Interactive Header */
.ai-header {
    background: #2a0a72;
    /* Deeper, more mature purple */
    padding: 15px 20px;
}

.ai-action-icon {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
}

.ai-action-icon:hover {
    color: #3A0CA3;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

/* Specific Style for Expand Button in deep purple header */
.ai-header .ai-action-icon {
    color: white;
    opacity: 0.8;
}

.ai-header .ai-action-icon:hover {
    opacity: 1;
    background: transparent;
}

/* FORCE SCROLLING FIX */
.ai-popup {
    height: 550px !important;
    max-height: 90vh !important;
}

.ai-view {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#aiassistant-history,
#ai-history-items {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    /* Remove the fixed max-height so it can expand in fullscreen mode */
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
}

.msg {
    flex-shrink: 0;
    /* Stop bubbles from squishing */
    margin-bottom: 10px;
}

#aiassistant-input {
    flex: 1 !important;
    border: 1px solid #ddd !important;
    border-radius: 15px !important;
    padding: 10px 15px !important;
    font-size: 14px;
    outline: none !important;
    resize: none !important;
    /* User can't manually resize */
    height: 40px;
    max-height: 120px;
    /* Allow it to grow to 4-5 lines */
    overflow-y: auto;
}

#aiassistant-history {
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    flex: 1 1 auto;
    /* Fill available space */
    padding-bottom: 30px !important;
    /* Space at bottom */
}

/* --- ACTION CARDS (NEW) --- */
.ai-action-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-top: 15px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-action-card .card-title {
    background: #3A0CA3;
    color: white;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
}

.ai-action-card .card-body {
    padding: 12px;
    font-size: 13px;
    color: #475569;
    line-height: 1.6;
    display: block;
}


.ai-action-card .card-footer {
    padding: 10px;
    display: flex;
    gap: 8px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

.ai-action-card button {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    border: none;
}

.confirm-btn {
    background: #10b981;
    color: white;
}

.confirm-btn:hover {
    background: #059669;
}

.cancel-btn {
    background: #e2e8f0;
    color: #475569;
}

.cancel-btn:hover {
    background: #cbd5e1;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

@media (max-width: 768px) {

    /* Full screen popup on mobile */
    .ai-popup {
        width: 100vw !important;
        height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        border-radius: 0 !important;
        max-height: 100vh !important;
    }

    /* Larger touch targets */
    .ai-btn {
        width: 56px;
        height: 56px;
        bottom: 20px;
        right: 20px;
    }

    /* Quick action buttons optimized for touch */
    .quick-btn {
        font-size: 12px !important;
        padding: 8px 12px !important;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .ai-quick-actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px;
    }

    /* Larger input area */
    #aiassistant-input {
        font-size: 16px !important;
        /* Prevents zoom on iOS */
        padding: 10px 15px !important;
    }

    /* Larger send button */
    #aiassistant-send {
        width: 44px !important;
        height: 44px !important;
    }

    /* Better message spacing */
    .msg {
        font-size: 14px !important;
        padding: 12px !important;
        margin: 8px 0 !important;
    }

    /* Action cards full width */
    .ai-action-card {
        margin: 10px 0 !important;
    }

    .ai-card-input {
        font-size: 16px !important;
        /* Prevents zoom */
        padding: 10px !important;
    }

    /* Hide keyboard shortcut hints on mobile */
    .ai-footer::after {
        display: none;
    }

    /* Copy button always visible on mobile */
    .ai-copy-btn {
        opacity: 1 !important;
    }
}

@media (max-width: 480px) {

    /* Extra small screens */
    .ai-header {
        padding: 10px 12px;
    }

    .bot-name {
        font-size: 14px;
    }

    .quick-btn {
        font-size: 11px !important;
        padding: 6px 10px !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

    /* Increase all interactive element sizes */
    button,
    .quick-btn,
    .confirm-btn,
    .cancel-btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Better tap feedback */
    button:active,
    .quick-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .ai-popup {
        height: 100vh !important;
    }

    .chat-area {
        max-height: calc(100vh - 200px) !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ai-popup {
        background: #1e293b;
        color: #e2e8f0;
    }

    .msg-ai {
        background: #334155;
        color: #e2e8f0;
    }

    .msg-user {
        background: #3A0CA3;
        color: white;
    }

    #aiassistant-input {
        background: #334155 !important;
        color: #e2e8f0 !important;
        border-color: #475569 !important;
    }

    .ai-action-card {
        background: #334155;
        border-color: #475569;
    }

    .ai-copy-btn {
        background: rgba(51, 65, 85, 0.9);
        border-color: #475569;
    }
}

.card-success {
    padding: 15px;
    background: #ecfdf5;
    color: #065f46;
    font-weight: 600;
    text-align: center;
}

.card-error {
    padding: 15px;
    background: #fef2f2;
    color: #991b1b;
    font-weight: 600;
    text-align: center;
}

/* --- MARKDOWN STYLING --- */
.msg-ai a,
.card-success a {
    color: #3A0CA3;
    text-decoration: none;
    font-weight: 700;
    border-bottom: 1px solid #3A0CA3;
    transition: all 0.2s;
}

.msg-ai a:hover,
.card-success a:hover {
    color: #4361EE;
    border-bottom-color: #4361EE;
}

.msg-ai ul,
.card-success ul {
    margin: 8px 0;
    padding-left: 18px;
    list-style-type: disc;
}

.msg-ai li,
.card-success li {
    margin-bottom: 4px;
}

.card-success {
    text-align: left !important;
    /* Reports look better left-aligned */
    font-size: 13px;
    line-height: 1.5;
}

/* Drag and Drop Styling */
#aiassistant-history.drag-over {
    border: 2px dashed #4361EE !important;
    background: rgba(67, 97, 238, 0.1) !important;
    position: relative;
    z-index: 10;
}

#aiassistant-history.drag-over::after {
    content: "📥 Drop files to upload";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: bold;
    color: #3A0CA3;
    box-shadow: 0 8px 25px rgba(58, 12, 163, 0.2);
    pointer-events: none;
    border: 1px solid #4361EE;
    font-size: 14px;
}

/* --- DESIGN PREVIEW CARD --- */
.design-preview-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-top: 15px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.preview-header {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
}

.preview-header span {
    font-weight: 600;
    color: #495057;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.preview-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.preview-btn {
    background: #3A0CA3;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.preview-btn:hover {
    background: #4361EE;
}

.preview-action-btn {
    background: white;
    border: 1px solid #dee2e6;
    color: #495057;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.preview-action-btn:hover {
    background: #e9ecef;
    color: #3A0CA3;
    border-color: #3A0CA3;
}

.preview-container {
    background: #fff;
    padding: 0;
    border-top: 1px solid #e2e8f0;
    height: 400px;
    position: relative;
    width: 100%;
}

.preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

    /* Increase all interactive element sizes for better touch targets */
    button,
    .quick-btn,
    .confirm-btn,
    .cancel-btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Better tap feedback */
    button:active,
    .quick-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }
}

/* AI Overlay */
.ai-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 100;
    padding: 20px;
    box-sizing: border-box;
}

.overlay-content h3 {
    margin: 15px 0 10px;
    color: #3A0CA3;
    font-size: 1.2rem;
}

.overlay-content p {
    font-size: 14px;
    color: #555;
    margin-bottom: 20px;
}

.activate-btn {
    background: linear-gradient(135deg, #3A0CA3 0%, #7209B7 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s;
}

.activate-btn:hover {
    transform: scale(1.05);
}

/* Settings View */
.settings-area {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    height: 100%;
}

.settings-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    border: 1px solid #e9ecef;
}

.settings-card h4 {
    margin: 0 0 10px 0;
    color: #3A0CA3;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.small-text {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 10px;
}

.key-box {
    background: #e9ecef;
    padding: 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
    word-break: break-all;
    margin-bottom: 10px;
    color: #495057;
}

.settings-info {
    font-size: 14px;
    font-weight: 500;
}

.status-active {
    color: #28a745;
}

.status-inactive {
    color: #dc3545;
}

.ai-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}