* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.profile-picture {
    border-radius: 50%;
    width: 150px;
    height: 150px;
    object-fit: cover;
    margin: 0 auto;
    display: block;
}

.chat-profile-picture {
    border-radius: 50%;
    width: 32px;
    height: 32px;
    object-fit: cover;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f7f7f8;
    height: 100vh;
    display: flex;
    margin: 0;
    overflow: hidden;
    position: relative;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Logo Styles */
.header-logo {
    height: 40px;
    width: auto;
    margin-right: 12px;
    vertical-align: middle;
}

.login-logo {
    height: 60px;
    width: auto;
    margin-bottom: 16px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.3s ease;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
}

.sidebar-logo {
    height: 32px;
    width: auto;
    flex-shrink: 0;
}

.sidebar-brand-text {
    color: #333;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

/* Hide brand elements when collapsed except on mobile */
.sidebar.collapsed .sidebar-brand {
    opacity: 0;
    pointer-events: none;
}

/* Ensure sidebar content stays within bounds when collapsed */
.sidebar.collapsed * {
    max-width: 60px;
    box-sizing: border-box;
}

.sidebar.collapsed .sidebar-toggle {
    max-width: 24px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .sidebar.collapsed .sidebar-brand {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar.collapsed * {
        max-width: none;
    }
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, transform 0.3s ease;
    position: relative;
    z-index: 100;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    overflow: hidden;
    contain: layout;
}

.sidebar.collapsed {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
}

/* Force all sidebar content to stay within bounds */
.sidebar * {
    max-width: 100%;
    box-sizing: border-box;
}

.sidebar.collapsed * {
    max-width: 60px;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    position: relative;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.sidebar-header h2 {
    color: #333;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-brand-text {
    opacity: 0;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 24px;
    height: 24px;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    position: relative;
    z-index: 102;
}

.sidebar-toggle:hover {
    background: #f1f3f4;
}

/* Normal state - toggle button on the right */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* When collapsed, center the toggle button and keep it within sidebar bounds */
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 1rem 0.5rem;
    position: relative;
    width: 60px;
    max-width: 60px;
}

.sidebar.collapsed .sidebar-toggle {
    position: relative;
    margin: 0 auto;
    left: 0;
    right: 0;
    transform: none;
}

/* Absolutely ensure toggle button never escapes sidebar */
.sidebar .sidebar-toggle {
    contain: layout;
    will-change: transform;
}

.sidebar.collapsed .sidebar-toggle {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

.hamburger {
    width: 16px;
    height: 2px;
    background: #333;
    transition: all 0.3s ease;
    border-radius: 1px;
    display: block;
    position: relative;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.user-section {
    padding: 0 1rem 1rem 1rem;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0B5ADB;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}

.user-name {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .user-name {
    opacity: 0;
}

.credits-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.credits-display:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.credits-icon {
    font-size: 1.2rem;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff3cd;
    border-radius: 50%;
    flex-shrink: 0;
}

.credits-info {
    flex: 1;
    transition: opacity 0.3s ease;
}

.credits-amount {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
    line-height: 1.2;
}

.credits-label {
    font-size: 0.75rem;
    color: #666;
    line-height: 1;
}

.sidebar.collapsed .credits-info {
    opacity: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.nav-section {
    padding: 0 1rem;
}

.nav-section h3 {
    color: #666;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 0.5rem 0;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .nav-section h3 {
    opacity: 0;
}

.session-info {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: #666;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .session-info {
    opacity: 0;
}

.session-label {
    font-weight: 500;
}

.session-id {
    color: #0B5ADB;
    font-weight: 600;
}

.nav-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: none;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.875rem;
    color: #333;
    text-align: left;
    width: 100%;
}

.nav-btn:hover {
    background: #f1f3f4;
}

.nav-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.nav-text {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .nav-text {
    opacity: 0;
}

.nav-section-bottom {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid #e5e5e5;
}

.logout-btn {
    color: #dc2626;
}

.logout-btn:hover {
    background: #fef2f2;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    min-width: 0;
    position: relative;
    overflow: hidden;
}

.main-content.sidebar-collapsed {
    margin-left: 0;
}

.header {
    background: white;
    border-bottom: 1px solid #e5e5e5;
    padding: 1rem 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
    flex-direction: column;
    gap: 3px;
    width: 24px;
    height: 24px;
    justify-content: center;
    align-items: center;
}

.mobile-menu-btn:hover {
    background: #f1f3f4;
}

/* Ensure mobile menu button is only visible on mobile */
@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none !important;
    }
}

.header-title h1 {
    color: #333;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.header-title p {
    color: #666;
    margin: 0.25rem 0 0 0;
    font-size: 0.875rem;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1rem;
    height: 0;
    /* Force flex child to respect parent height */
    position: relative;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 0;
    /* Allow flex child to shrink below content size */
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 100%;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: #0B5ADB;
    color: white;
}

.message.assistant .message-avatar {
    background: #ab68ff;
    color: white;
}

.message-content {
    background: white;
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    max-width: 85%;
    width: fit-content;
    min-width: 200px;
}

.message.user .message-content {
    background: #0B5ADB;
    color: white;
}

.message-content p {
    margin: 0 0 0.5rem 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

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

/* Formatted text styling for agent responses */
.message-content strong {
    font-weight: 600;
    color: inherit;
}

.message-content em {
    font-style: italic;
    color: inherit;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875em;
    color: #d63384;
}

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

.sql-block {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 0.5rem;
    margin: 0.75rem 0;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.875rem;
    overflow: hidden;
}

.sql-header {
    background: #2d2d2d;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sql-label {
    color: #888;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.copy-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: #333;
    color: #fff;
}

.sql-code {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem;
    margin: 0;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
}

.sql-editor {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 0.5rem;
    margin: 0.75rem 0;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.875rem;
    overflow: hidden;
}

/* SQL Syntax Highlighting */
.sql-keyword {
    color: #569cd6;
    font-weight: 600;
}

.sql-string {
    color: #ce9178;
}

.sql-number {
    color: #b5cea8;
}

.sql-comment {
    color: #6a9955;
    font-style: italic;
}

.sql-operator {
    color: #d4d4d4;
}

.sql-function {
    color: #dcdcaa;
}

.message.user .sql-block {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.sql-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #0B5ADB;
    color: white;
}

.btn-primary:hover {
    background: #0A4FB8;
}

.btn-secondary {
    background: #f1f3f4;
    color: #333;
    border: 1px solid #dadce0;
}

.btn-secondary:hover {
    background: #e8eaed;
}

.results-table-container {
    overflow-x: auto;
    margin-top: 0.75rem;
    border: 1px solid #e5e5e5;
    border-radius: 0.5rem;
    background: white;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: max-content;
}

.results-table th,
.results-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e5e5;
    vertical-align: top;
    word-break: normal;
    /* Prevent unnecessary word breaking */
}

.results-table th:first-child,
.results-table td:first-child {
    min-width: 120px;
    /* Ensure enough width for district names */
    white-space: normal;
    /* Allow text to wrap naturally if needed */
}

.results-table th {
    background: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.results-table tr:last-child td {
    border-bottom: none;
}

.results-table tr:hover {
    background-color: #f8f9fa;
}

.error-message {
    background: #fef2f2;
    color: #dc2626;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid #fecaca;
    margin-top: 0.75rem;
}

.input-container {
    background: white;
    border-top: 1px solid #e5e5e5;
    padding: 1rem 2rem;
    position: relative;
    z-index: 1;
}

.input-form {
    display: flex;
    gap: 0.75rem;
    max-width: 800px;
    margin: 0 auto;
    align-items: flex-end;
    flex-wrap: wrap;
    /* Allow items to wrap */
}

.input-field {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
    min-width: 200px;
    /* Ensure it doesn't get too small */
}

#csvFileInput {
    flex-shrink: 0;
    /* Prevent it from shrinking */
    margin-top: 0.5rem;
    /* Space from the input field */
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background-color: #f9f9f9;
    cursor: pointer;
    font-size: 0.875rem;
    color: #333;
    transition: all 0.2s ease;
    width: auto;
    /* Allow natural width */
}

#csvFileInput:hover {
    border-color: #0B5ADB;
    background-color: #f0f8ff;
}

#csvFileInput::-webkit-file-upload-button {
    visibility: hidden;
}

#csvFileInput::before {
    content: 'Choose file';
    display: inline-block;
    background: #0B5ADB;
    color: white;
    border: 1px solid #0B5ADB;
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
    outline: none;
    white-space: nowrap;
    -webkit-user-select: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
}

#csvFileInput:hover::before {
    background: #0A4FB8;
    border-color: #0A4FB8;
}

#csvFileInput:active::before {
    background: #083E92;
    border-color: #083E92;
}

