/* ============================================
   Jet-Chat Professional Chat UI Styles
   ChatGPT-like Design with Persian Support
   ============================================ */

/* === CSS Variables & Theme === */
:root {
    /* Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-tertiary: #ececf1;
    --bg-hover: #e5e5e9;
    --bg-sidebar: #f9fafb;
    --bg-sidebar-hover: #e5e7eb;
    --bg-message-user: #e8f0fe;
    --bg-message-bot: #ffffff;
    --bg-input: #ffffff;
    --bg-code: #1e1e1e;
    
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-inverse: #ffffff;
    --text-link: #2563eb;
    
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    
    --accent-primary: #2563eb;
    --accent-primary-hover: #1d4ed8;
    --accent-secondary: #8b5cf6;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    --sidebar-width: 280px;
    --header-height: 56px;
    --input-min-height: 52px;
    --input-max-height: 400px;
    
    --font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #212121;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #2d2d3a;
    --bg-hover: #3a3a4a;
    --bg-sidebar: #1a1a2e;
    --bg-sidebar-hover: #2d2d3a;
    --bg-message-user: #1e3a5f;
    --bg-message-bot: #2d2d3a;
    --bg-input: #2d2d3a;
    --bg-code: #0d1117;
    
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --text-inverse: #1a1a2e;
    --text-link: #60a5fa;
    
    --border-color: #3a3a4a;
    --border-light: #2d2d3a;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

/* === Header & Navigation === */
/* Header background - Light mode: dark gradient so text is visible */
#mainHeader.bg-gradient-primary {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #1d4ed8 100%) !important;
}

[data-theme="dark"] #mainHeader.bg-gradient-primary {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #1a1a2e 100%) !important;
}

/* Header nav links - Light mode: white text on dark background */
#mainHeader .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.88) !important;
    transition: color 0.15s ease;
}

#mainHeader .navbar-nav .nav-link:hover,
#mainHeader .navbar-nav .nav-link:focus {
    color: rgba(255, 255, 255, 1) !important;
}

#mainHeader .navbar-nav .nav-link.active {
    color: #ffffff !important;
}

/* Navbar brand text */
#mainHeader .navbar-brand {
    color: rgba(255, 255, 255, 0.95) !important;
}

/* Navbar toggler icon */
#mainHeader .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.3);
}

#mainHeader .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255,255,255,0.85)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Dropdown menu in header - RTL optimized */
#mainHeader .dropdown-menu {
    background-color: #1e3a5f;
    border-color: rgba(255, 255, 255, 0.1);
    /* RTL: Ensure dropdown opens from right to left */
    text-align: right;
    right: auto !important;
    left: auto !important;
}

/* RTL: dropdown-menu-start aligns to the right in RTL mode */
#mainHeader .dropdown-menu-start {
    right: 0 !important;
    left: auto !important;
}

#mainHeader .dropdown-item {
    color: rgba(255, 255, 255, 0.85);
    /* RTL: right-align text and icons */
    text-align: right;
    direction: rtl;
}

#mainHeader .dropdown-item:hover,
#mainHeader .dropdown-item:focus {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

#mainHeader .dropdown-divider {
    border-color: rgba(255, 255, 255, 0.1);
}

/* === Base Reset === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    inset: 0;
    width: 100%;
}

body {
    font-family: var(--font-family);
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Scrollbar Styling === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* === Layout === */
.app-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-header h5 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* New Chat Button */
.new-chat-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    margin-bottom: 8px;
}

.new-chat-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Chat History Items */
.chat-history-item {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    position: relative;
}

.chat-history-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}

.chat-history-item.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chat-history-item .history-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.chat-history-item .history-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-history-item .history-delete {
    opacity: 0;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.chat-history-item:hover .history-delete {
    opacity: 1;
}

.chat-history-item .history-delete:hover {
    background: var(--accent-danger);
    color: white;
}

/* === Main Content === */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
    background: var(--bg-primary);
}

/* === Chat Header === */
.chat-header {
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-primary);
    min-height: var(--header-height);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-header .header-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-header .header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-success);
    display: inline-block;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Header Buttons */
.header-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.header-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.header-btn.active {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

/* === Messages Area === */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.messages-wrapper {
    max-width: 768px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 40px 24px;
    text-align: center;
}

.welcome-logo {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    margin-bottom: 24px;
    box-shadow: 0 8px 32px rgba(37, 99, 235, 0.2);
}

.welcome-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.welcome-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
    max-width: 480px;
}

