/* AI Chat Styles */

/* Ensure full height - works with sidebar structure */
html.ai-chat-page {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

html.ai-chat-page body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Override sidebar container for ai-chat page to use exact height */
html.ai-chat-page .app-container {
    height: 100vh;
    height: 100dvh;
    min-height: auto; /* Override min-height: 100vh */
    overflow: hidden;
}

html.ai-chat-page .main-content-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Hide the original header when sidebar is present */
html.ai-chat-page .main-content-wrapper > header {
    display: none;
}

.ai-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary, #f8fafc);
    overflow: hidden;
    min-height: 0;
    height: 100%; /* Take full height of parent */
}

/* Connection Status Banner */
.connection-status {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 0.875rem;
    background: #fef3c7;
    color: #92400e;
    border-bottom: 1px solid #fcd34d;
}

.connection-status.connected {
    background: #d1fae5;
    color: #065f46;
    border-color: #6ee7b7;
}

.connection-status.error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.connection-status .status-icon::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    animation: pulse 2s infinite;
}

.connection-status.connected .status-icon::before {
    background: #10b981;
    animation: none;
}

.connection-status.error .status-icon::before {
    background: #ef4444;
    animation: none;
}

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

/* Chat Layout */
.chat-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0; /* Critical for nested flexbox */
    height: 0; /* Force flex to calculate height properly */
}

