/* Main CSS - Root Variables and Global Styles */

:root {
    /* Color Palette */
    --primary-color: #4285f4;
    --primary-hover: #3367d6;
    --primary-light: #e8f0fe;
    --secondary-color: #5f6368;
    --background-color: #ffffff;
    --surface-color: #f8f9fa;
    --sidebar-bg: #f8f9fa;
    --border-color: #e8eaed;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-tertiary: #80868b;
    --error-color: #d93025;
    --success-color: #1e8e3e;
    --warning-color: #f9ab00;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-md: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 24px;
    --font-size-xxl: 32px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
    
    /* Z-index */
    --z-modal: 1000;
    --z-header: 100;
    --z-sidebar: 50;
}

/* Dark Mode Variables */
body.dark-mode {
    /* Color Palette - Dark Mode */
    --primary-color: #8ab4f8;
    --primary-hover: #aecbfa;
    --primary-light: #1a3a52;
    --secondary-color: #9aa0a6;
    --background-color: #1f1f1f;
    --surface-color: #2d2d2d;
    --sidebar-bg: #2d2d2d;
    --border-color: #3c4043;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-tertiary: #5f6368;
    --error-color: #f28b82;
    --success-color: #81c995;
    --warning-color: #fdd663;
    
    /* Adjust shadows for dark mode */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

/* High Contrast Mode Variables */
body.high-contrast {
    /* High Contrast - Light Base */
    --primary-color: #0000ff;
    --primary-hover: #0000cc;
    --primary-light: #e0e0ff;
    --secondary-color: #000000;
    --background-color: #ffffff;
    --surface-color: #ffffff;
    --sidebar-bg: #ffffff;
    --border-color: #000000;
    --text-primary: #000000;
    --text-secondary: #000000;
    --text-tertiary: #333333;
    --error-color: #cc0000;
    --success-color: #008000;
    --warning-color: #cc8800;
    
    /* Enhanced shadows */
    --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.8);
    --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.8);
    --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.8);
    --shadow-xl: 0 20px 30px -5px rgba(0, 0, 0, 0.8);
}

/* High Contrast Dark Mode */
body.high-contrast.dark-mode {
    /* High Contrast - Dark Base */
    --primary-color: #ffff00;
    --primary-hover: #ffff66;
    --primary-light: #666600;
    --secondary-color: #ffffff;
    --background-color: #000000;
    --surface-color: #000000;
    --sidebar-bg: #000000;
    --border-color: #ffffff;
    --text-primary: #ffffff;
    --text-secondary: #ffffff;
    --text-tertiary: #cccccc;
    --error-color: #ff6666;
    --success-color: #66ff66;
    --warning-color: #ffcc00;
    
    /* Enhanced shadows for dark high contrast */
    --shadow-sm: 0 2px 4px 0 rgba(255, 255, 255, 0.5);
    --shadow-md: 0 4px 8px -1px rgba(255, 255, 255, 0.5);
    --shadow-lg: 0 10px 20px -3px rgba(255, 255, 255, 0.5);
    --shadow-xl: 0 20px 30px -5px rgba(255, 255, 255, 0.5);
}

/* High Contrast Enhanced Borders and Focus */
body.high-contrast * {
    border-width: 2px !important;
    font-weight: 500;
}

body.high-contrast button,
body.high-contrast input,
body.high-contrast textarea,
body.high-contrast select {
    border: 3px solid var(--border-color) !important;
}

body.high-contrast :focus-visible {
    outline: 4px solid var(--primary-color) !important;
    outline-offset: 4px;
}

body.high-contrast a {
    text-decoration: underline;
    font-weight: 600;
}

body.high-contrast .btn {
    font-weight: 700;
    border: 3px solid var(--border-color) !important;
}

body.high-contrast .chat-message {
    border: 2px solid var(--border-color) !important;
}

body.high-contrast code,
body.high-contrast pre {
    border: 2px solid var(--border-color) !important;
}

body.high-contrast .btn-new-chat {
    color: #ffffff !important;
}

body.high-contrast.dark-mode .btn-new-chat {
    color: #000000 !important;
}

/* Keep slider and high contrast button with standard colors (not high contrast yellow/blue) */
body.high-contrast #highContrastBtn.active {
    background-color: #4285f4 !important;
    color: #ffffff !important;
}

body.high-contrast.dark-mode #highContrastBtn.active {
    background-color: #8ab4f8 !important;
    color: #000000 !important;
}

body.high-contrast .theme-toggle input:checked + .theme-toggle-slider {
    background-color: #4285f4 !important;
}

body.high-contrast.dark-mode .theme-toggle input:checked + .theme-toggle-slider {
    background-color: #8ab4f8 !important;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    color: var(--text-primary);
    background-color: var(--background-color);
    line-height: 1.6;
    overflow: hidden;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

.text-error {
    color: var(--error-color);
}

.text-success {
    color: var(--success-color);
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    font-family: var(--font-family);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    user-select: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--surface-color);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--border-color);
}

.btn-icon {
    padding: var(--spacing-sm);
    background-color: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-full);
}

.btn-icon:hover:not(:disabled) {
    background-color: var(--surface-color);
    color: var(--text-primary);
    box-shadow: none;
}

/* Container Layout */
.container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--background-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    animation: modalSlideIn var(--transition-normal);
}

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

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

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

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--surface-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .modal-content {
        max-width: 95%;
        padding: var(--spacing-lg);
    }
}

/* Selection */
::selection {
    background-color: var(--primary-light);
    color: var(--text-primary);
}

/* Focus Styles */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Smooth Animations */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark Mode Toggle Switch */
.theme-toggle-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

#highContrastBtn {
    transition: all var(--transition-normal);
}

/* #highContrastBtn.active {
    background-color: #4285f4;
    color: white;
} 

body.dark-mode #highContrastBtn.active {
    background-color: #8ab4f8;
    color: #000000;
}
*/
.theme-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.theme-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: var(--transition-normal);
    border-radius: var(--radius-full);
}

.theme-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition-normal);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle input:checked + .theme-toggle-slider {
    background-color: var(--primary-color);
}

.theme-toggle input:checked + .theme-toggle-slider:before {
    transform: translateX(24px);
}

.theme-toggle-slider:hover {
    opacity: 0.9;
}

.theme-icon {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.theme-toggle-container:hover .theme-icon {
    color: var(--text-primary);
}

/* High Contrast Button States */
body.high-contrast #highContrastBtn svg {
    stroke-width: 3;
}