.welcome-suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    width: 100%;
    max-width: 600px;
}

.suggestion-card {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: right;
    background: var(--bg-primary);
}

.suggestion-card:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
}

.suggestion-card .suggestion-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
    display: block;
}

.suggestion-card .suggestion-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.suggestion-card .suggestion-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* === Message Bubbles === */
.message {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    animation: message-fade-in 0.3s ease;
}

@keyframes message-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-top: 4px;
}

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

.message.bot .message-avatar {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.message-content {
    flex: 1;
    min-width: 0;
    max-width: 85%;
}

.message.user .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    line-height: 1.7;
    font-size: 0.95rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--accent-primary);
    color: white;
    border-bottom-left-radius: var(--radius-sm);
}

.message.bot .message-bubble {
    background: var(--bg-message-bot);
    border: 1px solid var(--border-color);
    border-bottom-right-radius: var(--radius-sm);
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    padding: 0 4px;
}

.message.user .message-meta {
    flex-direction: row-reverse;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* === Markdown Content Styling === */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
    margin: 16px 0 8px;
    font-weight: 600;
    line-height: 1.4;
}

.message-bubble h1 { font-size: 1.3rem; }
.message-bubble h2 { font-size: 1.15rem; }
.message-bubble h3 { font-size: 1.05rem; }
.message-bubble h4 { font-size: 1rem; }

.message-bubble p {
    margin: 8px 0;
}

.message-bubble p:first-child {
    margin-top: 0;
}

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

.message-bubble ul,
.message-bubble ol {
    margin: 8px 0;
    padding-right: 24px;
}

.message-bubble li {
    margin: 4px 0;
}

.message-bubble blockquote {
    border-right: 3px solid var(--accent-primary);
    padding: 8px 16px;
    margin: 12px 0;
    background: var(--bg-secondary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}

.message-bubble code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    direction: ltr;
    display: inline-block;
}

.message.user .message-bubble code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.message-bubble pre {
    margin: 12px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    direction: ltr;
    text-align: left;
    position: relative;
}

.message-bubble pre code {
    display: block;
    padding: 16px;
    background: var(--bg-code);
    color: #e5e7eb;
    font-size: 0.85rem;
    line-height: 1.5;
    overflow-x: auto;
    border-radius: var(--radius-md);
}

.message-bubble pre .copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    opacity: 0;
}

.message-bubble pre:hover .copy-btn {
    opacity: 1;
}

.message-bubble pre .copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.9rem;
}

.message-bubble th,
.message-bubble td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: right;
}

.message-bubble th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.message-bubble tr:nth-child(even) {
    background: var(--bg-secondary);
}

.message-bubble a {
    color: var(--text-link);
    text-decoration: none;
}

.message-bubble a:hover {
    text-decoration: underline;
}

.message-bubble hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

.message-bubble img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 8px 0;
}

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

