/* ============================================
   Layout - App Container & Main Structure
   ============================================ */

/* Lucide icon size utilities */
.icon-sm {
    width: 14px;
    height: 14px;
    display: inline-block;
    vertical-align: middle;
}

.icon-md {
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: middle;
}

.icon-success {
    color: #22c55e;
}

.icon-error {
    color: #ef4444;
}

.icon-warning {
    color: #eab308;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--color-bg);
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    margin-left: 60px;
    /* Sidebar is 60px collapsed, main content shifts right */
    /* padding-top removed to align header with sidebar logo */
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 100, 100, 0.4) transparent;
    /* Fix for homepage centering: ensure full height */
    min-height: 100vh;
}

/* The scrollbar is now on the body, so these rules are no longer needed for .main-content */
/*
.main-content:hover {
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.main-content::-webkit-scrollbar {
    width: 8px;
}

.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
}

.main-content:hover::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}
*/

/* ============================================
   Welcome Screen
   ============================================ */

.welcome-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    background: var(--color-bg);
    z-index: 1;
}

.welcome-container {
    max-width: 900px;
    width: 100%;
    text-align: center;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
}

.welcome-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.welcome-title {
    font-size: var(--font-size-2xl);
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: var(--spacing-xl);
}

/* ============================================
   Input Container (Claude-style)
   ============================================ */

/* Input Container - Full Width in Center Window */
.input-container {
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 4px;
    padding: 0 var(--spacing-lg);
    box-sizing: border-box;
}

/* Remove media query for fixed width to allow fluid 75% */


/* Input wrapper styles moved to line 252 to consolidate */

.message-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border: none;
    outline: none;
    resize: none;
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--color-text);
    background: transparent;
    min-height: 24px;
    max-height: 200px;
}

.message-input::placeholder {
    color: var(--color-text-muted);
}

/* Input controls styles moved to components.css for consistency */

/* Select controls */
.control-select {
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    background: var(--color-surface);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.control-select:hover {
    border-color: var(--color-text-muted);
}

.control-select:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* Toggle buttons */
.control-toggle {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    background: var(--color-surface);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.control-toggle:hover {
    border-color: var(--color-text-muted);
    background: var(--color-surface-hover);
}

.control-toggle.active {
    background: var(--color-accent-light);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.toggle-icon {
    font-size: 14px;
}

.toggle-label {
    font-size: var(--font-size-xs);
}

/* Expand toggle button */
.expand-toggle {
    position: absolute;
    top: var(--spacing-sm);
    left: var(--spacing-sm);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    background: transparent;
    transition: all var(--transition-fast);
    z-index: 1;
}

.expand-toggle:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.expand-toggle.expanded svg {
    transform: rotate(45deg);
}

.input-wrapper {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    padding-left: 44px;
    /* Room for expand toggle */
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-md);
}

/* Expanded state */
.input-container.expanded .input-wrapper {
    padding-bottom: var(--spacing-lg);
}

.input-container.expanded .message-input {
    min-height: 150px;
}

/* send-btn styles moved to components.css */

/* ============================================
   Quick Actions
   ============================================ */

.quick-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
    flex-wrap: wrap;
}

.quick-action-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    background: var(--color-surface);
    transition: all var(--transition-fast);
}

.quick-action-btn:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-text-muted);
    color: var(--color-text);
}

/* ============================================
   Chat Area
   ============================================ */

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages {
    flex: 1;
    overflow-y: auto !important;
    /* FIX: Changed from 'visible' to 'auto' to enable scrolling */
    overflow-x: hidden;
    padding: var(--spacing-lg);
    scroll-behavior: smooth;
}

/* ============================================
   Chat Input Area
   ============================================ */

.chat-input-container {
    padding: 0 var(--spacing-lg);
    background: var(--color-bg);
    border-top: none;
    width: 100%;
    display: flex;
    justify-content: center;
    /* Center the input-container */
}

/* ============================================
   List View (Claude.ai style)
   ============================================ */

.list-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    overflow: hidden;
    padding: 0 var(--spacing-xl);
    z-index: 1;
}

.list-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-xl) 0 var(--spacing-lg);
}

.list-view-title {
    font-size: 28px;
    font-weight: 500;
    color: var(--color-text);
}

.list-view-new-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-text);
    color: white;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.list-view-new-btn:hover {
    opacity: 0.9;
}

/* Search Box */
.list-view-search {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-md);
}

.list-view-search svg {
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.list-view-search input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: var(--font-size-base);
    color: var(--color-text);
    outline: none;
}

.list-view-search input::placeholder {
    color: var(--color-text-muted);
}

