/* Import IBM Plex Sans font */
 @import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap');

/* Global variables and base styles - White Theme */
:root {
    --primary-color: #E8986F; /* Coral/orange emphasis color */
    --primary-light: #f2b494;
    --primary-dark: #d67d52;
    --primary-subtle: #fef7f3;
    --gradient-1: #E8986F;
    --gradient-2: #f2b494;
    --gradient-3: #ff9a7a;
    --gradient-4: #e6a373;
    --secondary-color: #6b7280;
    --background-color: #faf9f7; /* Warm off-white background */
    --surface-color: #ffffff;
    --surface-secondary: #f8f9fa;
    --text-color: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --hover-bg: #f9fafb;
    --container-padding: 20px;
    --border-radius: 16px;
    --border-radius-sm: 12px;
    --border-radius-xs: 8px;
    --font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --sidebar-width: 280px;
    --chat-panel-width: 440px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    font-size: 14px;
    cursor: default;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
}

/* Card styles for white theme */
.glass-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.glass-button {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.glass-button:hover {
    background: var(--hover-bg);
    border-color: var(--border-color);
    box-shadow: var(--shadow-md);
}

.glass-item {
    background: var(--surface-color);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    cursor: pointer;
}

.glass-item:hover {
    background: var(--hover-bg);
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* Main layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    background: var(--background-color);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    margin: 16px;
    height: 64px;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

.header .logo {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.icon-button {
    background: transparent;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 10px;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button:hover {
    background: var(--hover-bg);
}

/* Main layout grid */
.main-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--chat-panel-width);
    gap: 16px;
    padding: 0 16px 16px;
    height: calc(100vh - 96px);
    flex-grow: 1;
    overflow: hidden;
    transition: grid-template-columns 0.3s ease;
}

.main-layout.sidebar-collapsed {
    grid-template-columns: 0fr 1fr var(--chat-panel-width); /* Fix: 0fr instead of 0px for proper collapse */
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    transition: width 0.3s ease, padding 0.3s ease;
}

.sidebar.collapsed {
    width: 0; /* This will be handled by grid-template-columns */
    padding: 0;
    border: none;
    overflow: hidden;
}

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

.sidebar-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
}

.file-explorer {
    flex-grow: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

/* Empty state for file explorer */
.file-explorer-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    min-height: 200px;
}

.file-explorer-empty .icon {
    margin-bottom: 16px;
    opacity: 0.6;
}

.file-explorer-empty p {
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0;
    line-height: 1.5;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    
    /* Card appearance */
    background: var(--surface-color);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.file-item:hover {
    background: var(--hover-bg);
    border-color: var(--border-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.file-item .file-icon {
    flex-shrink: 0;
    opacity: 0.8;
    width: 24px;
    height: 24px;
}

.file-item .file-info {
    display: flex;
    flex-direction: column;
    line-height: 1.4;
    flex-grow: 1;
}

.file-item .file-name {
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.875rem;
}

.file-item .file-meta {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.version-count {
    color: var(--text-secondary);
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
}

.file-group {
    width: 100%;
    overflow: hidden;
    margin-bottom: 6px;
}

.file-list {
    width: 100%;
    overflow: hidden;
}

/* Preview Panel */
.preview-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.preview-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
}

.preview-content {
    flex-grow: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
}

.empty-state p {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

/* Chat Panel - Gemini Style */
.chat-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    height: 100%;
    box-shadow: var(--shadow-md);
}

.messages-area {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Center content vertically when empty, but don't stretch to full height */
    justify-content: flex-start;
    align-items: stretch;
    min-height: 0; /* Allow shrinking */
    height: 100%; /* Ensure full height for scrolling */
    scrollbar-width: thin;
    scrollbar-color: rgba(74, 144, 226, 0.6) rgba(255, 255, 255, 0.1);
}

/* Webkit scrollbar styling for messages area */
.messages-area::-webkit-scrollbar {
    width: 8px;
}

.messages-area::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.messages-area::-webkit-scrollbar-thumb {
    background: rgba(74, 144, 226, 0.6);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: rgba(74, 144, 226, 0.8);
}

/* When no messages, center the content and show welcome message */
.messages-area:not(:has(.message)) {
    justify-content: center;
    align-items: center;
}

.messages-area:not(:has(.message))::before {
    content: "¿En qué puedo ayudarte?";
    font-size: 1.75rem;
    font-weight: 500;
    color: var(--text-color);
    text-align: center;
}

/* When messages exist, normal flow */
.messages-area:has(.message) {
    justify-content: flex-start;
    align-items: stretch;
}

/* Apply animated gradient only when no messages exist - Class-based approach */
.input-container.gradient-active {
    position: relative;
    background: radial-gradient(
        circle at center,
        rgba(232, 152, 111, 0.08) 0%,
        rgba(242, 180, 148, 0.06) 30%,
        rgba(232, 152, 111, 0.04) 60%,
        transparent 100%
    );
    border: 1px solid rgba(232, 152, 111, 0.2);
    box-shadow: 
        0 0 20px rgba(232, 152, 111, 0.15),
        0 4px 12px rgba(232, 152, 111, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
}



/* Document selection styles removed - now using input area tool buttons */

/* Input Area */
.input-area {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--surface-color);
}

.input-container {
    padding: 12px;
    position: relative;
    background: var(--surface-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.textarea-container {
    position: relative;
    display: flex;
    align-items: flex-end;
}

.textarea-container textarea {
    flex-grow: 1;
    padding: 12px 50px 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-color);
    resize: none;
    min-height: 24px;
    max-height: 120px;
    font-family: var(--font-family);
    font-size: 0.875rem;
    line-height: 1.5;
    outline: none;
    cursor: text;
}

.send-button {
    position: absolute;
    right: 12px;
    bottom: 12px;
    background: var(--primary-color) !important;
    color: white !important;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    z-index: 10;
    visibility: visible !important;
    opacity: 1 !important;
}

.send-button:hover {
    background: #2563eb;
    transform: scale(1.05);
}

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

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
    margin-bottom: 8px;
    padding-left: 4px;
}

.tool-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.tool-button:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.tool-button.selected {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-md);
}

.tool-button.selected:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.tool-button svg {
    width: 16px;
    height: 16px;
}

/* Voice button removed */

.char-counter {
    position: absolute;
    bottom: 4px;
    right: 16px;
    font-size: 0.7rem;
    color: var(--text-muted);
}




/* Remove old styles */
.send-button {
    display: none;
}

.disclaimer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 12px;
}

.disclaimer a {
    color: var(--text-secondary);
    text-decoration: underline;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive */
 @media (max-width: 1200px) {
    :root {
        --chat-panel-width: 380px;
        --sidebar-width: 240px;
    }
}

 @media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
        padding: 8px;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 64px;
        height: calc(100% - 64px);
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .preview-panel {
        display: none;
    }

    .chat-panel {
        width: 100%;
    }
}



/* Base message class */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    width: auto;
    min-width: 0;
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 16px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    box-sizing: border-box;
    overflow: visible;
}

.message.user {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-md);
}

