@import url('https://fonts.cdnfonts.com/css/latin-modern-roman');
/* Commercial Design System - ScienceAI */

/* 1. Variables & Theme */
:root {
    /* Brand Colors - Science Blue Theme */
    --primary: #0284c7;
    /* Sky 600 - Professional Blue */
    --primary-hover: #0369a1;
    /* Sky 700 */
    --primary-light: #e0f2fe;
    /* Sky 100 */

    /* Neutral/Surface Colors */
    --background: #f1f5f9;
    /* Slate 100 */
    --surface: #ffffff;
    /* White */
    --surface-glass: rgba(255, 255, 255, 0.95);
    --surface-alt: #f8fafc;
    /* Slate 50 */

    /* Text Colors */
    --text-main: #0f172a;
    /* Slate 900 */
    --text-muted: #64748b;
    /* Slate 500 */
    --text-light: #ffffff;
    /* White */

    /* Borders & Shadows */
    --border: #e2e8f0;
    /* Slate 200 */
    --border-focus: #6366f1;
    /* Indigo 500 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Functional Colors */
    --success: #10b981;
    /* Emerald 500 */
    --warning: #f59e0b;
    /* Amber 500 */
    --danger: #ef4444;
    /* Red 500 */

    /* Gradients & Special */
    --gradient-header: linear-gradient(to bottom, rgba(255, 255, 255, 0.5), transparent);
    --btn-danger-bg: #ef4444;
    --btn-danger-hover: #dc2626;

    /* Layout & Spacing */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --header-height: 60px;

    /* New Variables Refactor */
    --background-body: #fef7e8;
    --scrollbar-thumb: #cbd5e1;
    --scrollbar-thumb-hover: #94a3b8;
    --border-secondary-hover: #cbd5e1;
    --danger-hover: #dc2626;
    --modal-overlay: rgba(15, 23, 42, 0.4);
    --glass-border: rgba(255, 255, 255, 0.3);
    --chat-bubble-user-bg: #ffd88c;
    --chat-bubble-user-text: #1a1a1a;
    --chat-bubble-ai-bg: #fef7e8;
    --chat-bubble-ai-text: #1a1a1a;
    --alert-bg: #fef2f2;
    --alert-text: #991b1b;
    --alert-border: #fecaca;
    --shadow-bubble-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-bubble-md: 0 1px 2px rgba(0, 0, 0, 0.08);
    --black: #000000;
    --white: #fcfaf6;
    --icon-bg: transparent;
}

/* Dark Mode Theme */
[data-theme="dark"] {
    /* Brand Colors - Enhanced for dark mode */
    --primary: #38bdf8;
    /* Sky 400 - Brighter for dark backgrounds */
    --primary-hover: #0ea5e9;
    /* Sky 500 */
    --primary-light: #082f49;
    /* Sky 950 - Inverted */

    /* Neutral/Surface Colors */
    --background: #0f172a;
    /* Slate 900 - Deep dark blue */
    --surface: #1e293b;
    /* Slate 800 */
    --surface-glass: rgba(30, 41, 59, 0.95);
    --surface-alt: #334155;
    /* Slate 700 */

    /* Text Colors */
    --text-main: #f8fafc;
    /* Slate 50 - Light text */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --text-light: #0f172a;
    /* Slate 900 - Inverted for buttons */

    /* Borders & Shadows */
    --border: #334155;
    /* Slate 700 */
    --border-focus: #818cf8;
    /* Indigo 400 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.6), 0 8px 10px -6px rgb(0 0 0 / 0.5);

    /* Functional Colors - Adjusted for better visibility */
    --success: #34d399;
    /* Emerald 400 */
    --warning: #fbbf24;
    /* Amber 400 */
    --danger: #f87171;
    /* Red 400 */

    /* Gradients & Special */
    --gradient-header: linear-gradient(to bottom, rgba(255, 255, 255, 0.05), transparent);
    --btn-danger-bg: #dc2626;
    --btn-danger-hover: #b91c1c;

    /* Dark Mode Specific */
    --background-body: #0f172a;
    --scrollbar-thumb: #475569;
    /* Slate 600 */
    --scrollbar-thumb-hover: #64748b;
    /* Slate 500 */
    --border-secondary-hover: #475569;
    --danger-hover: #ef4444;
    --modal-overlay: rgba(0, 0, 0, 0.7);
    --glass-border: rgba(148, 163, 184, 0.2);
    --chat-bubble-user-bg: #1e3a5f;
    /* Deep blue */
    --chat-bubble-user-text: #e0f2fe;
    --chat-bubble-ai-bg: #1e293b;
    /* Slate 800 */
    --chat-bubble-ai-text: #f8fafc;
    --alert-bg: #7f1d1d;
    /* Red 900 */
    --alert-text: #fecaca;
    /* Red 200 */
    --alert-border: #991b1b;
    /* Red 800 */
    --shadow-bubble-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-bubble-md: 0 1px 2px rgba(0, 0, 0, 0.4);
    --black: #ffffff;
    --white: #0f172a;
    --icon-bg: rgba(255, 255, 255, 0.1);
}

