/* Inter font family */
body {
    font-family: 'Inter', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
    /* Smooth theme transition */
}

:root {
    /* --- Dark Theme Colors (Inspired by the dark button and deep blues in the illustration) --- */
    --bg-primary: #0a0b17;
    /* Near-black/Very dark indigo for main background */
    --bg-secondary: #131524;
    /* Dark indigo for main containers */
    --bg-tertiary: #20243b;
    /* Muted dark blue for elements */
    --bg-quaternary: #39426f;
    /* Deep blue/indigo for vibrant sections */

    --text-primary: #f0f0ff;
    /* Off-white for main text (from the logo/illustration background) */
    --text-secondary: #c9cce0;
    /* Light gray-blue */
    --text-tertiary: #9ea3bd;
    /* Muted gray-blue */
    --text-quaternary: #747a94;
    /* Subtle text/placeholder */

    --border-color: #39426f;
    /* Deep blue border */

    --accent-primary: #fa6c58;
    /* Reddish-Orange/Salmon from the illustration (CTA color) */
    --accent-primary-hover: #e55e4b;
    --accent-primary-light: #ff9d8d;
    --accent-green: #2ecc71;
    --accent-yellow: #ffc958;
    /* Brighter yellow/orange for contrast */
    --accent-red: #ef4444;

    --accent-primary-subtle: #ffefe8;
    /* Very light salmon tint */
    --accent-primary-subtle-border: #ffb7a8;

    --citation-popup-bg-dark: #070810;
    --citation-popup-border-dark: #1e1e32;
}

[data-theme="light"] {
    /* --- Light Theme Colors (Inspired by the white background, deep blue elements, and black text) --- */
    --bg-primary: #ffffff;
    /* Pure white (main background) */
    --bg-secondary: #f7f7fa;
    /* Off-white/Very light gray-blue */
    --bg-tertiary: #e9e9f3;
    /* Light gray-blue */
    --bg-quaternary: #d1d1e4;
    /* Muted light blue/gray */

    --text-primary: #121212;
    /* Near-black (from button/logo text) */
    --text-secondary: #33334d;
    /* Very dark gray-blue */
    --text-tertiary: #5c5c7d;
    /* Darker muted blue for less important text */
    --text-quaternary: #8686a6;
    /* Subtle blue/gray */

    --border-color: #d1d1e4;

    --accent-primary: #fa6c58;
    /* Reddish-Orange/Salmon from the illustration (CTA color) */
    --accent-primary-hover: #e55e4b;
    --accent-primary-light: #fa9080;
    /* Slightly lighter salmon for contrast */
    --accent-green: #2ecc71;
    --accent-yellow: #f59e0b;
    --accent-red: #dc2626;

    --accent-primary-subtle: #ffefe8;
    /* Very light salmon tint */
    --accent-primary-subtle-border: #ffb7a8;

    --citation-popup-bg-light: #fdfdff;
    --citation-popup-border-light: #e0e0f0;
}

/* Apply theme variables to default elements and Tailwind overrides */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Sidebar, Main Content, Modals */
.bg-gray-800 {
    background-color: var(--bg-secondary);
}

.bg-gray-700 {
    background-color: var(--bg-tertiary);
}

.bg-gray-600 {
    background-color: var(--bg-quaternary);
}

/* Text colors */
.text-gray-100 {
    color: var(--text-primary);
}

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

.text-gray-300 {
    color: var(--text-tertiary);
}

.text-gray-400 {
    color: var(--text-quaternary);
}

/* Borders */
.border-gray-700 {
    border-color: var(--border-color);
}

.border-gray-600 {
    border-color: var(--bg-quaternary);
}

/* Using quaternary background for this border */

/* Accent Colors */
.custom-bg-600 {
    background-color: var(--accent-primary);
}

.hover\:custom-bg-700:hover {
    background-color: var(--accent-primary-hover);
}

.custom-bg-400 {
    background-color: var(--accent-primary-light);
}

.text-blue-400 {
    color: var(--accent-primary-light);
}

.text-green-400 {
    color: var(--accent-green);
}

.text-yellow-400 {
    color: var(--accent-yellow);
}

.text-red-400 {
    color: var(--accent-red);
}

/* Placeholders */
.placeholder-gray-400::placeholder {
    color: var(--text-quaternary);
}

/* Hover states for interactive elements (buttons, links) */
.hover\:bg-gray-700:hover {
    background-color: var(--bg-tertiary);
}

.hover\:bg-gray-600:hover {
    background-color: var(--bg-quaternary);
}

/* Form elements */
.form-checkbox {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
}

/* Custom scrollbar for better aesthetics */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    /* Use theme variable */
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-quaternary);
    /* Use theme variable */
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-quaternary);
    /* A slightly darker shade for hover */
}

/* Style for the citation popup */
.citation-popup {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 8px);
    /* 8px above the citation span */
    width: max-content;
    max-width: 20rem;
    /* Limit width */
    padding: 0.75rem;
    color: var(--text-primary);
    /* Use primary text color for readability */
    font-size: 0.75rem;
    /* text-xs */
    border-radius: 0.5rem;
    /* rounded-lg */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    /* shadow-lg */
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s ease-out, transform 0.1s ease-out;
    pointer-events: none;
    /* Allows clicks to pass through when hidden */

    /* Apply specific background and border based on theme */
    background-color: var(--citation-popup-bg-dark);
    /* Default dark theme */
    border: 1px solid var(--citation-popup-border-dark);
    /* Default dark theme */
}

/* Adjust citation popup colors for light theme */
[data-theme="light"] .citation-popup {
    background-color: var(--citation-popup-bg-light);
    border: 1px solid var(--citation-popup-border-light);
}


.citation-popup::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 100%;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    /* Match the border-top-color to the popup's background color */
    border-top: 8px solid var(--citation-popup-bg-dark);
    /* Default dark theme */
}

[data-theme="light"] .citation-popup::after {
    border-top: 8px solid var(--citation-popup-bg-light);
}

.citation-span:hover .citation-popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Animation for sun/moon icon */
.spin {
    animation: spin 0.5s linear;
}

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

    to {
        rotate(360deg);
    }
}

/* Typing indicator animation */
.dot-pulse {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-quaternary);
    /* Match placeholder/subtle text */
    color: var(--text-quaternary);
    animation: dotPulse 1.5s infinite ease-in-out;
}

.dot-pulse::before,
.dot-pulse::after {
    content: '';
    position: absolute;
    top: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-quaternary);
    /* Match placeholder/subtle text */
    animation: dotPulse 1.5s infinite ease-in-out;
}

.dot-pulse::before {
    left: -12px;
    animation-delay: 0.3s;
}

.dot-pulse::after {
    left: 12px;
    animation-delay: 0.6s;
}

@keyframes dotPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(0.75);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Spinner animation for button */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #ffffff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}