/* Info Bar */
.list-view-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-md);
}

.list-view-sort {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-left: auto;
}

.list-view-sort select {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-sm);
    background: var(--color-surface);
}

/* List Content */
.list-view-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.list-view-item-meta {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.list-view-item-meta .highlight {
    color: var(--color-accent);
}

/* Thread Item Row (with checkbox and menu) */
.list-view-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
}

.list-view-item:hover {
    background: var(--color-surface-hover);
}

.list-view-item-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.list-view-item:hover .list-view-item-checkbox,
.list-view-item.selected .list-view-item-checkbox {
    opacity: 1;
}

.list-view-item-checkbox.checked {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.list-view-item-checkbox.checked::after {
    content: "✓";
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.list-view-item.selected {
    background: rgba(191, 134, 95, 0.1);
}

.list-view-item-content {
    flex: 1;
    min-width: 0;
}

.list-view-item-title {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 4px;
}

.list-view-item-menu {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    background: transparent;
    opacity: 0;
    transition: opacity var(--transition-fast);
    position: relative;
}

.list-view-item:hover .list-view-item-menu {
    opacity: 1;
}

.list-view-item-menu:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

/* Arrow icon at end of row */
.list-view-item-arrow {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    flex-shrink: 0;
    cursor: pointer;
}

.list-view-item-arrow:hover {
    color: var(--color-text);
}

/* Thread Menu Dropdown */
.thread-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    white-space: nowrap;
    z-index: 1000;
    padding: var(--spacing-xs) 0;
}

.thread-menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.thread-menu-item:hover {
    background: var(--color-surface-hover);
}

.thread-menu-item.danger {
    color: #dc2626;
}

.thread-menu-divider {
    height: 1px;
    background: var(--color-border-light);
    margin: var(--spacing-xs) 0;
}

/* BUG FIX 5: Thread menu submenu styles */
.thread-menu-item.has-submenu {
    position: relative;
}

.thread-menu-item.has-submenu .submenu-indicator {
    margin-left: auto;
    color: var(--color-text-muted);
    font-size: 12px;
}

.thread-menu-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: -5px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    white-space: nowrap;
    z-index: 1001;
    padding: var(--spacing-xs) 0;
    margin-left: 4px;
}

.thread-menu-submenu.active {
    display: block;
}

.thread-menu-submenu .submenu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.thread-menu-submenu .submenu-item:hover {
    background: var(--color-surface-hover);
}

.thread-menu-submenu .submenu-item.disabled {
    color: var(--color-text-muted);
    cursor: not-allowed;
}

.thread-menu-submenu .submenu-item.disabled:hover {
    background: transparent;
}

/* Selection Action Bar */
.selection-action-bar {
    display: none;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0;
    margin-bottom: var(--spacing-sm);
}

.selection-action-bar.active {
    display: flex;
}

.selection-count {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.selection-count .count-badge {
    background: var(--color-accent);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.selection-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.selection-action-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    background: transparent;
}

.selection-action-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.selection-clear-btn {
    margin-left: auto;
    color: var(--color-text-muted);
    font-size: 20px;
    background: transparent;
    padding: var(--spacing-xs);
}

/* Move to Project Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border-light);
}

.modal-title {
    font-size: var(--font-size-lg);
    font-weight: 500;
    color: var(--color-text);
}

.modal-close-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    background: transparent;
    font-size: 18px;
}

.modal-close-btn:hover {
    background: var(--color-surface-hover);
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    max-height: 60vh;
}

.modal-subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-md);
}

.project-search-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-md);
}

.project-list-modal {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.project-list-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.project-list-item:hover {
    background: var(--color-surface-hover);
}

.project-list-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
}

.project-list-item-name {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.project-list-item-badge {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    padding: 2px 6px;
    background: var(--color-surface-hover);
    border-radius: var(--radius-sm);
}

/* Delete Confirmation Modal */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--color-border-light);
}

.btn-cancel {
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.btn-cancel:hover {
    background: var(--color-surface-hover);
}

.btn-danger {
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    background: #dc2626;
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-primary {
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    background: var(--color-accent);
    color: white;
    border: none;
}

.btn-primary:hover {
    background: #a67c5b;
}

/* Modal Variants */
.modal-sm {
    max-width: 400px;
}

/* Modal Form Elements */
.modal-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    background: var(--color-surface);
    color: var(--color-text);
}

.modal-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.modal-textarea {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    background: var(--color-surface);
    color: var(--color-text);
    resize: vertical;
    min-height: 100px;
}

.modal-textarea:focus {
    outline: none;
    border-color: var(--color-accent);
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: var(--spacing-xs);
}

.char-counter {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-align: right;
    margin-top: var(--spacing-xs);
}

/* Responsive Project Grid (Claude.ai style) */
.project-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    width: 100%;
    box-sizing: border-box;
}