.message.ai {
    align-self: flex-start;
    background-color: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.message .icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    opacity: 0.8;
}

.message .content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.message .text {
    white-space: pre-wrap; /* Preserve whitespace and line breaks */
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
}

/* Thinking indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    margin: 10px 0;
    align-self: flex-start;
}

.thinking-indicator .icon svg {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    animation: spin 1s linear infinite;
}

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

.thinking-indicator .text {
    font-style: italic;
    color: var(--text-secondary);
}

.progress-indicator {
    font-size: 10px;
    color: #777;
    margin-top: 5px;
}

/* Error and Marketing Banners */
.error-message-container,
.marketing-message-container,
.retry-message-container {
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.error-message-container {
    background-color: #ef4444;
    color: white;
}

.marketing-message-container {
    background-color: #22c55e;
    color: white;
}

.retry-message-container {
    background-color: #facc15;
    color: #1f2937;
}

.error-message-container .icon svg,
.marketing-message-container .icon svg,
.retry-message-container .icon svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.marketing-message-container .cta-button {
    background-color: white;
    color: inherit;
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    font-weight: 600;
    margin-left: auto;
    white-space: nowrap;
}

.marketing-message-container .cta-button:hover {
    opacity: 0.9;
}

/* File entry in chat - Glass card design */
.file-entry {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    min-width: 0;
    
    /* Card appearance */
    background: var(--surface-color);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.file-entry:hover {
    background: var(--hover-bg);
    border-color: var(--border-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.file-entry .file-details {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-grow: 1;
    min-width: 0; /* Allow flex item to shrink */
    overflow: hidden; /* Prevent overflow */
}

.file-entry .file-type-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    opacity: 0.8;
}

.file-entry .file-type-icon svg {
    width: 100%;
    height: 100%;
}

.file-entry .file-info {
    display: flex;
    flex-direction: column;
    line-height: 1.4;
    flex-grow: 1;
    min-width: 0; /* Allow flex item to shrink */
    overflow: hidden; /* Prevent overflow */
}

.file-entry .file-name {
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.file-entry .file-meta {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.file-entry .file-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.file-entry .preview-button,
.file-entry .download-button {
    background: var(--surface-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--border-radius-xs);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    box-shadow: var(--shadow-sm);
}

.file-entry .preview-button:hover,
.file-entry .download-button:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* PDF Viewer Styles */
.pdf-preview {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}


.pdf-js-viewer {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    margin: 0;
    overflow: hidden;
}

.pdf-controls {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    background: transparent;
    border: none;
    gap: 12px;
    z-index: 10;
    pointer-events: none;
}

.pdf-controls > * {
    pointer-events: auto;
}

.pdf-nav-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.pdf-nav-btn {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    box-shadow: var(--shadow-sm);
}

.pdf-nav-btn:hover:not(:disabled) {
    background: var(--hover-bg);
    color: var(--text-color);
    border-color: var(--border-color);
    box-shadow: var(--shadow-md);
}

.pdf-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pdf-page-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
    font-size: 14px;
    white-space: nowrap;
}

.pdf-page-input {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 4px 8px;
    border-radius: 6px;
    width: 50px;
    text-align: center;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
}

/* Remove increment/decrement arrows from number input */
.pdf-page-input::-webkit-outer-spin-button,
.pdf-page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pdf-page-input[type=number] {
    -moz-appearance: textfield;
}


.pdf-zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.pdf-zoom-btn {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    box-shadow: var(--shadow-sm);
}

.pdf-zoom-btn:hover {
    background: var(--hover-bg);
    color: var(--text-color);
    border-color: var(--border-color);
    box-shadow: var(--shadow-md);
}

.pdf-zoom-level {
    color: var(--text-color);
    font-size: 14px;
    min-width: 45px;
    text-align: center;
}

.pdf-canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--background-color);
    padding: 60px 0 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.pdf-page-canvas {
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background-color: #fff;
    display: block;
    max-width: calc(100% - 40px);
    height: auto;
    margin: 0 20px;
}

.pdf-loading,
.pdf-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.pdf-error-icon {
    margin-bottom: 12px;
    opacity: 0.7;
}

/* Progressive Responsive Panel Collapsing */
/* Priority: Chat Panel (highest) > Preview Panel > File Manager (lowest) */

/* Tablet landscape and smaller desktop - reduce panel sizes */
@media (max-width: 1200px) {
    :root {
        --chat-panel-width: 380px;
        --sidebar-width: 240px;
    }
}

/* Hide file manager first when width insufficient for all 3 panels */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr var(--chat-panel-width); /* Only preview + chat */
    }
    
    .main-layout.sidebar-collapsed {
        grid-template-columns: 1fr var(--chat-panel-width); /* Same layout when sidebar would be collapsed */
    }
    
    .sidebar {
        position: fixed;
        left: -100%;
        top: 64px;
        height: calc(100% - 64px);
        width: 240px;
        z-index: 1000;
        transition: left 0.3s ease;
        background-color: var(--surface-color);
        backdrop-filter: blur(10px);
        border-right: 1px solid var(--glass-border);
    }
    
    .sidebar.open {
        left: 0;
    }
}

/* Hide preview panel second, leaving only chat panel */
@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr; /* Only chat panel visible */
        padding: 8px;
    }

    .main-layout.sidebar-collapsed {
        grid-template-columns: 1fr; /* Ensure it remains 1fr on mobile */
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 64px;
        height: calc(100% - 64px);
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
        background-color: var(--surface-color);
        backdrop-filter: blur(10px);
        border-right: 1px solid var(--glass-border);
    }

    .sidebar.open {
        left: 0;
    }

    .preview-panel {
        display: none; /* Hide preview panel on mobile */
    }

    .chat-panel {
        width: 100%;
        border-radius: var(--border-radius); /* Ensure rounded corners on mobile */
    }
}