/* 2. Reset & Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--white);
    color: var(--text-main);
    margin: 0;
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 0;
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--text-main);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
}

/* 3. Layout Utilities */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
}

.grid {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    flex-direction: row;
    gap: 1.5rem;
}

/* Glassmorphism Utility */
.glass-panel {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

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

/* 4. Components */

/* Buttons */
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(to bottom, var(--primary), var(--primary-hover));
    color: var(--text-light);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

button:hover {
    background: linear-gradient(to bottom, var(--primary-hover), #025a8a);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm), inset 0 2px 3px rgba(0, 0, 0, 0.1);
}

button.secondary {
    background: linear-gradient(to bottom, var(--surface), var(--surface-alt));
    color: var(--text-main);
    border-color: var(--border);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

button.secondary:hover {
    background: linear-gradient(to bottom, var(--surface-alt), #e2e8f0);
    border-color: var(--border-secondary-hover);
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

button.danger {
    background-color: var(--danger);
}

button.danger:hover {
    background-color: var(--danger-hover);
}

/* Inputs */
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--surface);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
    outline: none;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light), inset 0 1px 2px rgba(0, 0, 0, 0.05);
    background-color: var(--white);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    /* Slate 900 with opacity */
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background-color: var(--surface);
    margin: 5vh auto;
    padding: 2rem;
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-xl);
    position: relative;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border);
}

.close {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: var(--text-main);
}

/* 5. App Specific Layouts */

/* Resize Sections */
#container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background-color: var(--background);
}

.resize-title {
    display: none !important;
}

.resize-section {
    background: linear-gradient(to bottom, var(--white), var(--surface-alt));
    position: relative;
    display: flex;
    flex-direction: column;
    border-right: 2px solid var(--border);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.5);
}

.resize-section-internal {
    padding: 3rem;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: transparent;
}

.resize-handle {
    width: 8px;
    background: var(--border);
    position: absolute;
    right: 0px;
    top: 0;
    bottom: 0;
    z-index: 10;
    cursor: col-resize;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resize-handle::after {
    content: "";
    display: block;
    width: 2px;
    height: 20px;
    background-color: var(--text-muted);
    border-radius: 1px;
}

.resize-handle:hover,
.resize-handle:active {
    background: var(--primary);
}

.resize-handle:hover::after,
.resize-handle:active::after {
    background-color: var(--surface);
}

/* Headers */
.resize-section h2 {
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 1rem;
    padding: 0.75rem 1rem 0.75rem 1rem;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.06), 0 1px 0 rgba(255, 255, 255, 0.8);
    background: var(--gradient-header);
    border-radius: var(--radius-sm);
    margin-left: -0.5rem;
}

/* Papers List */
.papers-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    min-height: 0;
}

.card {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
    margin-bottom: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15),
        0 2px 4px -2px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2),
        0 4px 6px -4px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border-color: var(--primary);
    transform: translateY(-3px) scale(1.01);
}

.icon-container-box {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    height: 100%;
    align-items: flex-end;
}

.icon-container-box-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 4px;
    border-radius: 4px;
    background-color: var(--icon-bg);
    transition: background-color 0.2s;
}