/* Narrow screen: 1 column */
@media (max-width: 700px) {
    .project-cards {
        grid-template-columns: 1fr;
    }

    .project-card {
        width: 95%;
        margin: 0 auto;
    }
}

/* Wide screen: 2 columns */
@media (min-width: 701px) {
    .project-card {
        /* Cards fill their grid cell */
        width: 100%;
    }
}

.project-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    position: relative;
    min-height: 120px;
}

.project-card:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border);
}

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-sm);
}

.project-card-title {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--color-text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-card-menu {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    background: transparent;
    opacity: 0;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
}

.project-card:hover .project-card-menu {
    opacity: 1;
}

.project-card-menu:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--color-text);
}

.project-card-description {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-md);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-card-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Project Menu Dropdown */
.project-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 1000;
    padding: var(--spacing-xs) 0;
}

.project-menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.project-menu-item:hover {
    background: var(--color-surface-hover);
}

.project-menu-item.danger {
    color: #dc2626;
}

/* Pagination */
.list-view-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-lg) 0;
    border-top: 1px solid var(--color-border-light);
}

.page-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    background: transparent;
    transition: all var(--transition-fast);
}

.page-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-numbers {
    display: flex;
    gap: var(--spacing-xs);
}

.page-num {
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.page-num:hover {
    background: var(--color-surface-hover);
}

.page-num.active {
    background: var(--color-text);
    color: white;
}

/* ============================================
   API Status Panel
   ============================================ */

.api-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.api-status-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.status-label {
    color: var(--color-text-secondary);
}

.status-value {
    color: var(--color-text);
}

.api-status-divider {
    width: 1px;
    height: 16px;
    background: var(--color-border);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-muted);
}

.status-indicator.online {
    background: #22c55e;
}

.status-indicator.offline {
    background: #ef4444;
}

/* ============================================
   Project View (Claude.ai style)
   ============================================ */

.project-view {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    overflow: hidden;
    z-index: 1;
}

.project-view-header {
    padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-sm);
}

.project-back-btn {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    background: transparent;
    margin-bottom: var(--spacing-sm);
}

.project-back-btn:hover {
    color: var(--color-text);
}

.project-title-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.project-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--color-text);
}

.project-menu-btn,
.project-star-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    background: transparent;
    font-size: 18px;
}

.project-menu-btn:hover,
.project-star-btn:hover {
    background: var(--color-surface-hover);
}

.project-star-btn.starred {
    color: #f59e0b;
}

.project-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.project-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-xl) var(--spacing-lg);
    padding-top: 180px;
    /* Space from header - main-content already has 48px */
    overflow-y: auto;
    overflow-x: hidden;
}

.project-chat-input {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    /* Default: 40% of viewport width */
    width: 40vw;
    min-width: 320px;
    max-width: 800px;
}

.project-chat-input textarea {
    width: 100%;
    border: none;
    background: transparent;
    resize: none;
    font-size: var(--font-size-base);
    color: var(--color-text);
    outline: none;
    min-height: 32px;
    line-height: 1.5;
}

.project-chat-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.project-sidebar {
    /* Width is set in responsive section below */
    border-left: 1px solid var(--color-border-light);
    padding: var(--spacing-md);
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--color-bg);
    font-size: var(--font-size-sm);
}

.project-instructions,
.project-files {
    margin-bottom: var(--spacing-lg);
}

.panel-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-sm);
}

.edit-btn,
.add-file-btn {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    background: transparent;
    font-size: 14px;
}

.edit-btn:hover,
.add-file-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.instructions-content {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
}

.files-usage {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-sm);
}

/* Note: .files-list styles are in the responsive section below */

.file-item {
    padding: var(--spacing-sm);
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-light);
    font-size: var(--font-size-xs);
    text-align: center;
    cursor: pointer;
}

.file-item:hover {
    border-color: var(--color-border);
}

/* File Upload Zone */
.file-upload-zone {
    padding: var(--spacing-xl);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: var(--spacing-md);
}

.file-upload-zone:hover,
.file-upload-zone.drag-over {
    border-color: var(--color-accent);
    background: rgba(239, 108, 77, 0.05);
}

.file-upload-zone .upload-icon {
    font-size: 32px;
    margin-bottom: var(--spacing-sm);
}

.file-upload-zone p {
    color: var(--color-text-secondary);
    margin: 0;
}