.user-message {
    background: var(--primary-color);
    color: white;
    margin-left: auto;
    margin-right: 0;
    max-width: 80%;
    box-shadow: var(--shadow-md);
}

.ai-message {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    max-width: 90%;
    width: auto;
    min-width: 0;
    box-shadow: var(--shadow-sm);
    overflow: visible;
}

/* Streaming response indicators */
.text.streaming {
    position: relative;
    min-height: 20px;
}

.text.streaming::after {
    content: '▋';
    color: var(--primary-color);
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.message-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
}

.text {
    line-height: 1.5;
    width: 100%;
    box-sizing: border-box;
}

/* Thinking Indicator Styles */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: thinking-pulse 1.4s infinite ease-in-out;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
.thinking-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes thinking-pulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Real-time streaming indicators */
.streaming-indicator {
    margin-top: 12px;
    padding: 8px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.thinking-dots.active {
    opacity: 1;
}

.thinking-text {
    margin-bottom: 8px;
    line-height: 1.6;
}

.thinking-text pre {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.section-text {
    padding: 8px 0;
    font-size: 0.95em;
    line-height: 1.5;
}

/* Streaming analysis section specific styles */
#streaming-analysis {
    border-left: 3px solid var(--accent-color);
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.1), rgba(80, 200, 120, 0.05));
}