/* Model Panel (Left Sidebar) */
.model-panel {
    width: 280px;
    flex: 0 0 280px;
    background: var(--bg-secondary, #fff);
    border-right: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.panel-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* Allow shrinking */
}

.panel-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.btn-icon {
    background: transparent;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary, #64748b);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-tertiary, #f1f5f9);
    color: var(--text-primary, #1e293b);
}

/* Current Model Section */
.current-model-section {
    padding: 16px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.current-model-section label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #64748b);
    margin-bottom: 8px;
}

.model-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    background: var(--bg-primary, #fff);
    font-size: 0.875rem;
    color: var(--text-primary, #1e293b);
    cursor: pointer;
}

.model-select:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.download-models-link {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: var(--primary-color, #3b82f6);
    text-decoration: none;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 6px;
    transition: all 0.2s;
}

.download-models-link:hover {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary-color, #2563eb);
}

.download-models-link svg {
    flex-shrink: 0;
}

/* Models Section */
.models-section {
    padding: 16px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.models-section h3 {
    margin: 0 0 12px 0;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #64748b);
}

.models-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.loading-models {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary, #64748b);
    font-size: 0.875rem;
}

.model-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-tertiary, #f8fafc);
    border-radius: 8px;
    gap: 8px;
}

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

.model-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary, #1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-size {
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
}

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

.btn-model-action {
    background: transparent;
    border: none;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary, #64748b);
    transition: all 0.2s;
}

.btn-model-action:hover {
    background: var(--bg-secondary, #e2e8f0);
}

.btn-model-action.delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Sessions Section */
.sessions-section {
    padding: 16px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.sessions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.sessions-header h3 {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #64748b);
}

.btn-new-chat {
    padding: 4px;
}

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 150px;
    overflow-y: auto;
}

.session-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    border: 1px solid transparent;
    gap: 6px;
}

.session-item:hover {
    background: var(--bg-tertiary, #f8fafc);
}

.session-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

.session-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.session-name {
    font-size: 0.8rem;
    color: var(--text-primary, #1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.session-time {
    font-size: 0.7rem;
    color: var(--text-secondary, #94a3b8);
    flex-shrink: 0;
}

.session-item.active .session-name {
    font-weight: 500;
    color: var(--primary-color, #3b82f6);
}

.btn-delete-session {
    display: none;
    background: transparent;
    border: none;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary, #94a3b8);
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-delete-session:hover {
    background: #fee2e2;
    color: #dc2626;
}

.session-item:hover .btn-delete-session {
    display: flex;
}

/* Download Section */
.download-section {
    padding: 16px;
    padding-bottom: 24px;
}

.download-section h3 {
    margin: 0 0 8px 0;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #64748b);
}

.hardware-note {
    font-size: 0.7rem;
    color: var(--text-secondary, #64748b);
    margin: 0 0 12px 0;
    padding: 8px;
    background: var(--bg-tertiary, #f8fafc);
    border-radius: 6px;
    line-height: 1.5;
}

.hardware-note strong {
    color: var(--text-primary, #1e293b);
}

/* Available Models List */
.available-models-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
    max-height: 280px;
    overflow-y: auto;
}

.available-model-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    background: var(--bg-tertiary, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.available-model-item:hover {
    border-color: var(--primary-color, #3b82f6);
    background: rgba(59, 130, 246, 0.05);
}

.available-model-item .model-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.available-model-item .model-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.available-model-item .model-size-tag {
    font-size: 0.65rem;
    color: var(--text-secondary, #64748b);
    background: var(--bg-secondary, #e2e8f0);
    padding: 1px 5px;
    border-radius: 4px;
}

.available-model-item .model-desc {
    font-size: 0.7rem;
    color: var(--text-secondary, #64748b);
    line-height: 1.3;
}

.available-model-item .model-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 4px;
    text-transform: uppercase;
}

.available-model-item .model-badge.cpu {
    background: #d1fae5;
    color: #065f46;
}

.available-model-item .model-badge.gpu {
    background: #fef3c7;
    color: #92400e;
}

.custom-model-input {
    display: flex;
    gap: 6px;
}

.custom-model-input input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    font-size: 0.8rem;
    min-width: 0;
}

.custom-model-input .btn {
    padding: 6px 10px;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Download Progress */
.download-progress {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-tertiary, #f8fafc);
    border-radius: 8px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.875rem;
}

.progress-bar {
    height: 6px;
    background: var(--bg-secondary, #e2e8f0);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color, #3b82f6);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-status {
    display: block;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
}

/* System Access Section in Panel - fixed at bottom */
.system-access-section {
    flex: 0 0 auto;
    padding: 16px;
    border-top: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-secondary, #fff);
    margin-top: auto; /* Push to bottom */
}

.btn-system-access-panel {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-tertiary, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-system-access-panel:hover {
    background: var(--bg-secondary, #fff);
    border-color: var(--primary-color, #3b82f6);
    color: var(--primary-color, #3b82f6);
}

.btn-system-access-panel.active {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.4);
    color: #16a34a;
}

.btn-system-access-panel.active:hover {
    background: rgba(34, 197, 94, 0.25);
}

.system-access-hint {
    margin: 8px 0 0 0;
    font-size: 0.7rem;
    color: var(--text-secondary, #94a3b8);
    text-align: center;
}

/* Toggle Panel Button */
.btn-toggle-panel {
    display: none;
    position: fixed;
    top: 70px;
    left: 10px;
    z-index: 100;
    padding: 10px;
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-primary, #f8fafc);
    overflow: hidden;
    min-height: 0; /* Critical for flexbox shrinking */
    height: 100%;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    min-height: 0; /* Allow shrinking */
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    max-width: 600px;
    margin: auto;
}

.welcome-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color, #3b82f6) 0%, #8b5cf6 100%);
    border-radius: 20px;
    margin-bottom: 20px;
    color: #fff;
}

.welcome-message h2 {
    margin: 0 0 12px 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.welcome-message p {
    margin: 0 0 24px 0;
    color: var(--text-secondary, #64748b);
    line-height: 1.6;
}

.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.quick-prompt {
    padding: 8px 16px;
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text-primary, #1e293b);
    cursor: pointer;
    transition: all 0.2s;
}

.quick-prompt:hover {
    border-color: var(--primary-color, #3b82f6);
    background: var(--primary-color, #3b82f6);
    color: #fff;
}

/* Message Styles */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.message.user .message-avatar {
    background: var(--primary-color, #3b82f6);
    color: #fff;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    color: #fff;
}

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 0.9375rem;
}

.message.user .message-content {
    background: var(--primary-color, #3b82f6);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--bg-secondary, #fff);
    color: var(--text-primary, #1e293b);
    border: 1px solid var(--border-color, #e2e8f0);
    border-bottom-left-radius: 4px;
}

.message.assistant .message-content pre {
    background: var(--bg-tertiary, #f1f5f9);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message.assistant .message-content code {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
}

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

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

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary, #64748b);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

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

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* Chat Input - always at bottom */
.chat-input-container {
    flex: 0 0 auto;
    padding: 16px 24px 24px;
    background: var(--bg-secondary, #fff);
    border-top: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 16px;
    padding: 8px 8px 8px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#chat-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 0.9375rem;
    line-height: 1.5;
    max-height: 150px;
    background: transparent;
    color: var(--text-primary, #1e293b);
}

#chat-input::placeholder {
    color: var(--text-secondary, #94a3b8);
}

#chat-input:disabled {
    cursor: not-allowed;
}

.btn-send,
.btn-stop {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-send {
    background: var(--primary-color, #3b82f6);
    color: #fff;
}

.btn-send:hover:not(:disabled) {
    background: var(--primary-dark, #2563eb);
}

.btn-send:disabled {
    background: var(--bg-tertiary, #e2e8f0);
    color: var(--text-secondary, #94a3b8);
    cursor: not-allowed;
}

.btn-stop {
    background: #ef4444;
    color: #fff;
}

.btn-stop:hover {
    background: #dc2626;
}

.input-hint {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-clear-chat {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: transparent;
    border: none;
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-clear-chat:hover {
    background: var(--bg-tertiary, #f1f5f9);
    color: var(--text-primary, #1e293b);
}

.btn-system-access {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: var(--bg-tertiary, #f1f5f9);
    border: 1px solid var(--border-color, #e2e8f0);
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-system-access:hover {
    background: var(--bg-secondary, #fff);
    border-color: var(--primary-color, #3b82f6);
    color: var(--primary-color, #3b82f6);
}

.btn-system-access.active {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.4);
    font-weight: 600;
}

.btn-system-access.active:hover {
    background: rgba(34, 197, 94, 0.25);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal .modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
}

.modal .modal-content {
    position: relative;
    background-color: var(--bg-secondary, #fff);
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal .modal-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.modal .modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal .modal-close:hover {
    color: var(--text-primary, #1e293b);
}

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

.modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-tertiary, #f8fafc);
    border-radius: 0 0 12px 12px;
}

.modal-sm .modal-content {
    max-width: 400px;
}

.modal-md .modal-content {
    max-width: 520px;
}

.text-muted {
    color: var(--text-secondary, #64748b);
    font-size: 0.875rem;
}

/* Button overrides for modals */
.modal .btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.modal .btn-secondary {
    background: var(--bg-tertiary, #e2e8f0);
    color: var(--text-primary, #1e293b);
    border: 1px solid var(--border-color, #e2e8f0);
}

.modal .btn-secondary:hover {
    background: var(--bg-secondary, #d1d5db);
}

.btn-danger {
    background: #ef4444;
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: #f59e0b;
    color: #fff;
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
}

.btn-warning:disabled {
    background: #fcd34d;
    cursor: not-allowed;
    opacity: 0.7;
}

/* System Access Modal Styles */
.warning-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    color: #92400e;
    font-weight: 600;
    margin-bottom: 20px;
}

.warning-banner svg {
    flex-shrink: 0;
    color: #f59e0b;
}

.consent-section {
    margin-bottom: 16px;
}

.consent-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin: 0 0 10px 0;
}

.consent-section.warning h3 {
    color: #dc2626;
}

.feature-list,
.warning-list {
    margin: 0;
    padding-left: 20px;
    font-size: 0.85rem;
    line-height: 1.8;
}

.feature-list li {
    color: var(--text-secondary, #64748b);
}

.feature-list li strong {
    color: var(--text-primary, #1e293b);
}

.warning-list li {
    color: #991b1b;
}

.feature-list code,
.warning-list code {
    background: var(--bg-tertiary, #f1f5f9);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.consent-checkbox {
    padding: 16px;
    background: var(--bg-tertiary, #f8fafc);
    border-radius: 8px;
    margin-top: 16px;
}

.consent-checkbox label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-primary, #1e293b);
}

.consent-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
}

/* System Info Modal */
.active-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    margin-bottom: 12px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #94a3b8;
}

.status-indicator.active {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 8px rgba(34, 197, 94, 0.5); }
    50% { box-shadow: 0 0 16px rgba(34, 197, 94, 0.8); }
}

.session-note {
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
    font-style: italic;
    margin-top: 12px;
}

/* System Notice in Chat */
.system-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 8px;
    font-size: 0.8rem;
    color: #16a34a;
    margin: 8px 0;
    animation: messageSlide 0.3s ease;
}

.system-notice svg {
    flex-shrink: 0;
}

[data-theme="dark"] .system-notice {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

/* Empty State for No Models */
.no-models {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary, #64748b);
}

.no-models svg {
    margin-bottom: 8px;
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
    /* When sidebar is present, model panel slides from left edge of main content */
    html.ai-chat-page .main-content-wrapper {
        margin-left: 0 !important;
    }

    .model-panel {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        height: 100vh !important;
    }

    .model-panel.open {
        transform: translateX(0);
    }

    .btn-toggle-panel {
        display: block;
    }

    .chat-messages {
        padding: 16px;
    }

    .chat-input-container {
        padding: 12px 16px 16px;
    }

    .message {
        max-width: 95%;
    }

    .welcome-message {
        padding: 20px 10px;
    }

    .quick-prompts {
        gap: 6px;
    }

    .quick-prompt {
        font-size: 0.8125rem;
        padding: 6px 12px;
    }
}

/* Dark mode overrides */
[data-theme="dark"] .connection-status {
    background: #422006;
    color: #fbbf24;
    border-color: #854d0e;
}

[data-theme="dark"] .connection-status.connected {
    background: #052e16;
    color: #4ade80;
    border-color: #166534;
}

[data-theme="dark"] .connection-status.error {
    background: #450a0a;
    color: #f87171;
    border-color: #7f1d1d;
}

[data-theme="dark"] .message.assistant .message-content pre {
    background: #1e293b;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar,
.model-panel::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.model-panel::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
.model-panel::-webkit-scrollbar-thumb {
    background: var(--border-color, #e2e8f0);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.model-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary, #94a3b8);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    background: var(--text-primary, #1e293b);
    color: #fff;
    font-size: 0.875rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    background: #059669;
}

.toast-error {
    background: #dc2626;
}

.toast-info {
    background: #3b82f6;
}

/* Action Notices in Chat */
.action-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin: 8px 24px;
    border-radius: 8px;
    font-size: 0.875rem;
    animation: slideIn 0.3s ease;
}

.action-notice.success {
    background: rgba(5, 150, 105, 0.1);
    border: 1px solid rgba(5, 150, 105, 0.3);
    color: #059669;
}

.action-notice.error {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: #dc2626;
}

.action-notice svg {
    flex-shrink: 0;
}

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

/* System Notice */
.system-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin: 8px 24px;
    border-radius: 8px;
    font-size: 0.875rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--primary-color, #3b82f6);
}

.system-notice svg {
    flex-shrink: 0;
}