.icon-container-pdf-image {
    width: 48px;
    height: 48px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-image: url('https://www.svgrepo.com/show/152004/pdf.svg');
}

.icon-container-json-image {
    width: 48px;
    height: 48px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-image: url('https://cdn-icons-png.flaticon.com/512/136/136443.png');
}

.icon-container-csv-image {
    width: 48px;
    height: 48px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-image: url('https://www.svgrepo.com/show/104744/csv-file-format-extension.svg');
}

.button-icon-menu {
    display: flex;
    gap: 0.25rem;
}

.icon-button {
    padding: 0.25rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    box-shadow: none;
    font-size: 1rem;
}

.icon-button:hover {
    color: var(--primary);
    background: var(--primary-light);
    transform: none;
}

/* Close button styling */
.close-icon {
    margin-left: 5px;
    font-weight: bold;
}

/* Chat Interface */
#chat {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: linear-gradient(to bottom, var(--surface-alt), var(--background));
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Ensure the HTMX websocket wrapper fills the space */
[hx-ext="ws"] {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-bubble {
    max-width: 75%;
    padding: 1.2rem 1.5rem;
    /* More padding for breathing room */
    border-radius: 1.25rem;
    /* All corners rounded by default */
    position: relative;
    font-size: 1.05rem;
    /* Increased for better legibility */
    line-height: 1.6;
    /* Better line spacing */
    box-shadow: var(--shadow-bubble-sm);
    /* Very subtle shadow */
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.01em;
}

.chat-bubble-user {
    background-color: var(--chat-bubble-user-bg);
    /* Very light blue */
    color: var(--chat-bubble-user-text);
    /* Black text */
    margin-left: auto;
    max-width: 92%;
    padding: 1rem 1.5rem;
    /* Less padding */
    font-size: 1.05rem;
    line-height: 1.6;
    position: relative;
    box-shadow: var(--shadow-bubble-sm);
    font-family: 'Latin Modern Roman';
    letter-spacing: 0.01em;
    border-radius: 0.65rem;
    border-bottom-right-radius: 0;
}

.chat-bubble-ai {
    background-color: var(--chat-bubble-ai-bg);
    /* Light tan/papyrus */
    color: var(--chat-bubble-ai-text);
    /* Black text */
    margin-right: auto;
    max-width: 92%;
    padding: 1rem 1.5rem;
    /* Less padding */
    font-size: 1.05rem;
    line-height: 1.6;
    position: relative;
    box-shadow: var(--shadow-bubble-md);
    font-family: 'Latin Modern Roman';
    letter-spacing: 0.01em;
    border-radius: 0.65rem;
    border-bottom-left-radius: 0;
    border: none;
}

.chat-bubble-timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding: 0 0.5rem;
    font-family: 'Latin Modern Roman', serif;
}

.chat-bubble-area-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-bottom: 0.5rem;
}

.chat-bubble-area-ai {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    font-family: 'Latin Modern Roman';
}

.chat-bubble-area-user .chat-bubble-timestamp {
    text-align: right;
}

.chat-bubble-area-ai .chat-bubble-timestamp {
    text-align: left;
}

/* Undo Request Button */
.undo-request-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.75rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 500;
    background: linear-gradient(to bottom, var(--surface), var(--surface-alt));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.undo-request-btn:hover {
    background: linear-gradient(to bottom, var(--warning), #d97706);
    border-color: var(--warning);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.undo-request-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text-muted);
}

.undo-request-btn.disabled:hover {
    opacity: 0.6;
    transform: none;
    box-shadow: var(--shadow-sm);
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text-muted);
}

/* Reset button variant - more prominent/dangerous styling */
.undo-request-btn.reset-btn {
    background: linear-gradient(to bottom, var(--btn-danger-bg), var(--danger-hover));
    border-color: var(--btn-danger-bg);
    color: white;
}