#csvFileInput.has-file::before {
    content: 'File selected';
    /* Change text when file is chosen */
    background: #28a745;
    /* Green color for selected */
    border-color: #28a745;
}

#csvFileInput.has-file:hover::before {
    background: #218838;
    border-color: #218838;
}

.input-field:focus {
    border-color: #0B5ADB;
    box-shadow: 0 0 0 3px rgba(11, 90, 219, 0.1);
}

.send-btn {
    padding: 0.75rem 1.5rem;
    background: #0B5ADB;
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.send-btn:hover:not(:disabled) {
    background: #0A4FB8;
}

.send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Agent Selector Styles */
.agent-selector-container {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    z-index: 10;
}

.agent-selector-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-width: 140px;
    justify-content: space-between;
    position: relative;
}

.agent-selector-btn:hover {
    border-color: #0B5ADB;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.dropdown-arrow {
    font-size: 0.75rem;
    color: #666;
    transition: transform 0.2s;
}

.agent-selector-btn:hover .dropdown-arrow {
    color: #0B5ADB;
}

.agent-selector-btn:focus {
    outline: none;
    border-color: #0B5ADB;
    box-shadow: 0 0 0 3px rgba(11, 90, 219, 0.1);
}

/* Modal Styles for Agent Selection - REMOVED DUPLICATE */

