/* Custom styling for Cortex */

/* Responsive sidebar handling */
@media (max-width: 768px) {
    .sidebar-mobile-hidden {
        display: none;
    }
}

/* Chat message styling */
.message-user {
    background-color: #f3f4f6;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.message-assistant {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

/* Code block styling */
.prose pre {
    background-color: #1f2937;
    color: #f9fafb;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
}

.prose code {
    font-family: "Menlo", "Monaco", "Consolas", monospace;
}

/* Markdown styling */
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
    font-weight: bold;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.prose h1 {
    font-size: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.25rem;
}

/* Dashboard styling */
.dashboard-container {
    padding: 1.5rem;
}

.dashboard-header {
    margin-bottom: 1.5rem;
}

.view-toggle-container {
    display: flex;
    gap: 0.5rem;
}

.view-toggle-btn {
    padding: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1rem;
}

.dashboard-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chart-card {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chart-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.chart-card-header {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-card-body {
    padding: 1rem;
    flex-grow: 1;
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.chart-card-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-container {
    position: relative !important;
    width: 100%;
    height: 100%;
    min-height: 250px;
}

/* Style for chart containers in chat */
#chat-messages canvas {
    position: relative !important;
    z-index: 5;
}

#chat-messages .chart-container {
    position: relative !important;
    display: block;
    margin-top: 1rem;
    margin-bottom: 1rem;
    width: 100%;
}

/* Save button styling */
.save-to-dashboard-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    z-index: 50 !important;
    cursor: pointer;
}

.chart-container:hover .save-to-dashboard-btn,
canvas:hover + .save-to-dashboard-btn,
.save-to-dashboard-btn:hover {
    opacity: 1 !important;
}

.prose h2 {
    font-size: 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.25rem;
}

.prose h3 {
    font-size: 1.125rem;
}

.prose h4 {
    font-size: 1rem;
}

.prose p {
    margin-bottom: 0.75rem;
}

.prose ul {
    list-style-type: disc;
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.prose ol {
    list-style-type: decimal;
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.prose li {
    margin-bottom: 0.25rem;
}

.prose blockquote {
    border-left: 4px solid #e5e7eb;
    padding-left: 1rem;
    margin-left: 0;
    margin-right: 0;
    font-style: italic;
    color: #6b7280;
}

.prose code {
    font-family: Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    background-color: #f3f4f6;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

.prose pre {
    background-color: #1f2937;
    color: #f9fafb;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.prose pre code {
    background-color: transparent;
    padding: 0;
    font-size: inherit;
    color: inherit;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.prose th, .prose td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
}

.prose th {
    background-color: #f3f4f6;
    font-weight: bold;
}

.prose a {
    color: #3b82f6;
    text-decoration: underline;
}

.prose a:hover {
    text-decoration: none;
}

.prose img {
    max-width: 100%;
    height: auto;
    border-radius: 0.25rem;
}

.prose hr {
    border: 0;
    border-top: 1px solid #e5e7eb;
    margin: 1rem 0;
}

.prose strong, .prose b {
    font-weight: bold;
}

.prose em, .prose i {
    font-style: italic;
}

/* Input textarea auto-resize */
#message-input {
    min-height: 40px;
    max-height: 200px;
    overflow-y: hidden;
    resize: none;
}

/* Chat interface styles for stop button functionality */

/* Stop button animations and states */
#stop-button {
    transition: all 0.2s ease-in-out;
    position: relative;
}

#stop-button:hover {
    background-color: #dc2626;
    transform: scale(1.05);
}

#stop-button:active {
    transform: scale(0.95);
}

/* Loading dots animation */
.loading-dots {
    display: inline-block;
    position: relative;
    font-style: italic;
    color: #6b7280;
}

.loading-dots::after {
    content: '';
    animation: loading-dots 1.4s ease-in-out infinite;
}

@keyframes loading-dots {
    0%, 80%, 100% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80% {
        content: '...';
    }
}

/* Button transition states */
.button-transition {
    transition: all 0.3s ease-in-out;
}

/* Form disabled state */
.form-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.form-disabled textarea {
    background-color: #f9fafb;
    cursor: not-allowed;
}