.undo-request-btn.reset-btn:hover {
    background: linear-gradient(to bottom, var(--btn-danger-hover), var(--btn-danger-bg));
    border-color: var(--btn-danger-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.show-work-button {
    background-color: var(--chat-bubble-ai-bg);
    border: 1px solid var(--black);
    color: var(--black);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-family: 'Latin Modern Roman';
    font-weight: 500;
    cursor: pointer;
    margin: 0.5rem 0;
    transition: all 0.2s;
    display: inline-block;
    text-align: center;
}

.show-work-button:hover {
    background-color: var(--chat-bubble-ai-bg);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.chat-bubble-tool {
    background-color: var(--surface-alt);
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
    width: 100%;
}

/* Reset styling for content inside chat bubbles */
.chat-bubble-ai h1,
.chat-bubble-ai h2,
.chat-bubble-ai h3,
.chat-bubble-ai h4,
.chat-bubble-ai h5,
.chat-bubble-ai h6,
.chat-bubble-user h1,
.chat-bubble-user h2,
.chat-bubble-user h3,
.chat-bubble-user h4,
.chat-bubble-user h5,
.chat-bubble-user h6 {
    font-weight: inherit;
    letter-spacing: normal;
    color: inherit;
    margin: 0.5em 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: none;
}

.chat-bubble-ai ul,
.chat-bubble-ai ol,
.chat-bubble-user ul,
.chat-bubble-user ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
    color: var(--text-main);
}

.chat-bubble-ai li,
.chat-bubble-user li {
    margin: 0.25em 0;
    color: var(--text-main);
}

.chat-bubble-ai p,
.chat-bubble-user p {
    margin: 0.5em 0;
}

.chat-bubble-ai a,
.chat-bubble-user a {
    color: var(--primary);
    text-decoration: underline;
}

.chat-bubble-ai code,
.chat-bubble-user code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
}

.chat-bubble-ai pre,
.chat-bubble-user pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.5em;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 0.5em 0;
}

.chat-bubble-ai blockquote,
.chat-bubble-user blockquote {
    margin: 0.5em 0;
    padding-left: 1em;
    border-left: 3px solid rgba(0, 0, 0, 0.1);
}

.chat-input-container {
    background: var(--white);
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.chat-form {
    display: flex;
    gap: 0.75rem;
}

.chat-form textarea {
    resize: none;
    min-height: 44px;
    max-height: 120px;
}

/* Analysis Section */
#right-section-internal {
    overflow-y: auto;
}

#right-section-internal h2 {
    position: sticky;
    top: 0;
    z-index: 10;
    margin-top: 0;
    padding-top: 0;
    /* Adjust for visual balance */
}

#papers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
    padding: 0.75rem;
}

#data-viewer {
    overflow-y: auto;
}

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 0.75rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    font-size: 0.9rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.card button,
.card a.icon-button {
    word-break: normal;
    overflow-wrap: normal;
}