.uploaded-files-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.uploaded-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm);
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-light);
}

.uploaded-file-item .file-name {
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.uploaded-file-item .file-remove {
    width: 20px;
    height: 20px;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
}

/* ============================================
   Responsive Layout - Claude.ai style breakpoints
   ============================================ */

/* 
   Breakpoints (based on typical 1920px monitor):
   - >= 1250px (~65%): Chat 40vw, Panel 20vw - WIDE
   - 860px-1249px (~45-65%): Chat 40% centered, Panel hidden - MEDIUM  
   - < 860px (~<45%): Chat 90%, Panel hidden - NARROW
*/

/* Default: sidebar base styles for wide screens (>= 1250px) */
.project-sidebar {
    width: 20vw;
    min-width: 220px;
    max-width: 350px;
    flex-shrink: 0;
    margin-right: 60px;
    /* Match left sidebar icon width */
}

.files-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    overflow: hidden;
}

/* ========== WIDE: >= 1250px ========== */
/* Show panel 20vw, chatbox 40vw */
@media (min-width: 1250px) {
    .project-sidebar {
        display: flex;
        flex-direction: column;
        width: 20vw;
        min-width: 220px;
        max-width: 380px;
    }

    .project-chat-input {
        width: 40vw;
        min-width: 400px;
        max-width: 800px;
    }

    .files-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========== MEDIUM: 860px - 1249px ========== */
/* Hide panel, chatbox 40% centered */
@media (min-width: 860px) and (max-width: 1249px) {
    .project-sidebar {
        display: flex;
        flex-direction: column;
        width: 200px;
        min-width: 180px;
        max-width: 220px;
    }

    .project-chat-input {
        width: 45%;
        min-width: 350px;
        max-width: 600px;
    }

    .project-main {
        justify-content: flex-start;
    }
}

/* ========== NARROW: < 860px ========== */
/* Show panel with smaller width, chatbox adjusted */
@media (max-width: 859px) {
    .project-sidebar {
        display: flex;
        flex-direction: column;
        width: 160px;
        min-width: 140px;
        max-width: 180px;
    }

    .project-chat-input {
        width: 70%;
        min-width: 280px;
        max-width: none;
    }

    .project-main {
        padding: var(--spacing-md);
    }
}

/* File Card Styles (Claude.ai style) */
.file-card {
    position: relative;
    padding: var(--spacing-sm);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Square aspect ratio */
    aspect-ratio: 1 / 1;
    overflow: hidden;
    min-width: 0;
    /* Allow shrinking */
}

.file-card:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border);
}

.file-card.selected {
    border-color: var(--color-accent);
    background: rgba(239, 108, 77, 0.05);
}

.file-card-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
    word-break: break-word;
}

.file-card-lines {
    font-size: 10px;
    color: var(--color-text-muted);
    margin-top: auto;
}

.file-card-type {
    font-size: 10px;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    padding: 2px 6px;
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    width: fit-content;
    margin-top: 2px;
}

/* File card checkbox - at top-left like Claude.ai */
.file-card-checkbox {
    position: absolute;
    top: var(--spacing-xs);
    left: var(--spacing-xs);
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-bg);
    opacity: 0;
    transition: opacity var(--transition-fast);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-card:hover .file-card-checkbox,
.file-card.selected .file-card-checkbox {
    opacity: 1;
}

.file-card.selected .file-card-checkbox {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
}

.file-card.selected .file-card-checkbox::after {
    content: '✓';
    font-size: 12px;
    color: white;
}

/* File card delete button - shown on hover */
.file-card-delete {
    position: absolute;
    bottom: var(--spacing-xs);
    right: var(--spacing-xs);
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: transparent;
    color: var(--color-text-muted);
    opacity: 0;
    transition: opacity var(--transition-fast);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.file-card:hover .file-card-delete {
    opacity: 1;
}

.file-card-delete:hover {
    background: rgba(220, 53, 53, 0.1);
    color: #dc3545;
}

/* Files Selection Action Bar */
.files-selection-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-sm);
    border: 1px solid var(--color-border-light);
}

.files-selection-bar.active {
    display: flex;
}