/* Message states */
.message-stopped {
    border-left: 4px solid #f59e0b;
    padding-left: 12px;
    background-color: #fffbeb;
}

.message-stopped .prose {
    color: #78716c;
}

/* Tool call container styles for better UX during stops */
.tool-call-container.cancelled {
    opacity: 0.7;
    border-left: 3px solid #f59e0b;
}

.tool-call-container.cancelled .tool-status {
    background-color: #f59e0b;
    color: white;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    #stop-button, #submit-button {
        padding: 8px;
    }
    
    #stop-button svg, #submit-button svg {
        width: 18px;
        height: 18px;
    }
}

/* Keyboard shortcut hints */
.shortcut-hint {
    position: absolute;
    bottom: -20px;
    right: 0;
    font-size: 10px;
    color: #9ca3af;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

#stop-button:hover .shortcut-hint {
    opacity: 1;
}

/* Enhanced button states */
.btn-primary {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.btn-primary:hover {
    background-color: #2563eb;
    border-color: #2563eb;
}

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

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

/* Pulse animation for active processing */
.processing-indicator {
    animation: pulse 2s infinite;
}

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

/* Dark mode styling */
.dark-mode {
    background-color: #1f2937;
    color: #f9fafb;
}

.dark-mode .bg-white {
    background-color: #374151;
}

.dark-mode .border {
    border-color: #4b5563;
}

.dark-mode .text-gray-700 {
    color: #e5e7eb;
}

.dark-mode .text-gray-500 {
    color: #9ca3af;
}

.dark-mode .message-user {
    background-color: #374151;
}

.dark-mode .message-assistant {
    background-color: #1f2937;
    border-color: #4b5563;
}

/* Loading indicators */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.loading-dots:after {
    content: '.';
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60% {
        content: '...';
    }
    80%, 100% {
        content: '';
    }
}

/* Button transitions */
.btn-transition {
    transition: all 0.2s ease-in-out;
}

.btn-transition:hover {
    transform: translateY(-1px);
}

/* Range slider styling */
input[type="range"] {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.dark-mode input[type="range"] {
    background: #4b5563;
}

/* Chat timestamp styling */
.chat-timestamp {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.25rem;
}

/* Syntax highlighting */
.hljs {
    display: block;
    overflow-x: auto;
    padding: 1rem;
    background: #1f2937;
    color: #e5e7eb;
    border-radius: 0.5rem;
}

.hljs-keyword,
.hljs-operator {
    color: #93c5fd;
}

.hljs-string {
    color: #86efac;
}

.hljs-number {
    color: #fca5a5;
}

.hljs-comment {
    color: #9ca3af;
    font-style: italic;
}

.hljs-function {
    color: #c4b5fd;
}

/* Toast notifications */
.toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 1rem;
    background: #1f2937;
    color: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
    transform: translateY(-100%);
    opacity: 0;
}

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

/* Mobile responsive adjustments */
@media (max-width: 640px) {
    .message-user, .message-assistant {
        padding: 0.75rem;
    }
    
    .prose pre {
        padding: 0.75rem;
    }
    
    .toast {
        left: 1rem;
        right: 1rem;
        text-align: center;
    }
}

/* Tool Call Styling */

/* Tool call indicator styling */
.tool-call-indicator {
    margin: 10px 0;
    padding: 8px 12px;
    border-radius: 6px;
    background-color: #f9fafb;
    border-left: 4px solid #6366f1;
    font-family: monospace;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dark-mode .tool-call-indicator {
    background-color: #374151;
    border-left: 4px solid #818cf8;
}

.tool-name {
    font-weight: bold;
    color: #4f46e5;
    margin-right: 10px;
}

.dark-mode .tool-name {
    color: #a5b4fc;
}

.tool-status {
    font-style: italic;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
}

.dark-mode .tool-status {
    color: #9ca3af;
}

/* Tool status indicators */
.tool-status.running::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 8px;
    background-color: #f59e0b;
    border-radius: 50%;
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.tool-status.success {
    color: #10b981;
}

.dark-mode .tool-status.success {
    color: #34d399;
}

.tool-status.error {
    color: #ef4444;
}

.dark-mode .tool-status.error {
    color: #f87171;
}

/* Tool result styling */
.tool-result {
    margin-top: 4px;
    padding: 8px;
    background-color: #f3f4f6;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

.dark-mode .tool-result {
    background-color: #1f2937;
}

/* Wren-specific styling */
.wren-result-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 0.85rem;
}

.wren-result-table th,
.wren-result-table td {
    padding: 6px 8px;
    border: 1px solid #e5e7eb;
    text-align: left;
}

.wren-result-table th {
    background-color: #f3f4f6;
    font-weight: bold;
}

.dark-mode .wren-result-table th {
    background-color: #374151;
    border-color: #4b5563;
}

.dark-mode .wren-result-table td {
    border-color: #4b5563;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .tool-call-indicator {
        padding: 6px 8px;
        font-size: 0.8rem;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .tool-name {
        margin-bottom: 4px;
    }
}

/* Tool Call Styling */

/* Tool call container styling */
.tool-call-container {
    margin: 12px 0;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    background-color: #f9fafb;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.dark-mode .tool-call-container {
    background-color: #2d3748;
    border-color: #4a5568;
}

/* Tool call header styling */
.tool-call-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background-color: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    user-select: none;
}

.dark-mode .tool-call-header {
    background-color: #374151;
    border-color: #4a5568;
}

/* Add visual feedback on hover */
.tool-call-header:hover {
    background-color: #e5e7eb;
}

.dark-mode .tool-call-header:hover {
    background-color: #4b5563;
}

.tool-name {
    font-weight: bold;
    color: #4f46e5;
    margin-right: 10px;
    font-family: monospace;
}

.dark-mode .tool-name {
    color: #818cf8;
}

.tool-status {
    font-style: italic;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
}

.dark-mode .tool-status {
    color: #9ca3af;
}

/* Tool status indicators */
.tool-status.running::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 8px;
    background-color: #f59e0b;
    border-radius: 50%;
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.tool-status.success {
    color: #10b981;
}

.dark-mode .tool-status.success {
    color: #34d399;
}

.tool-status.error {
    color: #ef4444;
}

.dark-mode .tool-status.error {
    color: #f87171;
}

/* Tool arguments styling */
.tool-call-args {
    padding: 8px 12px;
    border-bottom: 1px dashed #e5e7eb;
    background-color: #f3f4f6;
    overflow-x: auto;
}

.dark-mode .tool-call-args {
    background-color: #1f2937;
    border-color: #4a5568;
}

.tool-call-args pre {
    margin: 0;
}

.tool-call-args code {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

/* Tool result styling */
.tool-call-result {
    padding: 8px 12px;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

.tool-call-result pre {
    margin: 0;
}

.tool-call-result code {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

/* JSON syntax highlighting */
.hljs-string {
    color: #059669;
}

.dark-mode .hljs-string {
    color: #10b981;
}

.hljs-attr {
    color: #c026d3;
}

.dark-mode .hljs-attr {
    color: #e879f9;
}

.hljs-number {
    color: #0284c7;
}

.dark-mode .hljs-number {
    color: #38bdf8;
}

.hljs-boolean {
    color: #f59e0b;
}

.dark-mode .hljs-boolean {
    color: #fbbf24;
}

.hljs-null {
    color: #737373;
}

.dark-mode .hljs-null {
    color: #a3a3a3;
}

/* Tool error styling */
.tool-error {
    padding: 8px 12px;
    color: #ef4444;
    background-color: #fee2e2;
    border-radius: 4px;
    margin: 8px 0;
}

.dark-mode .tool-error {
    background-color: #7f1d1d;
    color: #fca5a5;
}

.error-label {
    font-weight: bold;
    margin-right: 4px;
}

/* Collapsible tool results */
.tool-call-header::after {
    content: '▼';
    margin-left: 8px;
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.tool-call-container.collapsed .tool-call-header::after {
    transform: rotate(-90deg);
}

.tool-call-container.collapsed .tool-call-args,
.tool-call-container.collapsed .tool-call-result {
    display: none;
}

/* Tool indicator for collapsed state */
.tool-call-container.collapsed {
    background-color: transparent;
    border-color: transparent;
    border-left: 3px solid #4f46e5;
    margin: 6px 0;
}

.dark-mode .tool-call-container.collapsed {
    border-left-color: #818cf8;
}

.tool-call-container.collapsed .tool-call-header {
    background-color: transparent;
    border-bottom: none;
    padding: 4px 8px;
}

.dark-mode .tool-call-container.collapsed .tool-call-header {
    background-color: transparent;
}

/* Tool name styles for collapsed state */
.tool-call-container.collapsed .tool-name {
    font-size: 0.85rem;
}

/* Transition for expanding/collapsing */
.tool-call-container {
    transition: background-color 0.2s, border-color 0.2s, margin 0.2s;
}

.tool-call-header {
    transition: background-color 0.2s, padding 0.2s, border-bottom 0.2s;
}

/* Responsive styling */
@media (max-width: 640px) {
    .tool-call-container {
        font-size: 0.8rem;
    }
    
    .tool-call-header {
        padding: 6px 8px;
    }
    
    .tool-call-args,
    .tool-call-result {
        padding: 6px 8px;
    }
    
    .tool-call-args code,
    .tool-call-result code {
        font-size: 0.75rem;
    }
    
    .tool-call-container.collapsed .tool-name {
        font-size: 0.8rem;
    }
}

/* Hover indicator to show it's clickable */
.tool-call-header:hover {
    background-color: #e5e7eb;
}

.dark-mode .tool-call-header:hover {
    background-color: #4b5563;
}

.tool-call-container.collapsed .tool-call-header:hover {
    background-color: rgba(79, 70, 229, 0.05);
}

.dark-mode .tool-call-container.collapsed .tool-call-header:hover {
    background-color: rgba(129, 140, 248, 0.05);
}

/* Better visual cue for completed tools */
.tool-call-container.collapsed .tool-status.success::before {
    content: '✓';
    margin-right: 4px;
    font-weight: bold;
}

.tool-call-container.collapsed .tool-status.error::before {
    content: '⚠️';
    margin-right: 4px;
}

/* Additional accessibility for colorblind users */
.tool-call-container.collapsed {
    padding-left: 4px;
}

/* Badge to indicate tool in collapsed mode */
.tool-call-container.collapsed::before {
    content: 'tool';
    position: relative;
    left: -3px;
    top: -1px;
    font-size: 0.65rem;
    padding: 1px 4px;
    background-color: #e0e7ff;
    color: #4f46e5;
    border-radius: 4px;
    font-family: sans-serif;
    margin-right: 4px;
    font-weight: bold;
    text-transform: uppercase;
}

.dark-mode .tool-call-container.collapsed::before {
    background-color: #4338ca;
    color: #e0e7ff;
}

/* Dashboard specific styles */
.report-chart-container {
    transition: all 0.2s ease-in-out;
    position: relative;
    cursor: pointer;
    background: rgba(248, 248, 248, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.report-chart-container:hover {
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
}

.report-chart-container.chart-loaded {
    background-color: rgba(255, 255, 255, 0.5);
}

.report-chart-container::after {
    content: 'Click to view details';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    z-index: 10;
}

.report-chart-container:hover::after {
    opacity: 1;
}

/* Make charts respect container size */
.report-chart {
    width: 100% !important;
    height: 100% !important;
}

/* Report card styling */
.report-card {
    transition: transform 0.2s ease-in-out;
}

.report-card:hover {
    transform: translateY(-2px);
}

/* Modal chart styling */
#report-modal-chart {
    width: 100% !important;
    height: 100% !important;
}

/* Dark mode adjustments for dashboard */
.dark .report-chart-container {
    background: rgba(55, 65, 81, 0.3);
}

.dark .report-chart-container.chart-loaded {
    background-color: rgba(30, 41, 59, 0.5);
}

/* Improved dashboard grid layout */
@media (min-width: 1024px) {
    #grid-view {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

/* ===== CONSISTENT PAGE HEADER STYLES ===== */
/* Add these styles to your existing styles.css file */

/* Consistent header styling across all pages */
.page-header {
    background-color: white;
    padding: 1rem 1.5rem; /* 16px vertical (matches sidebar), 24px horizontal */
    border-bottom: 1px solid #e5e7eb; /* gray-200 - matches sidebar border */
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    min-height: 72px; /* Matches sidebar header height */
}

.page-title {
    font-size: 1.5rem; /* text-2xl */
    font-weight: 600; /* font-semibold */
    color: #111827; /* text-gray-900 */
    margin: 0;
    line-height: 1.2;
}

/* Header button styling for consistency */
.header-button {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: #3b82f6; /* blue-500 */
    color: white;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: background-color 0.2s, transform 0.1s;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
}

.header-button:hover {
    background-color: #2563eb; /* blue-600 */
    transform: translateY(-1px);
    text-decoration: none;
}

.header-button:active {
    transform: translateY(0);
}

.header-button svg {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.25rem;
    flex-shrink: 0;
}

/* Chat-specific title styling for editing functionality */
.chat-title {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
    margin: -0.25rem -0.5rem; /* Negative margin to maintain alignment */
}

.chat-title:hover {
    background-color: #f9fafb; /* gray-50 */
}

.chat-title:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    background-color: #f9fafb;
}

/* Dark mode support */
.dark-mode .page-header {
    background-color: #1f2937; /* gray-800 */
    border-color: #374151; /* gray-700 */
}

.dark-mode .page-title {
    color: #f9fafb; /* text-gray-100 */
}

.dark-mode .chat-title:hover {
    background-color: #374151; /* gray-700 */
}

.dark-mode .chat-title:focus {
    background-color: #374151;
}

.dark-mode .header-button {
    background-color: #3b82f6;
}

.dark-mode .header-button:hover {
    background-color: #2563eb;
}

/* Override existing dashboard header styles to use consistent header */
.dashboard-header {
    /* Remove existing styles and use .page-header class instead */
    margin-bottom: 0 !important;
    padding: 0 !important;
}

/* Update dashboard container to work with new header */
.dashboard-container {
    /* Keep existing flex layout but remove padding from header area */
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
}

/* Create scrollable content area for dashboard */
.dashboard-content {
    flex: 1 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    padding: 1.5rem !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .page-header {
        padding: 0.75rem 1rem; /* Reduce padding on mobile */
        min-height: 60px;
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .page-title {
        font-size: 1.25rem; /* text-xl */
        text-align: center;
    }
    
    .header-button {
        justify-content: center;
        width: 100%;
    }
    
    .chat-title {
        text-align: center;
        margin: 0;
        padding: 0.5rem;
    }
}

@media (max-width: 640px) {
    .page-header {
        padding: 0.75rem;
        min-height: 60px;
    }
    
    .page-title {
        font-size: 1.125rem; /* text-lg */
    }
    
    .header-button {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .header-button svg {
        width: 1rem;
        height: 1rem;
    }
}

/* Ensure proper spacing for header content */
.page-header .flex {
    gap: 0.5rem;
}

/* Additional utility for header actions group */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .header-actions {
        width: 100%;
        justify-content: center;
    }
}

/* Fix any existing conflicting styles */
.bg-white.p-4.border-b {
    /* Override inline styles that might conflict */
    padding: 0 !important;
}

/* Ensure headers work with existing chat and dashboard layouts */
.chat-title[data-chat-id] {
    /* Preserve existing functionality attributes */
    user-select: none;
}

/* Loading state for header buttons */
.header-button.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.header-button.loading::after {
    content: '';
    display: inline-block;
    width: 1rem;
    height: 1rem;
    margin-left: 0.5rem;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Focus styles for accessibility */
.header-button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.dark-mode .header-button:focus {
    outline-color: #60a5fa;
}

/* Ensure text doesn't wrap in titles */
.page-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    .page-title {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        text-align: center;
    }
}

.sidebar-header,
.page-header {
    min-height: 72px; /* Force same height */
}