:root {
    --bg-body: #f4f7f6;
    --bg-sidebar: #2c3e50;
    --text-sidebar: #ecf0f1;
    --primary: #3498db;
    --accent: #e74c3c;
    --bg-card: #ffffff;
    --text-main: #2c3e50;
    --text-meta: #7f8c8d;
    --border: #bdc3c7;
    --success: #2ecc71;
    --warning: #f1c40f;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    display: flex;
    height: 100vh;
    background-color: var(--bg-body);
    color: var(--text-main);
}

/* Mobile Header */
.mobile-header {
    display: none;
    background: var(--bg-sidebar);
    color: white;
    padding: 15px;
    align-items: center;
    gap: 15px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.menu-toggle {
    font-size: 24px;
    cursor: pointer;
}

.brand-mobile {
    font-size: 20px;
    font-weight: bold;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
    transition: width 0.3s, transform 0.3s;
    height: 100vh;
    overflow-y: auto;
    z-index: 1001;
    /* Above overlay */
}

/* Collapsed State (Desktop) */
.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .brand {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar.collapsed .sidebar-toggle-btn {
    transform: rotate(180deg);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    min-height: 30px;
}

.brand {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
    white-space: nowrap;
}

.sidebar-toggle-btn {
    cursor: pointer;
    color: var(--text-meta);
    font-size: 18px;
    transition: transform 0.3s;
}

.sidebar-toggle-btn:hover {
    color: white;
}

.nav-item {
    padding: 12px 15px;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 5px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
}

/* Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.sidebar-overlay.active {
    display: block;
}

/* Main Content */
.main {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    transition: padding 0.3s;
    width: 100%;
    /* Ensure fits */
}

.hidden {
    display: none;
}

h2 {
    margin-top: 0;
}

/* ... existing component styles ... */

/* ... (skipping unchanged parts) ... */

/* Responsive Media Queries */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -250px;
        top: 0;
        bottom: 0;
        width: 250px;
        /* height set by bottom:0 */
    }

    .sidebar.mobile-open {
        transform: translateX(250px);
    }

    .sidebar.collapsed {
        width: 250px;
        /* Disable collapse logic on mobile */
    }

    /* Hide desktop toggle in sidebar on mobile usually, or keep it */
    .sidebar-toggle-btn {
        display: none;
    }

    .main {
        padding: 80px 20px 20px 20px;
        /* Top padding for header */
    }

    /* Adjust Grid Layouts */
    .indexer-grid {
        grid-template-columns: 1fr;
    }

    .search-box {
        flex-direction: column;
    }

    .search-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .filters {
        flex-wrap: wrap;
    }

    .result-meta {
        flex-wrap: wrap;
    }

    /* Logs viewer height */
    .log-viewer {
        height: 400px;
    }

    .card {
        padding: 15px;
    }
}

.hidden {
    display: none;
}

h2 {
    margin-top: 0;
}

/* Components */
.btn {
    padding: 8px 20px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.btn:hover {
    opacity: 0.9;
}

.btn-secondary {
    background-color: #95a5a6;
}

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

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

/* Search Section */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#search-input {
    flex: 1;
    padding: 12px 15px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
}

#search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.search-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

.filters {
    display: flex;
    gap: 10px;
}

.filter-chip {
    padding: 6px 12px;
    background: #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.filter-chip.active {
    background: var(--primary);
    color: white;
}

.saved-filters-select {
    padding: 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.results-header {
    margin-bottom: 15px;
    font-size: 14px;
    color: var(--text-meta);
}

/* Result Cards */
.result-card {
    background: var(--bg-card);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.result-title {
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 5px;
}

.result-path {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-meta);
    margin-bottom: 5px;
    background: #f0f0f0;
    padding: 2px 5px;
    border-radius: 3px;
    display: inline-block;
}

.result-snippet {
    background: #f9f9f9;
    padding: 8px;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.5;
}

.result-text {
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 8px;
    white-space: pre-wrap;
}

.result-meta {
    font-size: 12px;
    color: var(--text-meta);
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    text-transform: uppercase;
    font-weight: bold;
}

.badge-note {
    background: #e1f5fe;
    color: #0288d1;
}

.badge-file {
    background: #e8f5e9;
    color: #388e3c;
}

.result-summary {
    font-size: 14px;
    color: #555;
    background: #fff8e1;
    /* very light yellow for summary */
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 8px;
    border-left: 3px solid #ffca28;
}

.result-keywords {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.keyword-tag {
    font-size: 11px;
    background: #f0f4c3;
    color: #827717;
    padding: 2px 6px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.keyword-tag:hover {
    background: #dce775;
}

.btn-delete-note {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 16px;
    padding: 0 5px;
}

.btn-delete-note:hover {
    color: #c0392b;
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}


/* Ideas Section */
.idea-form {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.form-group {
    margin-bottom: 15px;
}

#idea-text {
    width: 100%;
    height: 150px;
    padding: 15px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    resize: vertical;
}

select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
}


/* Indexer Section */
.indexer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.card h3 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
}

.status-label {
    color: var(--text-meta);
}

.status-value {
    font-weight: bold;
}

.config-editor textarea {
    width: 100%;
    height: 300px;
    font-family: monospace;
    font-size: 12px;
    padding: 10px;
    border: 1px solid var(--border);
}

.recent-jobs-list {
    max-height: 300px;
    overflow-y: auto;
}

.job-item {
    font-size: 12px;
    padding: 8px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
}

.job-status-success {
    color: var(--success);
}

.job-status-failed {
    color: var(--accent);
}

/* Logs Section */
.log-controls {
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
}

.log-viewer {
    background: #1e1e1e;
    color: #aeaeae;
    padding: 15px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    height: 600px;
    overflow: auto;
    white-space: pre-wrap;
}

/* Search Tabs */
.search-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.search-tab {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    color: var(--text-meta);
}

.search-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.search-mode-panel.hidden {
    display: none;
}

/* Image Upload */
.image-upload-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    color: var(--text-meta);
    cursor: pointer;
    margin-bottom: 15px;
    transition: border-color 0.2s;
}

.image-upload-area:hover,
.image-upload-area.drag-over {
    border-color: var(--primary);
    background-color: rgba(52, 152, 219, 0.05);
}

/* Image Thumbnails */
.result-thumb-container {
    margin: 10px 0;
    max-width: 100%;
    overflow: hidden;
    border-radius: 4px;
    background: #f0f0f0;
}

.result-thumb {
    max-height: 200px;
    object-fit: contain;
    cursor: zoom-in;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.result-thumb:hover {
    transform: scale(1.02);
}