.files-selection-count {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

.files-selection-count .minus-icon {
    width: 18px;
    height: 18px;
    background: var(--color-accent);
    color: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

.files-selection-actions {
    display: flex;
    gap: var(--spacing-xs);
}

.files-selection-actions button {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.files-selection-actions button:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.files-selection-actions .delete-btn:hover {
    background: rgba(220, 53, 53, 0.1);
    color: #dc3545;
}

/* Project Thread List */
.project-threads {
    flex: 1;
    overflow-y: auto;
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
    align-self: stretch;
    /* Override parent's align-items: center */
    min-height: 0;
    /* Allow flex item to shrink properly */
}

.project-thread-item {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--color-border-light);
    cursor: pointer;
}

.project-thread-item:hover {
    background: var(--color-surface-hover);
}

.project-thread-title {
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 4px;
}

.project-thread-meta {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* Thread Context Menu */
.thread-menu {
    position: absolute;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 1000;
}

.thread-menu-item {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.thread-menu-item:hover {
    background: var(--color-surface-hover);
}

.thread-menu-item.danger {
    color: #ef4444;
}

.thread-menu-divider {
    height: 1px;
    background: var(--color-border-light);
    margin: var(--spacing-xs) 0;
}

/* Project Cards (for project list) */
.project-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
}

.project-card {
    padding: var(--spacing-lg);
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.project-card:hover {
    border-color: var(--color-border);
    box-shadow: var(--shadow-sm);
}

.project-card-title {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--color-text);
}

.project-card-meta {
    font-size: var(--font-size-sm);
    color: var(--color-accent);
    margin-top: auto;
}

/* ============================================
   Fixed Center Width Container
   ============================================ */

.center-container {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Apply fixed width to list views */
.list-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    overflow: hidden;
}

.list-view-inner {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--spacing-xl);
}

/* ============================================
   Create Project View (Full Page)
   ============================================ */

.create-project-view {
    position: fixed;
    inset: 0;
    background: var(--color-bg);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
}

.create-project-container {
    max-width: 560px;
    width: 100%;
}

.create-project-title {
    font-size: 32px;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: var(--spacing-xl);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xl);
}

/* ============================================
   Project Thread View (with Breadcrumb)
   ============================================ */

.project-thread-view {
    position: fixed;
    inset: 0;
    left: var(--sidebar-collapsed-width);
    background: var(--color-bg);
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.project-thread-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border-light);
}

.project-thread-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-sm);
}

.breadcrumb-project {
    color: var(--color-accent);
    cursor: pointer;
}

.breadcrumb-project:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--color-text-muted);
}

.breadcrumb-thread {
    color: var(--color-text);
    font-weight: 500;
}

.breadcrumb-dropdown {
    color: var(--color-text-muted);
    background: transparent;
    padding: var(--spacing-xs);
    font-size: 10px;
}

.share-btn {
    padding: var(--spacing-xs) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: var(--font-size-sm);
}

.share-btn:hover {
    background: var(--color-surface-hover);
}

.project-thread-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.project-thread-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

.project-thread-input {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-bg);
}

.chat-input-box {
    max-width: 800px;
    margin: 0 auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
}

.chat-input-box textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border: none;
    background: transparent;
    font-size: var(--font-size-base);
    color: var(--color-text);
    resize: none;
    outline: none;
    min-height: 24px;
}

.chat-input-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.chat-input-controls .attach-btn,
.chat-input-controls .history-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 14px;
}

.chat-input-controls .attach-btn:hover,
.chat-input-controls .history-btn:hover {
    background: var(--color-surface-hover);
}

.chat-input-controls .model-select {
    margin-left: auto;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

/* send-btn styles moved to components.css */

/* ============================================
   Research Sidebar Popup — thread-item styled to match sidebar-list-item
   Scoped to #researchThreadList (ID+class = higher specificity than research.html
   inline .thread-item) so these rules win in all page contexts.
   ============================================ */

#researchThreadList .thread-item {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #1A1A1A;
    background: transparent;
    text-decoration: none;
    overflow: hidden;
    transition: background var(--transition-fast);
    gap: 8px;
    height: 28px;
    white-space: nowrap;
    /* Reset card-style overrides from research.html inline .thread-item */
    border: none !important;
    margin-bottom: 0 !important;
    box-shadow: none !important;
}

#researchThreadList .thread-item:hover {
    background: var(--color-surface-hover) !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

#researchThreadList .thread-item.active {
    background: var(--color-accent-light) !important;
    color: var(--color-accent) !important;
}

#researchThreadList .thread-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 300;
    font-size: 13px !important;
    font-family: 'Inter', sans-serif !important;
    color: #1A1A1A !important;
}

#researchThreadList .thread-time {
    font-size: 11px !important;
    font-family: 'Inter', sans-serif !important;
    color: #999999 !important;
    white-space: nowrap;
    flex-shrink: 0;
}

#researchThreadList .thread-status-dot {
    flex-shrink: 0;
    font-size: 10px;
    line-height: 1;
    width: 12px;
    text-align: center;
}