#agentModalOverlay .agent-modal {
    background: white !important;
    border-radius: 12px !important;
    width: 90% !important;
    max-width: 500px !important;
    max-height: 80vh !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    overflow: hidden !important;
}

#agentModalOverlay .modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#agentModalOverlay .modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

#agentModalOverlay .modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#agentModalOverlay .modal-close-btn:hover {
    color: #333;
}

#agentModalOverlay .modal-content {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

#agentModalOverlay .agent-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#agentModalOverlay .agent-item {
    padding: 1rem;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

#agentModalOverlay .agent-item:hover {
    border-color: #0B5ADB;
    box-shadow: 0 2px 8px rgba(11, 90, 219, 0.1);
}

#agentModalOverlay .agent-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.agent-type-indicator {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.agent-type-indicator.marketplace {
    background: #17a2b8;
    color: white;
}

.agent-type-indicator.custom {
    background: #0B5ADB;
    color: white;
}

.agent-type-indicator.rented {
    background: #6f42c1;
    color: white;
}

.agent-creator {
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.25rem;
    font-style: italic;
}

#agentModalOverlay .agent-item.marketplace-agent {
    border-left: 3px solid #17a2b8;
}

#agentModalOverlay .agent-description {
    color: #666;
    font-size: 14px;
    line-height: 1.4;
}

/* Simple Agent Modal - Clean Implementation */
#agentModalOverlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 99999 !important;
}

#agentModalOverlay.show {
    display: flex !important;
}

.loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6b7280;
    font-style: italic;
}

.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #6b7280;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.editable-sql {
    background: #1e1e1e;
    border: none;
    color: #d4d4d4;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    width: 100%;
    min-height: 120px;
    resize: vertical;
    margin: 0;
}

.editable-sql:focus {
    outline: none;
    background: #252526;
}

/* Settings Page Styles */
.settings-body {
    background-color: #f7f7f8;
    overflow: auto !important;
    height: auto !important;
    display: block !important;
    min-height: 100vh;
}

/* Login Page Styles */
.login-body {
    background-color: #f7f7f8;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    overflow: auto !important;
    height: auto !important;
}

.login-container {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.login-card {
    background: white;
    border-radius: 1rem;
    padding: 2.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 10px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e5e5;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    color: #333;
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.login-header p {
    color: #666;
    font-size: 0.95rem;
    margin: 0;
}

.demo-info {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.demo-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.demo-info strong {
    color: #333;
    font-weight: 600;
}

.demo-creds {
    color: #666;
    font-size: 0.875rem;
}

.demo-creds code {
    background: #e9ecef;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.8rem;
    color: #0B5ADB;
    font-weight: 500;
}

.login-form {
    margin: 0;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: all 0.2s ease;
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: #0B5ADB;
    box-shadow: 0 0 0 3px rgba(11, 90, 219, 0.1);
}

.form-input:hover {
    border-color: #9ca3af;
}

.login-btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    position: relative;
}

.login-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.login-btn:disabled:hover {
    background: #9ca3af;
    transform: none;
}

.error-message {
    background: #fef2f2;
    color: #dc2626;
    padding: 0.875rem;
    border-radius: 0.5rem;
    border: 1px solid #fecaca;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.error-icon {
    flex-shrink: 0;
    font-size: 1rem;
}

/* Scrollable Page Override for non-chat pages */
.scrollable-page {
    overflow: hidden !important;
    height: 100vh !important;
}

.scrollable-page .main-content {
    overflow-y: auto;
    height: 100vh;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
        position: relative;
        width: 100%;
        display: flex;
        flex-direction: row;
    }
    
    /* Ensure body children don't cause layout issues */
    body > * {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    html {
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Force reset any potential layout issues on mobile */
    .main-content,
    .main-content.sidebar-collapsed,
    .main-content.threads-open {
        margin-left: 0 !important;
        margin-right: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        position: relative !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* Ensure no elements are positioned outside viewport */
    * {
        max-width: 100%;
        box-sizing: border-box;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        width: 280px;
        transition: transform 0.3s ease;
        flex-shrink: 0;
    }

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

    .sidebar.collapsed {
        transform: translateX(-100%);
        width: 280px;
    }

    .chat-threads-sidebar {
        display: none;
    }

    .main-content {
        width: 100% !important;
        margin-left: 0 !important;
        min-width: 0;
        position: relative;
        left: 0 !important;
    }

    .mobile-menu-btn {
        display: flex !important;
    }

    .sidebar-toggle {
        display: flex;
    }

    /* Reset collapsed sidebar header layout on mobile */
    .sidebar.collapsed .sidebar-header {
        justify-content: space-between;
        padding: 1rem;
    }

    .sidebar.collapsed .sidebar-toggle {
        margin: 0;
        position: relative;
        left: auto;
        top: auto;
        transform: none;
    }

    .header {
        padding: 0.75rem 1rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .header-content {
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
        max-width: 100%;
    }

    .header-title h1 {
        font-size: 1.25rem;
        line-height: 1.3;
    }

    .header-title p {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    .input-container {
        padding: 0.75rem 1rem;
    }

    .message-content {
        max-width: 90%;
        min-width: 150px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .input-form {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }

    .input-field {
        min-width: 0;
        width: 100%;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    .send-btn {
        align-self: stretch;
        width: 100%;
        padding: 0.875rem;
    }

    .login-card {
        padding: 1.5rem;
        margin: 0.5rem;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }

    .chat-container {
        max-width: 100%;
        width: 100%;
        padding: 0 0.75rem;
        margin: 0 auto;
        position: relative;
        left: 0;
    }

    .messages {
        padding: 1rem 0;
        gap: 1rem;
    }

    .agent-selector-container {
        justify-content: stretch;
        margin-bottom: 0.75rem;
        max-width: 100%;
        padding: 0;
    }

    .agent-selector-btn {
        width: 100%;
        justify-content: space-between;
        min-width: auto;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    #agentModalOverlay .agent-modal {
        width: 95% !important;
        max-height: 85vh !important;
        margin: 1rem !important;
    }

    .input-form {
        max-width: 100%;
    }

    /* Fix text overflow issues */
    .message-content p {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        line-height: 1.5;
    }

    .message-content {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    /* Ensure proper text rendering */
    .header-title h1,
    .header-title p {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Ensure tables are responsive */
    .results-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .results-table {
        min-width: 300px;
    }

    /* Fix CSV file input on mobile */
    #csvFileInput {
        width: 100%;
        margin-top: 0.5rem;
        padding: 0.75rem;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    #csvFileInput::before {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    /* Additional mobile fixes */
    .nav-text {
        font-size: 0.875rem;
    }

    .user-name {
        font-size: 0.875rem;
    }

    .session-info {
        font-size: 0.8rem;
    }

    /* Prevent horizontal scrolling */
    .main-content,
    .chat-container,
    .messages,
    .input-container {
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Better button spacing on mobile */
    .nav-btn {
        padding: 0.875rem 0.75rem;
        font-size: 0.875rem;
    }

    .nav-icon {
        font-size: 1.1rem;
    }

    /* Improve modal on mobile */
    #agentModalOverlay .modal-header {
        padding: 1rem;
    }

    #agentModalOverlay .modal-content {
        padding: 1rem;
    }

    #agentModalOverlay .agent-item {
        padding: 0.875rem;
    }

    #agentModalOverlay .agent-name {
        font-size: 0.95rem;
    }

    #agentModalOverlay .agent-description {
        font-size: 0.85rem;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    .header-title h1 {
        font-size: 1.1rem;
    }

    .header-title p {
        font-size: 0.75rem;
    }

    .message-content {
        max-width: 95%;
        padding: 0.875rem 1rem;
    }

    .chat-container {
        padding: 0 0.5rem;
    }

    .input-container {
        padding: 0.5rem;
    }

    .agent-selector-btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.85rem;
    }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    .sidebar-overlay.active {
        display: block;
    }
}

/* 
CRITICAL FIX: Ensure hamburger menu stays in sidebar when collapsed */
.sidebar.collapsed .sidebar-toggle {
    position: absolute !important;
    left: 18px !important;
    top: 18px !important;
    transform: none !important;
    margin: 0 !important;
    right: auto !important;
    z-index: 999 !important;
}

.sidebar.collapsed .sidebar-header {
    position: relative !important;
    width: 60px !important;
    max-width: 60px !important;
    overflow: hidden !important;
}

/* Ensure no content escapes the collapsed sidebar */
.sidebar.collapsed {
    contain: strict !important;
    overflow: hidden !important;
}

.pricing-tiers {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    padding: 30px;
    margin: 30px;
}

.pricing-tier {
    width: 24%; /* Adjust as needed */
    min-height: 200px;
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #e5e5e5;
    text-align: center;
    border-radius: 0.5rem;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.pricing-tier h2 {
    color: #333;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.pricing-tier p {
    color: #666;
    margin-bottom: 10px; /* Add margin between list items */
}

.marketing-section {
    background-color: white;
    padding: 30px;
    margin: 30px;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: left;
}

.marketing-section h2 {
    color: #333;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 15px;
}

.marketing-section p {
    color: #666;
    font-size: 1rem;
    line-height: 1.5;
}

/* Enhancements for public portfolio links */
.link-item {
    position: relative;
    overflow: hidden;
    transform: translateZ(0); /* Optimize for animation */
    display: flex; /* Add flex display */
    justify-content: space-between; /* Distribute space evenly */
    align-items: center; /* Vertically align items */
}

.link-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, rgba(11, 90, 219, 0.1), rgba(171, 104, 255, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.link-item:hover::before {
    opacity: 1;
}

.link-title, .link-clicks {
    position: relative;
    z-index: 1;
}

.link-clicks {
    font-size: 0.85rem;
    color: var(--text-color-secondary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0; /* Remove top margin */
    font-weight: 600;
    color: var(--primary-color); /* Use a distinct color for the count */
    transition: transform 0.2s ease-out, color 0.2s ease-out;
    display: inline-block;
}

/* Animation for click count update */
@keyframes pop-in {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.link-clicks .click-count.animate {
    animation: pop-in 0.3s ease-out;
}

.k-walk-section {
    background-color: white;
    padding: 30px;
    margin: 30px;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: left;
}

.k-walk-section h2 {
    color: #333;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 15px;
}

.k-walk-section p {
    color: #666;
    font-size: 1rem;
    line-height: 1.5;
}

/* Profile Page Styles */
/* Profile Page Styles */
.profile-section {
    padding: 40px;
    margin: 40px auto;
    background-color: #f9f9f9;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    max-width: 700px;
    transition: transform 0.2s ease-in-out;
}

.profile-section:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.profile-section .section-header {
    text-align: center;
    margin-bottom: 30px;
}

.profile-section .section-header h2 {
    font-size: 28px;
    color: #333;
    transition: color 0.3s ease;
}

.profile-section:hover .section-header h2 {
    color: #0B5ADB;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-gap: 25px;
    align-items: center;
}

.profile-card {
    padding: 30px;
    border: 1px solid #eee;
    border-radius: 12px;
    background-color: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
}

.profile-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.profile-card p {
    margin-bottom: 15px;
    font-size: 16px;
    color: #555;
}

.profile-card p strong {
    font-weight: 600;
    color: #333;
}

.profile-section form {
    display: flex;
    flex-direction: column;
}

.profile-section .form-group {
    margin-bottom: 20px;
}

.profile-section .form-group label {
    font-weight: 500;
    margin-bottom: 8px;
    display: block;
    color: #444;
    transition: color 0.3s ease;
}

.profile-section:hover .form-group label {
    color: #0B5ADB;
}

.profile-section .form-group input[type="file"],
.profile-section .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-sizing: border-box;
    margin-bottom: 15px;
    font-size: 15px;
    transition: border-color 0.3s ease;
}

.profile-section .form-group input[type="file"]:focus,
.profile-section .form-group textarea:focus {
    border-color: #0B5ADB;
    outline: none;
    box-shadow: 0 0 6px rgba(11, 90, 219, 0.1);
}

.profile-section .form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.profile-section input[type="text"],
.profile-section input[type="file"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-sizing: border-box;
    margin-bottom: 15px;
    font-size: 15px;
    transition: border-color 0.3s ease;
}

.profile-section input[type="text"]:focus,
.profile-section input[type="file"]:focus {
    border-color: #0B5ADB;
    outline: none;
    box-shadow: 0 0 6px rgba(11, 90, 219, 0.1);
}

.profile-section .btn-primary {
    background-color: #0B5ADB;
    color: #fff;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.profile-section .btn-primary:hover {
    background-color: #0A4FB8;
    transform: translateY(-2px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.profile-picture {
    border-radius: 50%;
    width: 150px;
    height: 150px;
    object-fit: cover;
    margin: 0 auto;
    display: block;
    animation: fadeIn 1s ease-in-out;
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}