.analysis-widget {
    background: linear-gradient(to bottom, var(--surface), var(--surface-alt));
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.analysis-header {
    padding: 1rem;
    border-bottom: 2px solid var(--border);
    background: linear-gradient(to bottom, rgba(248, 250, 252, 0.8), var(--surface-alt));
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.analysis-content {
    padding: 1rem;
    overflow-y: auto;
    max-height: 600px;
    /* Adjust as needed */
}

/* Menu Page Specifics */
.open-project-menu {
    background: linear-gradient(to bottom, var(--surface), var(--surface-alt));
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    padding: 2rem;
    margin: 2rem auto;
    max-width: 480px;
    border: 2px solid var(--border);
    height: auto;
}

.open-project-menu h2 {
    color: var(--primary);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Project Menu (Top Right) */
.project-menu {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 100;
    background: var(--surface-glass);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-md);
}

.project-menu button {
    padding: 0.6rem 0.6rem;
    font-size: 1.2rem;
    line-height: 1;
    background: transparent;
    color: var(--text-muted);
    box-shadow: none;
    border: 1px solid transparent;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    max-width: 2.5rem;
    transition: max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.2s,
        color 0.2s;
}

.project-menu button span {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Default state - show only emoji */
.project-menu button span::after {
    content: attr(data-text);
    opacity: 0;
    transform: translateX(-10px);
    font-size: 0.85rem;
    transition: opacity 0.25s ease 0.05s,
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.05s;
}

/* Hover state - expand and show text */
.project-menu:hover button {
    max-width: 200px;
    padding: 0.6rem 0.85rem;
}

.project-menu:hover button span::after {
    opacity: 1;
    transform: translateX(0);
}

.project-menu button:hover {
    background: var(--surface-alt);
    color: var(--text-main);
    transform: none;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    gap: 4px;
    padding: 0.5rem;
    justify-content: center;
    width: 100%;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

/* Analysis View Specifics */
details {
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: linear-gradient(to bottom, var(--surface), var(--surface-alt));
    overflow: hidden;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
}

details[open] {
    background: var(--surface-alt);
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

summary {
    padding: 0.75rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-main);
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s, color 0.2s;
}

.search-box {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: linear-gradient(to bottom, var(--surface), var(--surface-alt));
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Modal Styles */
summary:hover {
    background: var(--surface-alt);
}

summary::after {
    content: '+';
    font-weight: bold;
    color: var(--text-muted);
    margin-left: auto;
}

details[open]>summary::after {
    content: '-';
}

details[open]>summary {
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.nested {
    padding: 0.75rem 0 0.75rem 1rem;
    margin-left: 0.5rem;
    margin-top: 0.5rem;
}

details p,
details div:not(.nested) {
    padding: 0 0.75rem 0.5rem 0.75rem;
}

.db-load-info {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-left: 1rem;
}

.load-button {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.load-button:hover {
    background: linear-gradient(135deg, #bfdbfe 0%, var(--primary-light) 100%);
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(2, 132, 199, 0.3),
        0 2px 4px -2px rgba(2, 132, 199, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transform: translateY(-2px) scale(1.05);
}

.load-button:active {
    transform: translateY(0) scale(1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.reload {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: linear-gradient(135deg, var(--primary-light), rgba(224, 242, 254, 0.7));
    color: var(--primary);
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(2, 132, 199, 0.2);
    box-shadow: 0 1px 2px rgba(2, 132, 199, 0.1);
}

.tag .fas {
    margin-left: 0.25rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    background: var(--alert-bg);
    color: var(--alert-text);
    border: 1px solid var(--alert-border);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pi-generated-content img {
    max-width: 100%;
}

/* Progress Wheel Indicator */
.progress-wheel-container {
    padding: 0.5rem;
    width: 100%;
    animation: fadeIn 0.3s ease-in;
    display: none;
    /* Start hidden by default */
    position: relative;
    z-index: 50;
}

.progress-wheel-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: pulse 2s ease-in-out infinite;
}

.progress-wheel-visual {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.progress-circle {
    transform: rotate(-90deg);
}

.progress-circle-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 5;
}

.progress-circle-fill {
    fill: none;
    stroke: var(--primary);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 151;
    stroke-dashoffset: 151;
    transition: stroke-dashoffset 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

.progress-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 120px;
}

.progress-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-description {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 10px 15px -3px rgb(2 132 199 / 0.2), 0 4px 6px -4px rgb(2 132 199 / 0.2);
    }
}

/* Context Usage Indicator */
.context-indicator {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
    border: 1px solid var(--border);
    border-radius: 9999px;
    box-shadow: var(--shadow-sm);
    opacity: 0.7;
    transition: all 0.3s ease;
    cursor: help;
}

.context-indicator:hover {
    opacity: 1;
    box-shadow: var(--shadow-md);
}

.context-indicator::before {
    content: '🧠';
    font-size: 0.8rem;
}

.context-indicator.context-warning {
    color: var(--warning);
    border-color: var(--warning);
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.context-indicator.context-warning::before {
    content: '⚠️';
}

.context-indicator.context-critical {
    color: var(--danger);
    border-color: var(--danger);
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    animation: contextPulse 2s ease-in-out infinite;
}

.context-indicator.context-critical::before {
    content: '🔴';
}

@keyframes contextPulse {

    0%,
    100% {
        opacity: 0.8;
        transform: translateY(-50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.05);
    }
}

/* Context Limit Reached Banner */
.context-limit-banner {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    margin: 1rem 0;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid var(--warning);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.context-limit-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.context-limit-text {
    flex: 1;
}

.context-limit-text strong {
    display: block;
    font-size: 1.1rem;
    color: #92400e;
    margin-bottom: 0.5rem;
}

.context-limit-text p {
    margin: 0.5rem 0;
    color: #78350f;
    font-size: 0.95rem;
    line-height: 1.5;
}

.context-limit-text ul {
    margin: 0.75rem 0;
    padding-left: 1.25rem;
    color: #78350f;
}

.context-limit-text li {
    margin: 0.35rem 0;
    font-size: 0.9rem;
}

.context-compress-section {
    margin-top: 0.5rem;
}

.context-compress-section strong {
    color: #92400e;
    display: block;
    margin-bottom: 0.5rem;
}

.compress-context-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.5rem;
}

.compress-context-btn:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.compress-context-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

/* PI Generated File Links */
.pi-file-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.65rem;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    margin: 0.25rem 0.125rem;
    vertical-align: middle;
}

.pi-file-link:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.pi-file-name {
    color: var(--text-main);
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pi-file-buttons {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
    margin-left: 0.25rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--border);
}

.pi-file-buttons .icon-button {
    padding: 0.2rem 0.35rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

/* LLM Provider Selector */
.provider-selector {
    width: 100%;
}

.provider-options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.provider-option {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 100px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.provider-option input[type="radio"] {
    display: none;
}

.provider-option .provider-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    height: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.provider-option .provider-label i {
    font-size: 1.5rem;
    color: var(--primary);
    transition: all 0.2s ease;
}

.provider-option .provider-label span {
    font-weight: 500;
    color: var(--text-main);
}

.provider-option .provider-label .no-key {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
}

/* Hover state for enabled providers */
.provider-option:not(.disabled):hover .provider-label {
    border-color: var(--primary);
    background: linear-gradient(135deg, #e0f2fe 0%, var(--primary-light) 100%);
    box-shadow: 0 4px 6px -1px rgba(2, 132, 199, 0.2),
        0 2px 4px -2px rgba(2, 132, 199, 0.15);
    transform: translateY(-2px);
}

/* Selected state */
.provider-option input[type="radio"]:checked+.provider-label {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary-light) 0%, #bae6fd 100%);
    box-shadow: 0 4px 12px -2px rgba(2, 132, 199, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.provider-option input[type="radio"]:checked+.provider-label i {
    transform: scale(1.1);
}

/* Disabled state */
.provider-option.disabled {
    cursor: not-allowed;
}

.provider-option.disabled .provider-label {
    background: var(--surface-alt);
    border-color: var(--border);
    opacity: 0.5;
}

.provider-option.disabled .provider-label i {
    color: var(--text-muted);
}

.provider-option.disabled:hover .provider-label {
    transform: none;
    box-shadow: none;
    border-color: var(--border);
    background: var(--surface-alt);
}

/* Theme Transitions */
body,
.resize-section,
.modal-content,
.card,
.chat-bubble-user,
.chat-bubble-ai,
button,
input,
textarea,
select {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Dark Mode Toggle Button */
.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border: 2px solid var(--border);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: var(--shadow-xl);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle .icon {
    position: absolute;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle .sun-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.theme-toggle .moon-icon {
    opacity: 0;
    transform: rotate(180deg) scale(0);
}

[data-theme="dark"] .theme-toggle .sun-icon {
    opacity: 0;
    transform: rotate(-180deg) scale(0);
}

[data-theme="dark"] .theme-toggle .moon-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Adjust for better dark mode contrast */
[data-theme="dark"] .analysis-widget {
    background: linear-gradient(to bottom, var(--surface), var(--surface-alt));
}

[data-theme="dark"] .analysis-header {
    background: linear-gradient(to bottom, rgba(51, 65, 85, 0.8), var(--surface-alt));
}

[data-theme="dark"] .context-limit-banner {
    background: linear-gradient(135deg, #78350f 0%, #92400e 100%);
    border-color: var(--warning);
}

[data-theme="dark"] .context-limit-text strong,
[data-theme="dark"] .context-limit-text p,
[data-theme="dark"] .context-limit-text ul,
[data-theme="dark"] .context-limit-text li {
    color: var(--text-main);
}

[data-theme="dark"] .chat-input-container {
    background-color: transparent !important;
}