#streaming-analysis .section-icon {
    animation: thinking-pulse 2s infinite ease-in-out;
}

.streaming-content {
    min-height: 40px;
    transition: all 0.3s ease;
}

/* Structured Didactic Report Styles */
.thinking-structured {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.didactic-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.3s ease;
}

.didactic-section:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(74, 144, 226, 0.3);
}

.title-section {
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.15), rgba(80, 200, 120, 0.1));
    border-color: rgba(74, 144, 226, 0.3);
}

.didactic-section .section-header {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.didactic-section .section-header h4 {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.title-highlight {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--accent-color);
    text-align: center;
    padding: 12px;
    background: rgba(74, 144, 226, 0.1);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.content-text {
    line-height: 1.6;
    color: var(--text-secondary);
    font-size: 0.95em;
}

.subsection {
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border-left: 3px solid rgba(74, 144, 226, 0.4);
}

.subsection:last-child {
    margin-bottom: 0;
}

.subsection-title {
    display: block;
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.subsection-content {
    color: var(--text-secondary);
    line-height: 1.5;
    font-size: 0.9em;
}

.nested-content {
    margin-left: 16px;
    padding-left: 16px;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
}

.nested-content .subsection {
    background: rgba(255, 255, 255, 0.01);
    border-left-color: rgba(80, 200, 120, 0.4);
}

.content-list {
    margin: 8px 0;
    padding-left: 24px;
    list-style-position: outside;
    list-style-type: disc;
    max-width: calc(100% - 24px);
    box-sizing: border-box;
    overflow: visible;
}

.content-list li {
    margin-bottom: 6px;
    color: var(--text-secondary);
    line-height: 1.4;
    font-size: 0.9em;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.content-list li::marker {
    color: var(--accent-color);
}

/* Enhanced visibility for thinking content */
.didactic-reasoning {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.reasoning-sections {
    max-height: none;
    overflow: visible;
}

.thinking-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Mediation Strategy Styles */
.mediation-strategy .mediation-strategy-text {
    margin-bottom: 20px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
}

.files-container,
.files-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Banner Styles */
.banner {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.error-banner {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.banner-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    margin-left: 12px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.banner-close:hover {
    opacity: 1;
}

/* Paywall Banner Styles */
.paywall-banner {
    width: 100%;
    background-color: var(--primary-color); /* Emphasis color */
    color: white;
    padding: 10px 20px;
    text-align: center;
    font-size: 0.9rem;
    position: relative; /* To allow z-index to work */
    z-index: 99; /* Below header, above chat */
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0; /* Prevent shrinking */
}

.paywall-banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px; /* Match main layout width */
    gap: 20px;
}

.paywall-banner-text {
    flex-grow: 1;
    text-align: left;
    line-height: 1.4;
}

.paywall-banner-button {
    background-color: white;
    color: var(--primary-color);
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.paywall-banner-button:hover {
    background-color: var(--primary-light);
    color: white;
}

/* Chat Header Styles - Enhanced with restore button */
.chat-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 6px;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    cursor: pointer;
    width: 100%;
    
    /* Card appearance */
    background: var(--surface-color);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0; /* Allow text truncation */
}

.chat-header:hover {
    background: var(--hover-bg);
    border-color: var(--border-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.chat-header .chevron {
    flex-shrink: 0;
    opacity: 0.7;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header .folder-icon {
    flex-shrink: 0;
    opacity: 0.8;
    width: 18px;
    height: 18px;
}

.chat-header .chat-title {
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.875rem;
    flex-grow: 1;
    min-width: 0;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: break-word;
    /* Allow text to wrap instead of truncating */
    white-space: normal;
}

/* Removed file-count as it's no longer displayed */

/* Active Chat Directory Styling */
.chat-directory.active .chat-header {
    background: var(--primary-subtle);
    border: 1px solid var(--primary-color);
    box-shadow: var(--shadow-md);
}

.chat-directory.active .chat-header .chat-title {
    color: var(--primary-color);
    font-weight: 600;
}

.chat-directory.active .chat-header .folder-icon {
    opacity: 1;
}

.chat-directory.active .chat-header .folder-icon svg {
    stroke: var(--primary-color);
}

.chat-directory.active .chat-header .chevron {
    opacity: 0.9;
}

.chat-directory.active .chat-header .chevron svg {
    stroke: var(--primary-color);
}

/* Expanded state for better visual hierarchy */
.chat-header.expanded {
    margin-bottom: 8px;
}

.chat-header.expanded .folder-icon {
    opacity: 0.9;
}

/* Enhanced hover state for active directories */
.chat-directory.active .chat-header:hover {
    background: var(--primary-subtle);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

/* Visual Hierarchy Improvements */
.chat-directory {
    margin-bottom: 12px;
}

.chat-directory:last-child {
    margin-bottom: 0;
}

/* Different styling for inactive/collapsed directories */
.chat-directory:not(.active) .chat-header {
    background: var(--surface-secondary);
    border: 1px solid var(--border-light);
}

.chat-directory:not(.active) .chat-header .chat-title {
    color: var(--text-secondary);
    font-weight: 400;
}

.chat-directory:not(.active) .chat-header .folder-icon,
.chat-directory:not(.active) .chat-header .chevron {
    opacity: 0.5;
}

/* File list styling within directories */
.file-list {
    padding-left: 24px;
    border-left: 2px solid var(--border-light);
    margin-left: 12px;
    margin-top: 4px;
}

.chat-directory.active .file-list {
    border-left-color: var(--primary-color);
}

/* File items with reduced visual weight - more specific selectors */
.file-list .file-item {
    background: var(--surface-secondary) !important;
    border: 1px solid var(--border-light) !important;
    padding: 10px 12px !important;
    margin-bottom: 6px !important;
}

.file-list .file-item:hover {
    background: var(--hover-bg) !important;
    border-color: var(--border-color) !important;
}

.file-list .file-item.selected {
    background: var(--primary-subtle) !important;
    border-color: var(--primary-color) !important;
}

/* Empty chat styling */
.empty-chat {
    padding: 16px 24px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Removed restore conversation button styles - functionality moved to chat header click */

/* Loading and error states */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-style: italic;
}

.error-message {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    margin: 20px;
    text-align: center;
}

/* Markdown content styling for AI responses */
.message.ai .text h1,
.message.ai .mediation-strategy-text h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 16px 0 12px 0;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.message.ai .text h2,
.message.ai .mediation-strategy-text h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 14px 0 10px 0;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.message.ai .text h3,
.message.ai .mediation-strategy-text h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color);
    margin: 12px 0 8px 0;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.message.ai .text ul,
.message.ai .mediation-strategy-text ul {
    margin: 8px 0;
    padding: 0 0 0 24px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: calc(100% - 24px);
    overflow: visible;
    list-style-position: outside;
    list-style-type: disc;
    box-sizing: border-box;
}

.message.ai .text li,
.message.ai .mediation-strategy-text li {
    margin: 4px 0;
    color: var(--text-color);
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

.message.ai .text strong,
.message.ai .mediation-strategy-text strong {
    font-weight: 600;
    color: var(--text-color);
}

.message.ai .text br,
.message.ai .mediation-strategy-text br {
    line-height: 1.5;
}

/* Add some spacing between markdown elements */
.message.ai .text h1:first-child,
.message.ai .text h2:first-child,
.message.ai .text h3:first-child,
.message.ai .mediation-strategy-text h1:first-child,
.message.ai .mediation-strategy-text h2:first-child,
.message.ai .mediation-strategy-text h3:first-child {
    margin-top: 0;
}

.message.ai .text h1:last-child,
.message.ai .text h2:last-child,
.message.ai .text h3:last-child,
.message.ai .text ul:last-child,
.message.ai .text p:last-child,
.message.ai .mediation-strategy-text h1:last-child,
.message.ai .mediation-strategy-text h2:last-child,
.message.ai .mediation-strategy-text h3:last-child,
.message.ai .mediation-strategy-text ul:last-child,
.message.ai .mediation-strategy-text p:last-child {
    margin-bottom: 0;
}

/* PDF Loading and Error States */
.pdf-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #6b7280;
    font-style: italic;
    background: rgba(59, 130, 246, 0.05);
    border: 1px dashed rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    margin: 12px 0;
    min-height: 60px;
    font-size: 14px;
}

.pdf-loading:before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

.pdf-error {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #dc2626;
    background: rgba(239, 68, 68, 0.05);
    border: 1px dashed rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    margin: 12px 0;
    min-height: 60px;
    font-size: 14px;
}

.pdf-error:before {
    content: "⚠️";
    margin-right: 8px;
    font-size: 16px;
}

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

/* Enhanced Thinking Indicator with Loading Bar */
.thinking-indicator {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin: 8px 0;
    box-shadow: var(--shadow-md);
}

.thinking-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.thinking-text {
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.95rem;
}

.thinking-progress {
    margin-top: 4px;
}

.progress-bar-container {
    margin-bottom: 0;
}

.progress-bar {
    height: 6px;
    background: var(--surface-secondary);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-light);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light), var(--primary-color));
    background-size: 200% 100%;
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
    animation: shimmer 2s infinite;
    position: relative;
}

.progress-glow {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(90deg, transparent, rgba(232, 152, 111, 0.4), transparent);
    border-radius: 5px;
    opacity: 0;
    animation: glow-pulse 3s infinite;
}

/* Animation keyframes */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

/* Enhanced message styling for thinking state */
.message.thinking {
    margin-bottom: 16px;
}

.message.thinking .message-content {
    background: transparent;
    border: none;
    padding: 0;
}

/* Landing Page Styles - White Theme */
.landing-container {
    max-width: 500px;
    width: 90%;
    margin: 20px auto;
    padding: 40px 30px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 24px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.brand-container {
    text-align: center;
    margin-bottom: 8px;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.brand-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.brand-name {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.brand-tagline {
    font-size: 1rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

.brand-text {
    text-align: left;
}

.brand-name {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.025em;
    margin-bottom: 4px;
}

.brand-tagline {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.logo-wrapper img {
    width: 48px;
    height: 48px;
}

.landing-banner {
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary-color);
    text-align: center;
    line-height: 1.2;
    margin: 16px 0;
}

.landing-textbox {
    font-size: 1.125rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
    margin-bottom: 24px;
}

.landing-benefits {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 32px 0;
}

.benefit-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-radius: var(--border-radius-sm);
    background: var(--surface-color);
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.benefit-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.benefit-item svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--primary-color);
}

.benefit-item span {
    color: var(--text-color);
    font-size: 0.95rem;
    line-height: 1.5;
}

.landing-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 32px 0;
}

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.google-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.google-btn svg {
    flex-shrink: 0;
}

.landing-secondary-cta {
    padding: 12px 24px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.landing-secondary-cta:hover {
    background: var(--hover-bg);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.cr-badge {
    text-align: center;
    padding: 16px;
    background: var(--primary-subtle);
    border: 1px solid var(--primary-color);
    border-radius: var(--border-radius-sm);
    margin-top: 24px;
}

.cr-badge span {
    color: var(--primary-color);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Landing page responsive */
@media (max-width: 768px) {
    .landing-container {
        padding: 30px 20px;
        margin: 10px;
        width: calc(100% - 20px);
        max-height: calc(100vh - 20px);
        gap: 20px;
    }
    
    .landing-banner {
        font-size: 1.5rem;
    }
    
    .brand-name {
        font-size: 1.5rem;
    }
    
    .logo-wrapper {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .brand-text {
        align-items: center;
    }
    
    .brand-text {
        text-align: center;
    }
}

/* ===== THINKING PROCESS UI STYLES ===== */

.thinking-panel {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    margin: 12px 0;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    font-size: 0.875rem;
}

.thinking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--primary-subtle);
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-light);
}

.thinking-header h3 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
}

.collapse-thinking {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.collapse-thinking:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--primary-color);
}

.thinking-content {
    padding: 12px 14px;
}

.thinking-status {
    margin-bottom: 8px;
}

.status-message {
    font-size: 0.8125rem;
    color: var(--text-color);
    margin-bottom: 6px;
    font-weight: 500;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border-radius: 4px;
    width: 0%;
    transition: width 0.5s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

.thinking-sections {
    border-top: 1px solid var(--border-light);
    padding-top: 8px;
    margin-top: 8px;
}

.report-section {
    background: var(--surface-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-xs);
    padding: 10px 12px;
    margin-bottom: 8px;
}

.report-section h4 {
    margin: 0 0 6px 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary-color);
}

.report-details p {
    margin: 4px 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.report-details strong {
    color: var(--text-color);
}

.file-generation-status {
    border-top: 1px solid var(--border-light);
    padding-top: 8px;
    margin-top: 8px;
}

.file-generation h4 {
    margin: 0 0 6px 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary-color);
}

.file-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--surface-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-xs);
    margin-bottom: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.file-item:last-child {
    margin-bottom: 0;
}

/* Action Loop Visualization Styles */
.action-loop-status {
    border-top: 1px solid var(--border-light);
    padding-top: 8px;
    margin-top: 8px;
}

.action-iteration h4 {
    margin: 0 0 6px 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary-color);
}

.iteration-info, .tool-execution, .tool-retry {
    background: var(--surface-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-xs);
    padding: 8px 10px;
    margin-bottom: 6px;
}

.iteration-message, .tool-message, .retry-message {
    font-size: 0.75rem;
    color: var(--text-color);
    font-weight: 500;
    margin-bottom: 2px;
    line-height: 1.4;
}

.tool-name, .retry-tool {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    font-style: italic;
}

.tool-retry {
    border-color: var(--warning-color);
    background: rgba(255, 193, 7, 0.1);
}

.retry-message {
    color: var(--warning-color);
    font-weight: 600;
}

/* Responsive thinking panel */
@media (max-width: 768px) {
    .thinking-panel {
        margin: 8px 0;
    }
    
    .thinking-header {
        padding: 8px 12px;
    }
    
    .thinking-header h3 {
        font-size: 0.8125rem;
    }
    
    .thinking-content {
        padding: 10px 12px;
    }
    
    .report-section {
        padding: 8px 10px;
    }
    
    .status-message {
        font-size: 0.75rem;
    }
}

/* Animation for smooth appearance */
.thinking-panel {
    animation: slideInFromTop 0.3s ease-out;
}

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

/* =============================================================================
   UNIFIED THINKING PANEL - COMPLETE REPLACEMENT
   ============================================================================= */

.unified-thinking-panel {
    background: var(--surface-primary);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-md);
    margin: 16px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    position: relative;
    animation: slideInFromTop 0.3s ease-out;
}

.unified-thinking-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
}

.thinking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(var(--primary-color-rgb), 0.05);
    border-bottom: 1px solid var(--border-light);
}

.thinking-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.thinking-icon {
    font-size: 20px;
}

.thinking-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.collapse-thinking {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    padding: 4px 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.collapse-thinking:hover {
    background: var(--surface-secondary);
    border-color: var(--primary-color);
}

.collapse-icon {
    font-size: 14px;
    font-weight: bold;
}

.thinking-content {
    padding: 0;
}

.thinking-status {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    background: rgba(var(--accent-color-rgb), 0.03);
}

.status-message {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Reasoning Sections */
.didactic-reasoning,
.action-reasoning,
.file-reasoning {
    border-bottom: 1px solid var(--border-light);
}

.reasoning-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(var(--surface-secondary), 0.5);
    border-bottom: 1px solid var(--border-light);
}

.reasoning-icon {
    font-size: 18px;
}

.reasoning-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
}

/* Didactic Report Structured Sections */
.reasoning-sections {
    padding: 0;
}

.reasoning-section {
    border-bottom: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.reasoning-section:last-child {
    border-bottom: none;
}

.reasoning-section.reasoning-level-0 {
    background: rgba(var(--primary-color-rgb), 0.02);
}

.reasoning-section.reasoning-level-1 {
    background: rgba(var(--primary-color-rgb), 0.04);
    margin-left: 8px;
}

.reasoning-section.reasoning-level-2 {
    background: rgba(var(--primary-color-rgb), 0.06);
    margin-left: 16px;
}

.reasoning-section.reasoning-level-3 {
    background: rgba(var(--primary-color-rgb), 0.08);
    margin-left: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.section-header:hover {
    background: rgba(var(--primary-color-rgb), 0.05);
}

.section-icon {
    font-size: 16px;
    min-width: 20px;
}

.section-info {
    flex: 1;
}

.section-info h5 {
    margin: 0 0 2px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
}

.section-description {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

.toggle-section {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--border-radius-xs);
    transition: all 0.2s ease;
}

.toggle-section:hover {
    background: var(--surface-secondary);
    color: var(--primary-color);
}

.toggle-icon {
    font-size: 12px;
    font-weight: bold;
}

.section-content {
    padding: 0 16px 16px 48px;
    background: rgba(var(--surface-secondary), 0.3);
}

.content-item {
    margin-bottom: 12px;
}

.content-item:last-child {
    margin-bottom: 0;
}

.content-item strong {
    color: var(--text-color);
    font-weight: 600;
}

.content-item span {
    color: var(--text-secondary);
    margin-left: 8px;
}

.content-list {
    margin: 8px 0 0 16px;
    padding: 0;
}

.content-list li {
    margin: 4px 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.content-raw {
    background: var(--surface-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-xs);
    padding: 12px;
    font-family: monospace;
    font-size: 12px;
    color: var(--text-secondary);
    overflow-x: auto;
}

/* Action Loop Decision Items */
.action-decisions {
    padding: 8px 0;
    max-height: 300px;
    overflow-y: auto;
}

.action-decision {
    margin: 0 16px 8px 16px;
    background: var(--surface-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
}

.action-decision:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.decision-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.decision-icon {
    font-size: 16px;
    min-width: 20px;
}

.decision-info {
    flex: 1;
}

.decision-message {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 2px;
}

.decision-timestamp {
    font-size: 11px;
    color: var(--text-secondary);
}

.decision-status {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: var(--border-radius-xs);
    font-weight: bold;
}

.decision-status.executing {
    color: var(--primary-color);
    background: rgba(var(--primary-color-rgb), 0.1);
}

.decision-status.retrying {
    color: var(--warning-color);
    background: rgba(255, 193, 7, 0.1);
    animation: pulse 1s infinite;
}

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

/* File Generation Details */
.file-generation-details {
    padding: 8px 0;
}

/* Responsive unified thinking panel */
@media (max-width: 768px) {
    .unified-thinking-panel {
        margin: 12px 0;
    }
    
    .thinking-header {
        padding: 12px 16px;
    }
    
    .thinking-title h3 {
        font-size: 14px;
    }
    
    .reasoning-header {
        padding: 12px 16px;
    }
    
    .reasoning-header h4 {
        font-size: 14px;
    }
    
    .section-content {
        padding: 0 12px 12px 36px;
    }
    
    .reasoning-section.reasoning-level-1 {
        margin-left: 4px;
    }
    
    .reasoning-section.reasoning-level-2 {
        margin-left: 8px;
    }
    
    .reasoning-section.reasoning-level-3 {
        margin-left: 12px;
    }
}

/* Desktop specific styles */
@media (min-width: 769px) {
    .unified-thinking-panel {
        max-width: 100%;
        margin: 20px 0;
    }
    
    .action-decisions {
        max-height: 400px;
    }
}

/* ===== LOADING STATES FOR FILE EXPLORER ===== */

.loading-state {
    padding: 20px;
    border-radius: var(--border-radius-sm);
    background: var(--surface-color);
    border: 1px solid var(--border-light);
}

.loading-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-light);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

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

.loading-text h3 {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
}

.loading-status {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Skeleton Loading Animation */
.loading-skeleton {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-chat {
    background: var(--surface-secondary);
    border-radius: var(--border-radius-xs);
    padding: 12px;
    border: 1px solid var(--border-light);
}

.skeleton-header {
    height: 20px;
    background: var(--border-color);
    border-radius: 4px;
    margin-bottom: 8px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-files {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 16px;
}

.skeleton-file {
    height: 16px;
    background: var(--border-color);
    border-radius: 4px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-file:nth-child(1) {
    width: 85%;
    animation-delay: 0.1s;
}

.skeleton-file:nth-child(2) {
    width: 70%;
    animation-delay: 0.2s;
}

@keyframes skeleton-pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
    100% {
        opacity: 1;
    }
}

/* Progress Loading for Individual Conversations */
.chat-directory.loading {
    opacity: 0.7;
}

.chat-directory.loading .chat-header::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Mobile responsive loading */
@media (max-width: 768px) {
    .loading-state {
        padding: 16px;
    }
    
    .loading-header {
        gap: 12px;
    }
    
    .loading-spinner {
        width: 28px;
        height: 28px;
    }
    
    .skeleton-chat {
        padding: 10px;
    }
}

/* Streaming partial content styles */
.streaming-partial-content {
    padding: 16px;
    background: rgba(var(--primary-color-rgb), 0.05);
    border-radius: 8px;
    border: 1px solid rgba(var(--accent-color-rgb), 0.2);
    text-align: center;
    animation: pulse 2s infinite;
}

.streaming-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--accent-color);
}

.partial-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

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

/* Streaming progress bar styles */
.streaming-progress {
    margin: 8px 0;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(var(--border-light-rgb), 0.3);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--primary-color));
    border-radius: 3px;
    transition: width 0.3s ease;
    animation: progress-shimmer 2s infinite;
}

@keyframes progress-shimmer {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

/* JSON debug information styles */
.json-debug {
    margin-top: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.json-debug small {
    color: var(--text-secondary);
    opacity: 0.8;
}