/* === Typing Indicator === */
.typing-indicator {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    animation: message-fade-in 0.3s ease;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
    background: var(--bg-message-bot);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-sm);
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing-bounce 1.4s infinite ease-in-out;
}

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

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* === Input Area === */
.input-area {
    padding: 16px 24px 24px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.input-container {
    max-width: 768px;
    margin: 0 auto;
    position: relative;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: var(--input-max-height);
    padding: 4px 0;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.input-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.input-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--accent-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.send-btn:hover {
    background: var(--accent-primary-hover);
    transform: scale(1.05);
}

.send-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* Upload Section */
.upload-section {
    margin-top: 8px;
    max-width: 768px;
    margin-left: auto;
    margin-right: auto;
}

.upload-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.upload-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.upload-panel {
    margin-top: 8px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: none;
    animation: slide-down 0.2s ease;
}

.upload-panel.open {
    display: block;
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.upload-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.upload-panel-header .upload-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.upload-panel-header .upload-info h6 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.upload-panel-header .upload-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

.upload-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.upload-btn {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-fast);
}

.upload-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.upload-btn.primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.upload-btn.primary:hover {
    background: var(--accent-primary-hover);
}

.upload-btn.success {
    background: var(--accent-success);
    border-color: var(--accent-success);
    color: white;
}

.upload-btn.success:hover {
    background: #059669;
}

.upload-status {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: none;
}

.upload-status.show {
    display: block;
}

.upload-status.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.upload-status.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.upload-status.info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* === Footer === */
.chat-footer {
    padding: 8px 24px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.chat-footer .footer-badges {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 4px;
}

.chat-footer .footer-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
}

/* === Modal Styles === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fade-in 0.2s ease;
}

.modal-overlay.open {
    display: flex;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modal-slide-up 0.3s ease;
}

@keyframes modal-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h5 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* === Toast Notifications === */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toast-slide-up 0.3s ease;
    max-width: 400px;
}

.toast.success {
    border-right: 4px solid var(--accent-success);
}

.toast.error {
    border-right: 4px solid var(--accent-danger);
}

.toast.info {
    border-right: 4px solid var(--accent-primary);
}

@keyframes toast-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Responsive === */
@media (max-width: 768px) {
    html, body {
        position: static;
        overflow: hidden;
        height: 100dvh;
    }

    .app-layout {
        height: 100dvh;
    }

    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        transform: translateX(100%);
        z-index: 200;
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 199;
        display: none;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .messages-wrapper {
        padding: 0 16px;
    }

    .input-area {
        padding: 12px 16px 16px;
    }

    .welcome-suggestions {
        grid-template-columns: 1fr;
    }

    .message-content {
        max-width: 90%;
    }

    .chat-header {
        padding: 10px 16px;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .message-content {
        max-width: 95%;
    }

    .message-bubble {
        padding: 10px 14px;
        font-size: 0.9rem;
    }

    .welcome-title {
        font-size: 1.2rem;
    }
}

/* === Subscription Badge === */
.subscription-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: #1a1a2e;
    font-weight: 600;
    margin-left: 8px;
}

[data-theme="dark"] .subscription-badge {
    background: linear-gradient(135deg, #b45309, #d97706);
    color: #fef3c7;
}

.subscription-badge .badge-text {
    white-space: nowrap;
}

/* === Guest Banner === */
.guest-banner {
    background: linear-gradient(135deg, #1e40af, #7c3aed);
    color: white;
    font-size: 0.85rem;
    z-index: 50;
    position: relative;
}

.guest-banner a {
    color: #fbbf24;
    text-decoration: underline;
}

.guest-banner a:hover {
    color: #f59e0b;
}

.guest-banner .btn-outline-light {
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
    padding: 2px 8px;
    font-size: 0.75rem;
}

.guest-banner .btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* === Utility Classes === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.d-none { display: none; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-grow-1 { flex-grow: 1; }
.w-100 { width: 100%; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }

/* ============================================
   Dataframe Selector Dropdown
   ============================================ */
.dataframe-selector {
    position: relative;
    display: inline-block;
}

.dataframe-toggle {
    display: flex !important;
    align-items: center;
    gap: 4px;
    padding: 6px 10px !important;
    font-size: 0.78rem !important;
}

.dataframe-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
    font-weight: 500;
}

.dataframe-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    width: 320px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    margin-top: 4px;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    direction: rtl;
}

.dataframe-dropdown .dropdown-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.dataframe-count {
    background: var(--accent-primary);
    color: white;
    padding: 1px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
}

.dataframe-dropdown .dropdown-search {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
}

.dropdown-search-input:focus {
    border-color: var(--accent-primary);
}

.dataframe-dropdown .dropdown-list {
    flex: 1;
    overflow-y: auto;
    max-height: 250px;
}

.dataframe-item {
    padding: 8px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dataframe-item:hover {
    background: var(--bg-hover);
}

.dataframe-item.active {
    background: var(--bg-message-user);
    border-right: 3px solid var(--accent-primary);
}

.dataframe-item-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.dataframe-item-info {
    flex: 1;
    min-width: 0;
}

.dataframe-item-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dataframe-item-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.dataframe-item-check {
    color: var(--accent-primary);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.dataframe-item-delete {
    color: var(--text-muted);
    font-size: 0.78rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0;
    transition: all 0.15s;
}

.dataframe-item:hover .dataframe-item-delete {
    opacity: 1;
}

.dataframe-item-delete:hover {
    color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.1);
}

.dataframe-dropdown .dropdown-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.dataframe-dropdown .dropdown-footer {
    padding: 8px 14px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
}

.dropdown-btn.refresh {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dropdown-btn.refresh:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Dark theme for dataframe selector */
[data-theme="dark"] .dataframe-dropdown {
    background: #1f2937;
    border-color: #374151;
}

[data-theme="dark"] .dataframe-item.active {
    background: #1e3a5f;
}

[data-theme="dark"] .dropdown-search-input {
    background: #111827;
    border-color: #374151;
    color: #e5e7eb;
}

[data-theme="dark"] .dataframe-item:hover {
    background: #374151;
}
