 
        :root {
            --bg-primary: #ffffff;
            --bg-secondary: #f7f7f8;
            --bg-tertiary: #ececf1;
            --bg-sidebar: #f7f7f8;
            --text-primary: #1f2937;
            --text-secondary: #6b7280;
            --text-muted: #9ca3af;
            --border-color: #e5e7eb;
            --accent-color: #10a37f;
            --user-message-bg: #f7f7f8;
            --ai-message-bg: #ffffff;
            --hover-color: #f9f9f9;
            --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }

        [data-theme="dark"] {
            --bg-primary: #343541;
            --bg-secondary: #444654;
            --bg-tertiary: #2a2b32;
            --bg-sidebar: #202123;
            --text-primary: #ececf1;
            --text-secondary: #acacbe;
            --text-muted: #8e8ea0;
            --border-color: #4d4d4f;
            --accent-color: #10a37f;
            --user-message-bg: #343541;
            --ai-message-bg: #444654;
            --hover-color: #2a2b32;
            --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            background-color: var(--bg-primary);
            color: var(--text-primary);
            line-height: 1.5;
            transition: background-color 0.3s, color 0.3s;
            height: 100vh;
            overflow: hidden;
        }

        .app-container {
            display: flex;
            height: 100vh;
        }

        /* Sidebar Styles */
        .sidebar {
            width: 260px;
            background-color: var(--bg-sidebar);
            border-right: 1px solid var(--border-color);
            display: flex;
            flex-direction: column;
            transition: transform 0.3s ease;
            z-index: 100;
        }

        .new-chat-btn {
            margin: 8px;
            padding: 12px;
            border: 1px solid var(--border-color);
            border-radius: 6px;
            background-color: transparent;
            color: var(--text-primary);
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 12px;
            transition: background-color 0.2s;
        }

        .new-chat-btn:hover {
            background-color: var(--hover-color);
        }

        .new-chat-btn i {
            font-size: 16px;
        }

        .history-section {
            flex: 1;
            overflow-y: auto;
            padding: 8px;
        }

        .history-date {
            font-size: 12px;
            color: var(--text-muted);
            padding: 12px 12px 4px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .history-item {
            padding: 12px;
            border-radius: 6px;
            cursor: pointer;
            margin-bottom: 2px;
            display: flex;
            align-items: center;
            gap: 12px;
            color: var(--text-secondary);
            transition: background-color 0.2s;
        }

        .history-item:hover {
            background-color: var(--hover-color);
        }

        .history-item i {
            font-size: 16px;
            color: var(--text-muted);
        }

        .history-item.active {
            background-color: var(--hover-color);
        }

        .sidebar-footer {
            padding: 12px;
            border-top: 1px solid var(--border-color);
        }

        .user-profile {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 8px;
            border-radius: 6px;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        .user-profile:hover {
            background-color: var(--hover-color);
        }

        .user-avatar {
            width: 28px;
            height: 28px;
            border-radius: 2px;
            background-color: var(--accent-color);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 14px;
            font-weight: bold;
        }

        .user-name {
            font-size: 14px;
            color: var(--text-primary);
        }

        /* Main Content */
        .main-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            position: relative;
        }

        .chat-header {
            padding: 12px 16px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: space-between;
            background-color: var(--bg-primary);
        }

        .menu-toggle {
            background: none;
            border: none;
            color: var(--text-primary);
            cursor: pointer;
            padding: 4px;
            border-radius: 4px;
            display: none;
        }

        .menu-toggle:hover {
            background-color: var(--hover-color);
        }

        .chat-title {
            font-size: 16px;
            font-weight: 600;
            color: var(--text-primary);
        }

        .header-actions {
            display: flex;
            gap: 8px;
        }

        .header-btn {
            background: none;
            border: none;
            color: var(--text-primary);
            cursor: pointer;
            padding: 6px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .header-btn:hover {
            background-color: var(--hover-color);
        }

        .chat-container {
            flex: 1;
            overflow-y: auto;
            padding: 0;
            background-color: var(--bg-primary);
        }

        /* Welcome Section */
        .welcome-section {
            max-width: 768px;
            margin: 0 auto;
            padding: 48px 24px;
            text-align: center;
        }

        .welcome-title {
            font-size: 32px;
            font-weight: 600;
            margin-bottom: 16px;
            color: var(--text-primary);
        }

        .welcome-subtitle {
            font-size: 20px;
            color: var(--text-secondary);
            margin-bottom: 40px;
        }

        .capabilities-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 16px;
            margin-bottom: 40px;
        }

        .capability-card {
            padding: 16px;
            border-radius: 8px;
            background-color: var(--bg-secondary);
            text-align: left;
        }

        .capability-icon {
            margin-bottom: 12px;
            color: var(--accent-color);
        }

        .capability-title {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 4px;
            color: var(--text-primary);
        }

        .capability-desc {
            font-size: 14px;
            color: var(--text-secondary);
        }

        .examples-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 16px;
        }

        .example-card {
            padding: 16px;
            border-radius: 8px;
            background-color: var(--bg-secondary);
            cursor: pointer;
            transition: background-color 0.2s;
        }

        .example-card:hover {
            background-color: var(--hover-color);
        }

        .example-text {
            font-size: 14px;
            color: var(--text-secondary);
        }

        /* Messages */
        .message {
            padding: 24px 0;
            margin-top: 30px;
            max-width: 768px;
            margin: 0 auto;
            border-radius: 20px;
            
        }

        .message:last-child {
            border-bottom: none;
        }

        .message-user {
            background-color: var(--user-message-bg);
        }

        .message-ai {
            background-color: var(--ai-message-bg);
           
        }

        .message-container {
            max-width: 768px;
            margin: 0 auto;
            padding: 0 24px;
            display: flex;
            gap: 24px;
        }

        .message-avatar {
            width: 30px;
            height: 30px;
            border-radius: 2px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            flex-shrink: 0;
        }

        .user-avatar {
            background-color: #5436DA;
            color: white;
                border-radius: 50%;
        }

        .ai-avatar {
            background-color: var(--accent-color);
            color: white;
                border-radius: 50%;
        }

        .message-content {
            flex: 1;
            padding-top: 4px;
        }

        .message-text {
            white-space: pre-wrap;
            line-height: 1.6;
        }

        .message-actions {
            display: flex;
            gap: 12px;
            margin-top: 12px;
        }

        .message-action {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 14px;
            display: flex;
            align-items: center;
            gap: 4px;
            padding: 4px 8px;
            border-radius: 4px;
            transition: color 0.2s, background-color 0.2s;
        }

        .message-action:hover {
            color: var(--text-primary);
            background-color: var(--hover-color);
        }

        /* Input Area */
        .input-container {
            max-width: 768px;
            margin: 0 auto;
            padding: 16px 24px 24px;
        }

        .input-box {
            position: relative;
            border: 1px solid var(--border-color);
            border-radius: 12px;
            background-color: var(--bg-primary);
            box-shadow: 0 0 0 0 transparent;
            transition: box-shadow 0.2s, border-color 0.2s;
        }

        .input-box:focus-within {
            border-color: var(--accent-color);
            box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.2);
        }

        .message-input {
            width: 100%;
            border: none;
            outline: none;
            background: transparent;
            color: var(--text-primary);
            padding: 16px 48px 16px 16px;
            resize: none;
            min-height: 60px;
            max-height: 200px;
            font-family: inherit;
            font-size: 16px;
            line-height: 1.5;
        }

        .message-input::placeholder {
            color: var(--text-muted);
        }

        .send-button {
            position: absolute;
            bottom: 12px;
            right: 12px;
            background: var(--accent-color);
            color: white;
            border: none;
            border-radius: 6px;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        .send-button:hover {
            background-color: #0d8f6d;
        }

        .send-button:disabled {
            background-color: var(--text-muted);
            cursor: not-allowed;
        }

        .input-footer {
            text-align: center;
            margin-top: 12px;
        }

        .disclaimer {
            font-size: 12px;
            color: var(--text-muted);
        }

        /* Thinking Indicator */
        .thinking-indicator {
            display: flex;
            align-items: center;
            gap: 8px;
            color: var(--text-muted);
            font-size: 14px;
        }

        .thinking-dots {
            display: flex;
            gap: 4px;
        }

        .thinking-dots span {
            width: 4px;
            height: 4px;
            border-radius: 50%;
            background-color: var(--text-muted);
            animation: pulse 1.5s infinite ease-in-out;
        }

        .thinking-dots span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .thinking-dots span:nth-child(3) {
            animation-delay: 0.4s;
        }

        @keyframes pulse {

            0%,
            100% {
                opacity: 0.4;
            }

            50% {
                opacity: 1;
            }
        }

        /* Constitution Content Styles */
        .constitution-content {
            max-width: 768px;
            margin: 0 auto;
            padding: 24px;
        }

        .chapter-card {
            background-color: var(--bg-secondary);
            border-radius: 8px;
            padding: 16px;
            margin-bottom: 16px;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        .chapter-card:hover {
            background-color: var(--hover-color);
        }

        .chapter-title {
            font-size: 18px;
            font-weight: 600;
            margin-bottom: 8px;
            color: var(--text-primary);
        }

        .chapter-desc {
            font-size: 14px;
            color: var(--text-secondary);
        }

        .search-box {
            background-color: var(--bg-secondary);
            border-radius: 12px;
            padding: 24px;
            margin-bottom: 24px;
        }

        .search-input-group {
            display: flex;
            gap: 12px;
            margin-bottom: 16px;
        }

        .search-input {
            flex: 1;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 12px 16px;
            background-color: var(--bg-primary);
            color: var(--text-primary);
            font-size: 16px;
        }

        .search-input:focus {
            outline: none;
            border-color: var(--accent-color);
        }

        .search-btn {
            background-color: var(--accent-color);
            color: white;
            border: none;
            border-radius: 8px;
            padding: 12px 24px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.2s;
        }

        .search-btn:hover {
            background-color: #0d8f6d;
        }

        .filter-row {
            display: flex;
            gap: 12px;
        }

        .filter-select,
        .filter-input {
            flex: 1;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 12px;
            background-color: var(--bg-primary);
            color: var(--text-primary);
        }

        .filter-select:focus,
        .filter-input:focus {
            outline: none;
            border-color: var(--accent-color);
        }

        .search-results {
            margin-top: 24px;
        }

        .result-item {
            background-color: var(--bg-secondary);
            border-radius: 8px;
            padding: 16px;
            margin-bottom: 12px;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        .result-item:hover {
            background-color: var(--hover-color);
        }

        .result-title {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 8px;
            color: var(--text-primary);
        }

        .result-preview {
            font-size: 14px;
            color: var(--text-secondary);
        }

        /* Toast */
        .toast-container {
            position: fixed;
            top: 16px;
            right: 16px;
            z-index: 1050;
        }

        .toast {
            background-color: var(--bg-primary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 12px 16px;
            box-shadow: var(--shadow);
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 8px;
            animation: slideIn 0.3s ease;
        }

        @keyframes slideIn {
            from {
                transform: translateX(100%);
                opacity: 0;
            }

            to {
                transform: translateX(0);
                opacity: 1;
            }
        }

        .toast-message {
            font-size: 14px;
            color: var(--text-primary);
        }

        .toast-close {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            padding: 4px;
            border-radius: 4px;
        }

        .toast-close:hover {
            color: var(--text-primary);
            background-color: var(--hover-color);
        }

        /* Mobile Responsive */
        @media (max-width: 768px) {
            .sidebar {
                position: absolute;
                transform: translateX(-100%);
                height: inherit;
            }

            .sidebar.open {
                transform: translateX(0);
            }

            .menu-toggle {
                display: block;
            }

            .capabilities-grid,
            .examples-grid {
                grid-template-columns: 1fr;
            }

            .message-container {
                padding: 0 16px;
            }

            .input-container {
                padding: 16px 16px 24px;
            }

            .filter-row {
                flex-direction: column;
            }
        }


        /* Add these styles to your existing CSS */

        /* Search Results Styles */
        .article-item {
            background-color: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 16px;
            margin-bottom: 12px;
            cursor: pointer;
            transition: background-color 0.2s, border-color 0.2s;
        }

        .article-item:hover {
            background-color: var(--hover-color);
            border-color: var(--accent-color);
        }

        .article-title {
            font-weight: 600;
            font-size: 1.1em;
            color: var(--text-primary);
            margin-bottom: 8px;
        }

        .article-preview {
            color: var(--text-secondary);
            line-height: 1.5;
            margin-bottom: 8px;
        }

        .text-muted {
            color: var(--text-muted) !important;
        }

        /* Highlight for search terms */
        .highlight {
            background-color: var(--accent-color);
            color: white;
            padding: 2px 4px;
            border-radius: 3px;
        }

        [data-theme="dark"] .highlight {
            background-color: #0d8f6d;
            color: var(--text-primary);
        }

        /* Badge styles */
        .badge {
            font-size: 0.75em;
            font-weight: 500;
            padding: 4px 8px;
            border-radius: 4px;
        }

        .bg-primary {
            background-color: var(--accent-color) !important;
        }

        .bg-secondary {
            background-color: var(--text-muted) !important;
        }

        /* Modal Styles */
        .modal-content {
            background-color: var(--bg-primary);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            box-shadow: var(--shadow);
        }

        .modal-header {
            background-color: var(--bg-secondary);
            border-bottom: 1px solid var(--border-color);
            padding: 10px 24px;
        }

        .modal-title {
            color: var(--text-primary);
            font-weight: 600;
            font-size: 1.25em;
        }

        .modal-body {
            background-color: var(--bg-primary);
            color: var(--text-primary);
            padding: 24px;
        }

        .modal-footer {
            background-color: var(--bg-secondary);
            border-top: 1px solid var(--border-color);
            padding: 16px 24px;
        }

        .btn-close {
            filter: invert(0.5);
        }

        [data-theme="dark"] .btn-close {
            filter: invert(0.8);
        }

        .btn-close:hover {
            filter: invert(0.3);
        }

        [data-theme="dark"] .btn-close:hover {
            filter: invert(1);
        }

        /* Button Styles */



        /* Alert Styles */
        .alert {
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 16px;
            margin-bottom: 16px;
        }

        .alert-warning {
            background-color: rgba(245, 158, 11, 0.1);
            color: var(--text-primary);
        }

        .alert-danger {
            background-color: rgba(239, 68, 68, 0.1);
            color: var(--text-primary);
        }

        .alert-info {
            background-color: rgba(16, 163, 127, 0.1);
            color: var(--text-primary);
        }

        /* Pagination Styles */
        .pagination {
            margin-bottom: 0;
        }

        .page-link {
            background-color: var(--bg-secondary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            padding: 8px 16px;
            transition: all 0.2s;
        }

        .page-link:hover {
            background-color: var(--hover-color);
            border-color: var(--accent-color);
            color: var(--text-primary);
        }

        .page-item.active .page-link {
            background-color: var(--accent-color);
            border-color: var(--accent-color);
            color: white;
        }

        .page-item.disabled .page-link {
            background-color: var(--bg-tertiary);
            color: var(--text-muted);
            border-color: var(--border-color);
        }

        /* Loading Spinner */
        .loading-spinner {
            text-align: center;
            padding: 40px;
            color: var(--text-secondary);
        }

        .spinner-border.text-primary {
            color: var(--accent-color) !important;
        }

        /* Backdrop for modal */
        .modal-backdrop {
            background-color: rgba(0, 0, 0, 0.5);
        }

        [data-theme="dark"] .modal-backdrop {
            background-color: rgba(0, 0, 0, 0.7);
        }

        /* Article content in modal */
        .article-content {
            line-height: 1.6;
            color: var(--text-primary);
        }

        .article-content p {
            margin-bottom: 16px;
        }

        .article-meta {
            padding-bottom: 16px;
            border-bottom: 1px solid var(--border-color);
        }

        /* Constitution content specific styles */
        .constitution-content h2 {
            color: var(--text-primary);
            margin-bottom: 24px;
        }

        .constitution-content h4 {
            color: var(--text-primary);
            margin-bottom: 16px;
        }

        /* Search box enhancements */
        .search-box {
            background-color: var(--bg-secondary);
            border-radius: 12px;
            padding: 24px;
            margin-bottom: 24px;
            border: 1px solid var(--border-color);
        }

        .search-input {
            background-color: var(--bg-primary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
        }

        .search-input:focus {
            border-color: var(--accent-color);
            background-color: var(--bg-primary);
            color: var(--text-primary);
        }

        .filter-select,
        .filter-input {
            background-color: var(--bg-primary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
        }

        .filter-select:focus,
        .filter-input:focus {
            border-color: var(--accent-color);
            background-color: var(--bg-primary);
            color: var(--text-primary);
        }

        /* Toast container */
        .toast-container .toast {
            background-color: var(--bg-primary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
        }

        /* Fade in animation */
        .fade-in {
            animation: fadeIn 0.3s ease-in;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* Scrollbar styling */
        ::-webkit-scrollbar {
            width: 6px;
        }

        ::-webkit-scrollbar-track {
            background: var(--bg-secondary);
        }

        ::-webkit-scrollbar-thumb {
            background: var(--text-muted);
            border-radius: 3px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--text-secondary);
        }

        /* Modal scrollable content */
        .modal-dialog-scrollable .modal-body {
            scrollbar-width: thin;
            scrollbar-color: var(--text-muted) var(--bg-secondary);
        }

        /* User Profile Popup Styles */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.user-profile:hover {
    background-color: var(--hover-color);
}

.user-dropdown-arrow {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s;
    margin-left: auto;
}

.user-profile.active .user-dropdown-arrow {
    transform: rotate(180deg);
}

.user-popup {
    position: absolute;
    bottom: 70px;
    left: 12px;
    right: 12px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
    max-width: 250px;
}

.user-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.popup-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.popup-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.popup-avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.popup-user-details {
    flex: 1;
    min-width: 0;
}

.popup-user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 2px;
}

.popup-user-email {
    color: var(--text-muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.popup-section {
    padding: 4px 0;
    border-bottom: 1px solid var(--border-color);
}

.popup-section:last-of-type {
    border-bottom: none;
}

.popup-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    color: var(--text-primary);
    text-decoration: none;
}

.popup-item:hover {
    background-color: var(--hover-color);
}

.popup-item-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.popup-icon {
    width: 16px;
    font-size: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.popup-item-text {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.upgrade-item {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-radius: 8px;
    margin: 0 12px 8px;
    padding: 16px;
}

.upgrade-item:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
}

.popup-item-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.popup-item-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.upgrade-arrow {
    color: var(--text-muted);
    font-size: 14px;
}

.logout-item {
    color: #ef4444;
}

.logout-item .popup-icon,
.logout-item .popup-item-text {
    color: #ef4444;
}

.logout-item:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

/* Backdrop for popup */
.popup-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 1;
    display: none;
}

.popup-backdrop.show {
    display: block;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .user-popup {
        position: fixed;
        bottom: 80px;
        left: 20px;
        right: 20px;
        max-width: 300px;
        margin: 0 auto;
    }
}


/* Options Bar Styles */
.options-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
    align-items: center;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.option-label i {
    margin-right: 4px;
}

.option-select {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 8px;
    color: var(--text-primary);
    font-size: 12px;
    min-width: 100px;
}

.option-select:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Enhanced Message Styles */
.message-ai .legal-metadata {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
    border-left: 3px solid var(--accent-color);
}

.metadata-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    font-size: 12px;
}

.metadata-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metadata-label {
    color: var(--text-muted);
    font-weight: 500;
}

.metadata-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* Source Citations */
.source-citations {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.source-title {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.source-item {
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.source-type {
    display: inline-block;
    background-color: var(--accent-color);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-right: 6px;
}

/* Response Formatting */
.formatted-response {
    line-height: 1.6;
}

.formatted-response h3,
.formatted-response h4 {
    margin: 16px 0 8px 0;
    color: var(--text-primary);
}

.formatted-response p {
    margin-bottom: 12px;
}

.formatted-response ul,
.formatted-response ol {
    margin-bottom: 12px;
    padding-left: 20px;
}

.formatted-response li {
    margin-bottom: 4px;
}

.article-reference 
   {
    /* background-color: var(--bg-secondary); */
    /* padding: 8px 12px; */
    border-radius: 6px;
    /* margin: 8px 0; */
    /* border-left: 3px solid var(--accent-color); */
}

.article-number {
    font-weight: 600;
    color: var(--accent-color);
}

/* Mobile responsive for options bar */
@media (max-width: 768px) {
    .options-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .option-group {
        justify-content: space-between;
    }
}



/* Enhanced Message Actions */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.message-action {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.2s;
    text-decoration: none;
}

.message-action:hover {
    color: var(--text-primary);
    background-color: var(--hover-color);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.message-action.primary {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.message-action.primary:hover {
    background-color: #0d8f6d;
    transform: translateY(-1px);
}

.message-action.danger {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.message-action.danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

/* User Message Actions */
.message-user .message-actions {
    opacity: 0;
    transition: opacity 0.2s;
}

.message-user:hover .message-actions {
    opacity: 1;
}

/* Inline Edit Styles */
.message-edit-container {
    position: relative;
    margin-top: 8px;
}

.message-edit-input {
    width: 100%;
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 12px 40px 12px 12px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    min-height: 60px;
}

.message-edit-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.2);
}

.edit-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
}

.edit-action {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12px;
    transition: all 0.2s;
}

.edit-action:hover {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.edit-action.cancel {
    background-color: var(--bg-tertiary);
}

.edit-action.cancel:hover {
    background-color: #ef4444;
    border-color: #ef4444;
}

/* Message Status Indicators */
.message-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-success {
    background-color: #10a37f;
}

.status-error {
    background-color: #ef4444;
}

.status-processing {
    background-color: #f59e0b;
    animation: pulse 1.5s infinite;
}

/* Quick Actions Bar */
.quick-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.quick-action {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.quick-action:hover {
    background-color: var(--hover-color);
    color: var(--text-primary);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

/* Enhanced Error States */
.error-message {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    color: #ef4444;
}

.retry-section {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
    border-left: 3px solid #f59e0b;
}

.retry-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Message Groups */
.message-group {
    margin-bottom: 24px;
}

.message-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 0 24px;
    max-width: 768px;
    margin: 0 auto 8px;
}

.message-group-time {
    font-size: 11px;
    color: var(--text-muted);
}

.message-group-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

/* Copy Success Animation */
@keyframes copySuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.copy-success {
    animation: copySuccess 0.3s ease;
    color: #10a37f !important;
}

/* Enhanced Thinking Indicator */
.thinking-indicator.enhanced {
    display: flex;
    align-items: center;
    gap: 12px;
}

.thinking-progress {
    flex: 1;
    height: 2px;
    background-color: var(--border-color);
    border-radius: 1px;
    overflow: hidden;
}

.thinking-progress-bar {
    height: 100%;
    background-color: var(--accent-color);
    animation: progressAnimation 2s ease-in-out infinite;
}

@keyframes progressAnimation {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0); }
    100% { transform: translateX(100%); }
}

/* Mobile Enhancements */
@media (max-width: 768px) {
    .message-actions {
        gap: 6px;
    }
    
    .message-action {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .quick-actions {
        gap: 6px;
    }
    
    .quick-action {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .edit-actions {
        position: static;
        margin-top: 8px;
        justify-content: flex-end;
    }
    
    .message-edit-input {
        padding: 12px;
    }
}

/* Dark mode enhancements */
[data-theme="dark"] .message-action {
    border-color: var(--border-color);
}

[data-theme="dark"] .message-action:hover {
    border-color: var(--accent-color);
}

[data-theme="dark"] .edit-action {
    background-color: var(--bg-tertiary);
}

/* Focus states for accessibility */
.message-action:focus-visible,
.edit-action:focus-visible,
.quick-action:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* ai Style Response Rendering */
.ai-response {
    line-height: 1.6;
    font-size: 14px;
}

.ai-response h1,
.ai-response h2,
.ai-response h3,
.ai-response h4 {
    margin: 20px 0 12px 0;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-response h1 { font-size: 1.5em; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
.ai-response h2 { font-size: 1.3em; }
.ai-response h3 { font-size: 1.1em; }
.ai-response h4 { font-size: 1em; }

.ai-response p {
    margin-bottom: 16px;
    color: var(--text-primary);
}

.ai-response ul,
.ai-response ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.ai-response li {
    margin-bottom: 6px;
    color: var(--text-primary);
}

.ai-response blockquote {
    border-left: 4px solid var(--accent-color);
    padding: 12px 16px;
    margin: 16px 0;
    background-color: var(--bg-secondary);
    border-radius: 0 8px 8px 0;
    font-style: italic;
}

.ai-response code {
    background-color: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    color: var(--text-primary);
}

.ai-response pre {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    overflow-x: auto;
    position: relative;
}

.ai-response pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: var(--text-primary);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.code-language {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.code-copy-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.code-copy-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.ai-response table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    background-color: var(--bg-primary);
    border-radius: 8px;
    overflow: hidden;
}

.ai-response th,
.ai-response td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.ai-response th {
    background-color: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

.ai-response tr:hover {
    background-color: var(--hover-color);
}

/* Enhanced Message Header */
.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.message-role {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-tools {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tool-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tool-btn:hover {
    background-color: var(--hover-color);
    color: var(--text-primary);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.tool-btn.primary {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.tool-btn.primary:hover {
    background-color: #0d8f6d;
}

.tool-btn.danger {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.tool-btn.danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.tool-btn:disabled:hover {
    background: none;
    border-color: var(--border-color);
    color: var(--text-muted);
}

/* Stop Generation Button */
.stop-generation {
    /* background-color: #ef4444 !important;*/
    color: #956262 !important; 
    border-color: #956262 !important;
    animation: pulseStop 2s infinite;
}

.stop-generation:hover {
    border-color: #956262 !important;
}


/* .stop-generation {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: var(--accent-color);
    border-color: #956262 !important;
    animation: pulseStop 2s infinite;
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    
} */

@keyframes pulseStop {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Enhanced Thinking Indicator */
.thinking-indicator.enhanced {
    display: flex;
    align-items: center;
    gap: 12px;
    /* padding: 16px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border-left: 4px solid var(--accent-color); */
}

.thinking-progress {
    flex: 1;
    height: 3px;
    background-color: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.thinking-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #0d8f6d);
    animation: progressAnimation 1.5s ease-in-out infinite;
}

@keyframes progressAnimation {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0); }
    100% { transform: translateX(100%); }
}

.thinking-stats {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
}

/* Message Status */
.message-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-success { background-color: #10a37f; }
.status-error { background-color: #ef4444; }
.status-processing { 
    background-color: #f59e0b;
    animation: pulse 1.5s infinite;
}

/* Citation Styles */
.citation {
    background-color: var(--bg-secondary);
    border-left: 3px solid var(--accent-color);
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: 0 8px 8px 0;
}

.citation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.citation-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.citation-score {
    font-size: 11px;
    background-color: var(--accent-color);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
}

.citation-content {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

/* Legal Document Styling */
.legal-article {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
}

.article-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.article-number {
    font-weight: 700;
    color: var(--accent-color);
    font-size: 16px;
}

.article-title {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    margin-left: 1px;
}

.article-content {
    color: var(--text-primary);
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 768px) {
    .message-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .message-tools {
        width: 100%;
        justify-content: space-between;
    }
    
    .tool-btn {
        flex: 1;
        justify-content: center;
    }
    
    .ai-response pre {
        padding: 12px;
        font-size: 12px;
    }
    
    .code-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
}

/* Copy Success Animation */
@keyframes copySuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); background-color: #10a37f; }
    100% { transform: scale(1); }
}

.copy-success {
    animation: copySuccess 0.3s ease !important;
}

/* Smooth Transitions */
.message-ai {
    transition: all 0.3s ease;
}

.message-ai:hover {
    background-color: var(--hover-color);
}

/* Focus States */
.tool-btn:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Streaming message styles */
.message.streaming {
    opacity: 0.95;
}
/* Streaming thinking state */
.streaming-thinking {
    color: var(--text-secondary);
    font-style: italic;
}

.streaming-text {
    min-height: 20px;
    white-space: pre-wrap;
    display: none; /* Hidden until first chunk */
}

.streaming-cursor {
    display: none; /* Hidden until first chunk */
    animation: blink 1s infinite;
    color: var(--accent-color);
    /* font-weight: bold; */
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Ensure smooth scrolling for streaming */
.message.streaming .message-text {
    transition: all 0.1s ease;
}


/* Chat History Styles */
.chat-history-list {
    margin-bottom: 15px;
}

.chat-session-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.chat-session-item:hover {
    background: var(--hover-color);
}

.chat-session-item.active {
    background: var(--accent-color);
    color: white;
}

.chat-session-item.active .session-title {
    color: white;
}

.chat-session-item.active .session-date {
    color: rgba(255, 255, 255, 0.8);
}

.session-content {
    flex: 1;
    min-width: 0;
}

.session-title {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.session-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.delete-session-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.chat-session-item:hover .delete-session-btn {
    opacity: 1;
}

.delete-session-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* History header with refresh */
.history-date {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.refresh-history {
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    color: var(--text-muted);
}

.refresh-history:hover {
    background: var(--hover-color);
    color: var(--text-primary);
}

/* Loading and empty states */
.history-loading, .history-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.history-empty i {
    font-size: 2rem;
    margin-bottom: 8px;
    display: block;
}

.history-empty small {
    display: block;
    margin-top: 4px;
    font-size: 0.8rem;
}