/* ═══════════════════════════════════════════
   CODE BROWSER
   ═══════════════════════════════════════════ */

.browse-layout {
    display: flex;
    min-height: 100vh;
    padding-top: 60px;
}

/* ─── Sidebar ─── */
.browse-sidebar {
    width: 300px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    z-index: 20;
    overflow: hidden;
}

.browse-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.browse-sidebar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.browse-sidebar-title svg { opacity: 0.6; }

.browse-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.browse-search-box:focus-within { border-color: var(--accent-primary); }

.browse-search-box svg { flex-shrink: 0; opacity: 0.4; }

.browse-search-box input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    outline: none;
}

.browse-search-box input::placeholder { color: var(--text-muted); }

/* ─── File Tree ─── */
.browse-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.tree-dir {}

.tree-dir-label {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: 4px 12px 4px 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.1s;
}

.tree-dir-label:hover { background: var(--bg-card); color: var(--text-primary); }

.tree-arrow {
    flex-shrink: 0;
    transition: transform 0.15s;
    opacity: 0.4;
}

.tree-dir.open > .tree-dir-label .tree-arrow { transform: rotate(90deg); }

.tree-icon-dir { flex-shrink: 0; opacity: 0.5; }

.tree-children {
    display: none;
    padding-left: 12px;
}

.tree-dir.open > .tree-children { display: block; }

.tree-file {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 4px 12px 4px 28px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.1s;
    border-left: 2px solid transparent;
}

.tree-file:hover { background: var(--bg-card); color: var(--text-primary); }

.tree-file.active {
    background: var(--tag-bg);
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
}

.tree-file-name { flex: 1; }

.tree-file-size {
    font-size: 0.68rem;
    color: var(--text-muted);
    opacity: 0.6;
}

.browse-sidebar-stats {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ─── Sidebar Toggle (mobile) ─── */
.browse-sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 30;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
    align-items: center;
    justify-content: center;
}

/* ─── Main Content ─── */
.browse-main {
    flex: 1;
    margin-left: 300px;
    min-height: calc(100vh - 60px);
    max-width: calc(100vw - 300px);
    overflow-x: hidden;
}

/* ─── Welcome State ─── */
.browse-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 60px 32px;
    text-align: center;
}

.browse-welcome-icon { margin-bottom: 24px; }

.browse-welcome h2 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.browse-welcome > p {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 500px;
    line-height: 1.7;
    margin-bottom: 32px;
}

.browse-welcome-stats {
    display: flex;
    gap: 32px;
    margin-bottom: 48px;
}

.browse-welcome-stat {
    text-align: center;
}

.browse-welcome-stat strong {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

.browse-welcome-stat span {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.browse-quick-links {
    width: 100%;
    max-width: 720px;
}

.browse-quick-links h4 {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.browse-quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.quick-link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    font-family: inherit;
    color: inherit;
}

.quick-link:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.08);
}

.quick-link-name {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.quick-link-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ─── File Viewer ─── */
.browse-viewer {
    padding: 24px 32px 60px;
    max-width: 100%;
    overflow: hidden;
}

/* Breadcrumb */
.browse-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.bc-root { color: var(--text-muted); opacity: 0.6; }
.bc-sep { opacity: 0.3; }
.bc-part { color: var(--text-secondary); }
.bc-current { color: var(--accent-primary); font-weight: 700; }

/* File Header */
.browse-file-header {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.fh-title {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.fh-title h2 {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

.fh-badges {
    display: flex;
    gap: 8px;
}

.fh-badge {
    padding: 3px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
}

.fh-badge-lang {
    background: var(--tag-bg);
    color: var(--accent-primary);
    font-weight: 700;
    border-color: var(--accent-primary);
}

.fh-desc {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* Code Container */
.browse-code-container {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 32px;
}

.browse-line-numbers {
    padding: 20px 12px 20px 16px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.7;
    color: var(--text-muted);
    text-align: right;
    user-select: none;
    flex-shrink: 0;
    white-space: pre;
    opacity: 0.5;
}

.browse-code {
    flex: 1;
    padding: 20px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin: 0;
    tab-size: 2;
}

/* Syntax Highlighting */
.hl-keyword { color: #c792ea; font-weight: 600; }
.hl-type { color: #ffcb6b; }
.hl-string { color: #c3e88d; }
.hl-comment { color: #546e7a; font-style: italic; }
.hl-number { color: #f78c6c; }
.hl-bool { color: #ff5370; }

[data-theme="light"] .hl-keyword { color: #7c3aed; }
[data-theme="light"] .hl-type { color: #d97706; }
[data-theme="light"] .hl-string { color: #16a34a; }
[data-theme="light"] .hl-comment { color: #9ca3af; }
[data-theme="light"] .hl-number { color: #ea580c; }
[data-theme="light"] .hl-bool { color: #dc2626; }

/* ─── RTL / Arabic fixes ─── */
/* The entire browse layout stays LTR always (it's a code browser) */
.browse-layout {
    direction: ltr;
}
/* Only Arabic text elements get RTL */
[dir="rtl"] .fh-desc {
    direction: rtl;
    text-align: right;
}
[dir="rtl"] .browse-summary-btn,
[dir="rtl"] .browse-ai-btn {
    direction: rtl;
}
[dir="rtl"] .browse-ai-content {
    direction: rtl;
    text-align: right;
}
[dir="rtl"] .browse-ai-content code {
    direction: ltr;
    display: inline-block;
}

/* File Documentation */
.browse-file-docs {
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.browse-file-docs h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px;
}

.browse-file-docs p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0 0 12px;
}

.browse-file-docs ul {
    padding-left: 20px;
    margin: 0 0 12px;
}

.browse-file-docs li {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 4px;
}

.browse-file-docs code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.82em;
    color: var(--accent-primary);
}

.browse-file-docs .doc-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.browse-file-docs .doc-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.browse-file-docs .doc-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--tag-bg);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--tag-text);
    margin-right: 4px;
    margin-bottom: 4px;
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .browse-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .browse-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    }

    .browse-main { margin-left: 0; }

    .browse-sidebar-toggle { display: flex; }

    .browse-viewer { padding: 20px 16px 40px; }

    .fh-title { flex-direction: column; align-items: flex-start; gap: 8px; }

    .browse-welcome-stats { flex-direction: column; gap: 16px; }
}

@media (max-width: 600px) {
    .browse-sidebar { width: 260px; }
    .browse-welcome h2 { font-size: 1.3rem; }
    .browse-code { font-size: 0.72rem; }
    .browse-quick-grid { grid-template-columns: 1fr; }
}

/* ─── Code Coverage Indicator ─── */
.browse-code-coverage {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px 8px calc(60px + 16px);
    font-size: 0.72rem;
    font-weight: 600;
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.05);
    border-bottom: 1px solid rgba(99, 102, 241, 0.08);
}
.browse-code-coverage.complete {
    color: #34d399;
    background: rgba(52, 211, 153, 0.05);
}
.browse-code-coverage.generated {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.05);
}
.browse-coverage-bar {
    flex: 1;
    max-width: 200px;
    height: 4px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 2px;
    overflow: hidden;
}
.browse-coverage-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 2px;
    transition: width 0.5s ease;
}
[data-theme="light"] .browse-code-coverage { color: #4338ca; background: rgba(99, 102, 241, 0.03); }
[data-theme="light"] .browse-code-coverage.complete { color: #059669; }
[data-theme="light"] .browse-code-coverage.generated { color: #d97706; }

/* ─── Summary Role Block ─── */
.summary-role-block {
    margin-bottom: 16px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.05));
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 10px;
    border-left: 3px solid #6366f1;
}
.summary-role-title {
    font-size: 0.78rem;
    font-weight: 800;
    color: #a5b4fc;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.summary-role-desc {
    font-size: 0.82rem;
    line-height: 1.6;
    color: #e0e7ff;
}
.summary-role-folder {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(99, 102, 241, 0.1);
    font-size: 0.75rem;
    color: rgba(165, 180, 252, 0.7);
}
.summary-role-folder code {
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.1);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
}
[data-theme="light"] .summary-role-block { background: linear-gradient(135deg, #eef2ff, #f5f3ff); border-color: #c7d2fe; }
[data-theme="light"] .summary-role-block strong { color: #3730a3; }
[data-theme="light"] .summary-role-title { color: #4338ca; }
[data-theme="light"] .summary-role-desc { color: #1e1b4b; }
[data-theme="light"] .summary-role-folder { color: #6b7280; }

/* ─── Summary Quick Stats ─── */
.summary-quick-stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin: 12px 0 16px;
}
.summary-stat-item {
    text-align: center;
    padding: 10px 4px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 8px;
}
.stat-num {
    display: block;
    font-size: 1.1rem;
    font-weight: 800;
    color: #a5b4fc;
}
.stat-label {
    display: block;
    font-size: 0.62rem;
    color: rgba(165, 180, 252, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}
[data-theme="light"] .summary-stat-item { background: #f5f3ff; border-color: #ddd6fe; }
[data-theme="light"] .stat-num { color: #4338ca; }
[data-theme="light"] .stat-label { color: #6b7280; }

/* RTL support for summary */
.rtl-block { direction: rtl; text-align: right; }
.rtl-block .summary-role-block { border-left: none; border-right: 3px solid #6366f1; }
.rtl-block code { direction: ltr; display: inline-block; }

@media (max-width: 600px) {
    .summary-quick-stats { grid-template-columns: repeat(3, 1fr); }
}

/* ─── Action Bar (Summary + AI buttons) ─── */
.browse-action-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.browse-action-bar .browse-summary-btn {
    flex: 1;
}

/* ─── Ask AI Button ─── */
.browse-ai-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    padding: 12px 18px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.08));
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 10px;
    color: #6ee7b7;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
}
.browse-ai-btn svg {
    flex-shrink: 0;
    width: 18px; height: 18px;
    color: #34d399;
}
.browse-ai-btn:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.15));
    border-color: rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.12);
}
.browse-ai-btn.ai-loading-state {
    pointer-events: none;
    opacity: 0.7;
}
[data-theme="light"] .browse-ai-btn {
    background: linear-gradient(135deg, #ecfdf5, #e0f7fa);
    border-color: #a7f3d0;
    color: #047857;
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.1);
}
[data-theme="light"] .browse-ai-btn svg { color: #059669; }
[data-theme="light"] .browse-ai-btn:hover {
    background: linear-gradient(135deg, #d1fae5, #ccfbf1);
    border-color: #6ee7b7;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.15);
}

/* ─── AI Result Panel ─── */
.browse-ai-result {
    background: rgba(15, 15, 25, 0.6);
    border: 1px solid rgba(16, 185, 129, 0.18);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 8px;
    animation: summarySlide 0.3s ease;
}
.browse-ai-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(6, 182, 212, 0.08));
    border-bottom: 1px solid rgba(16, 185, 129, 0.12);
    font-weight: 600;
    font-size: 13px;
    color: #6ee7b7;
}
.browse-ai-header svg { color: #34d399; flex-shrink: 0; }
.browse-ai-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}
.browse-ai-close:hover { color: #f87171; }
.browse-ai-content {
    padding: 18px 22px;
    font-size: 13.5px;
    line-height: 1.8;
    color: rgba(255,255,255,0.85);
}
.browse-ai-content h3.ai-h2 {
    font-size: 15px;
    font-weight: 700;
    color: #6ee7b7;
    margin: 16px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(16, 185, 129, 0.15);
}
.browse-ai-content h3.ai-h2:first-child { margin-top: 0; }
.browse-ai-content h4.ai-h3 {
    font-size: 13.5px;
    font-weight: 600;
    color: #34d399;
    margin: 12px 0 6px;
}
.browse-ai-content strong { color: #e0e7ff; }
.browse-ai-content code {
    background: rgba(16, 185, 129, 0.08);
    color: #6ee7b7;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}
.browse-ai-content ul.ai-list {
    list-style: none;
    padding-left: 16px;
    margin: 8px 0;
}
.browse-ai-content ul.ai-list li {
    position: relative;
    padding-left: 14px;
    margin-bottom: 4px;
    color: rgba(255,255,255,0.75);
}
.browse-ai-content ul.ai-list li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: #34d399;
}
.browse-ai-content p { margin: 8px 0; }
.browse-ai-content .ai-error { color: #f87171; }

/* AI Loading Animation */
.ai-loading {
    text-align: center;
    padding: 24px;
}
.ai-loading p { color: rgba(255,255,255,0.5); margin-top: 12px; font-size: 13px; }
.ai-loading-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
}
.ai-loading-dots span {
    width: 8px; height: 8px;
    background: #34d399;
    border-radius: 50%;
    animation: aiDot 1.2s ease-in-out infinite;
}
.ai-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiDot {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* Light theme AI */
[data-theme="light"] .browse-ai-result {
    background: #f0fdf9;
    border-color: #a7f3d0;
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.08);
}
[data-theme="light"] .browse-ai-header {
    background: linear-gradient(135deg, #ecfdf5, #e0f7fa);
    border-bottom-color: #a7f3d0;
    color: #047857;
}
[data-theme="light"] .browse-ai-header svg { color: #059669; }
[data-theme="light"] .browse-ai-close { color: #94a3b8; }
[data-theme="light"] .browse-ai-close:hover { color: #ef4444; }
[data-theme="light"] .browse-ai-content { color: #334155; }
[data-theme="light"] .browse-ai-content h3.ai-h2 { color: #047857; border-bottom-color: #a7f3d0; }
[data-theme="light"] .browse-ai-content h4.ai-h3 { color: #059669; }
[data-theme="light"] .browse-ai-content strong { color: #1e293b; }
[data-theme="light"] .browse-ai-content code { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
[data-theme="light"] .browse-ai-content ul.ai-list li { color: #475569; }
[data-theme="light"] .browse-ai-content ul.ai-list li::before { color: #059669; }
[data-theme="light"] .ai-loading p { color: #6b7280; }
[data-theme="light"] .ai-loading-dots span { background: #059669; }

/* ─── Code Summary Section ─── */
.browse-summary-section {
    margin: 0 0 12px 0;
}

.browse-summary-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 18px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 10px;
    color: #a5b4fc;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
}
.browse-summary-btn:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.15));
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.12);
}
.browse-summary-btn svg {
    flex-shrink: 0;
    width: 18px; height: 18px;
    color: #818cf8;
}
[data-theme="light"] .browse-summary-btn {
    background: linear-gradient(135deg, #eef2ff, #e8e0ff);
    border-color: #c7d2fe;
    color: #4338ca;
    box-shadow: 0 1px 3px rgba(99, 102, 241, 0.1);
}
[data-theme="light"] .browse-summary-btn svg { color: #4f46e5; }
[data-theme="light"] .browse-summary-btn:hover {
    background: linear-gradient(135deg, #e0e7ff, #ddd6fe);
    border-color: #a5b4fc;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.15);
}

/* Summary Result Panel */
.browse-summary-result {
    background: rgba(15, 15, 25, 0.6);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 8px;
    animation: summarySlide 0.3s ease;
}
@keyframes summarySlide {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 2000px; }
}

.browse-summary-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.08));
    border-bottom: 1px solid rgba(99, 102, 241, 0.12);
    font-weight: 600;
    font-size: 13px;
    color: #a5b4fc;
}
.browse-summary-header svg { color: #818cf8; flex-shrink: 0; }
.browse-summary-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}
.browse-summary-close:hover { color: #f87171; }

.browse-summary-content {
    padding: 18px 22px;
    font-size: 13.5px;
    line-height: 1.7;
    color: rgba(255,255,255,0.85);
}

/* Summary inner styles */
.browse-summary-content .summary-lang-block { margin-bottom: 4px; }
.browse-summary-content .rtl-block { direction: rtl; text-align: right; }
.browse-summary-content .summary-h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 10px 0;
    color: #c4b5fd;
    display: flex;
    align-items: center;
    gap: 6px;
}
.browse-summary-content .summary-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}
.browse-summary-content .summary-badge {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: #a5b4fc;
}
.browse-summary-content .async-badge { background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.browse-summary-content .react-badge { background: rgba(56, 189, 248, 0.12); border-color: rgba(56, 189, 248, 0.2); color: #7dd3fc; }

.browse-summary-content .summary-field {
    margin: 6px 0;
}
.browse-summary-content strong { color: #e0e7ff; }
.browse-summary-content code {
    background: rgba(99, 102, 241, 0.12);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: #a5b4fc;
    font-family: 'JetBrains Mono', monospace;
}
.browse-summary-content .summary-list {
    margin: 4px 0 8px 0;
    padding-left: 18px;
    list-style: none;
}
.browse-summary-content .summary-list li {
    margin: 3px 0;
    color: rgba(255,255,255,0.7);
    position: relative;
    padding-left: 12px;
}
.browse-summary-content .summary-list li::before {
    content: '>';
    position: absolute;
    left: 0;
    color: #818cf8;
    font-weight: bold;
    font-size: 11px;
}
.browse-summary-content .rtl-block .summary-list { padding-left: 0; padding-right: 18px; }
.browse-summary-content .rtl-block .summary-list li { padding-left: 0; padding-right: 12px; }
.browse-summary-content .rtl-block .summary-list li::before { left: auto; right: 0; }

.browse-summary-content .summary-divider {
    border: none;
    border-top: 1px solid rgba(99, 102, 241, 0.12);
    margin: 14px 0;
}

/* Complexity colors */
.browse-summary-content .complexity-simple { color: #6ee7b7; }
.browse-summary-content .complexity-moderate { color: #fbbf24; }
.browse-summary-content .complexity-complex { color: #f87171; }

/* Light theme */
[data-theme="light"] .browse-summary-result {
    background: #fafbff;
    border-color: #c7d2fe;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.08), 0 0 0 1px rgba(99, 102, 241, 0.04);
}
[data-theme="light"] .browse-summary-header {
    background: linear-gradient(135deg, #eef2ff, #ede9fe);
    border-bottom-color: #c7d2fe;
    color: #3730a3;
}
[data-theme="light"] .browse-summary-header svg { color: #4f46e5; }
[data-theme="light"] .browse-summary-close { color: #94a3b8; }
[data-theme="light"] .browse-summary-close:hover { color: #ef4444; }
[data-theme="light"] .browse-summary-content { color: #334155; }
[data-theme="light"] .browse-summary-content .summary-h3 { color: #3730a3; border-bottom-color: #e0e7ff; }
[data-theme="light"] .browse-summary-content strong { color: #1e293b; }
[data-theme="light"] .browse-summary-content .summary-badge { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
[data-theme="light"] .browse-summary-content .async-badge { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
[data-theme="light"] .browse-summary-content .react-badge { background: #e0f2fe; color: #0369a1; border-color: #7dd3fc; }
[data-theme="light"] .browse-summary-content .summary-list li { color: #475569; }
[data-theme="light"] .browse-summary-content .summary-list li::before { color: #6366f1; }
[data-theme="light"] .browse-summary-content code { background: #eef2ff; color: #4338ca; border: 1px solid #e0e7ff; }
[data-theme="light"] .browse-summary-content .complexity-simple { color: #059669; }
[data-theme="light"] .browse-summary-content .complexity-moderate { color: #d97706; }
[data-theme="light"] .browse-summary-content .complexity-complex { color: #dc2626; }

/* ─── Detailed Summary Styles ─── */

/* Section titles */
.browse-summary-content .summary-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #818cf8;
    margin: 18px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.12);
    display: flex;
    align-items: center;
    gap: 8px;
}
.browse-summary-content .summary-count {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    font-size: 11px;
    padding: 1px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* Imports grid */
.browse-summary-content .summary-imports-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}
.browse-summary-content .summary-import-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: rgba(255,255,255,0.02);
    border-radius: 6px;
    font-size: 12px;
}
.browse-summary-content .summary-import-item:hover { background: rgba(99, 102, 241, 0.06); }
.browse-summary-content .import-from {
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    color: #a5b4fc;
    font-size: 11px;
    flex-shrink: 0;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.browse-summary-content .import-what { color: rgba(255,255,255,0.5); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browse-summary-content .import-type-tag { font-size: 9px; background: rgba(139, 92, 246, 0.15); color: #c4b5fd; padding: 1px 5px; border-radius: 3px; }
.browse-summary-content .type-import { opacity: 0.7; }

/* ── Class Block ── */
.browse-summary-content .summary-class-block {
    margin: 14px 0;
    background: rgba(99, 102, 241, 0.04);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 10px;
    padding: 14px 16px;
}
.browse-summary-content .summary-class-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}
.browse-summary-content .summary-class-icon {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-weight: 800;
    font-size: 12px;
    border-radius: 6px;
    flex-shrink: 0;
}
.browse-summary-content .iface-icon { background: linear-gradient(135deg, #06b6d4, #0ea5e9); }
.browse-summary-content .enum-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }

.browse-summary-content .summary-class-name {
    font-size: 15px;
    font-weight: 700;
    color: #e0e7ff;
}
.browse-summary-content .summary-class-doc {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    margin-bottom: 10px;
    font-style: italic;
}

/* Tags */
.browse-summary-content .summary-tag {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}
.browse-summary-content .tag-export { background: rgba(16, 185, 129, 0.12); color: #6ee7b7; }
.browse-summary-content .tag-extends { background: rgba(99, 102, 241, 0.12); color: #a5b4fc; }
.browse-summary-content .tag-impl { background: rgba(244, 114, 182, 0.12); color: #f9a8d4; }
.browse-summary-content .summary-line-ref {
    margin-left: auto;
    font-size: 11px;
    color: rgba(255,255,255,0.3);
    font-family: 'JetBrains Mono', monospace;
}
.browse-summary-content .rtl-block .summary-line-ref { margin-left: 0; margin-right: auto; }

/* Sub titles (Properties / Methods) */
.browse-summary-content .summary-sub-title {
    font-size: 12px;
    font-weight: 700;
    color: #818cf8;
    margin: 12px 0 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Properties table */
.browse-summary-content .summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 10px;
}
.browse-summary-content .summary-table th {
    text-align: left;
    padding: 5px 8px;
    font-weight: 600;
    color: rgba(255,255,255,0.4);
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.browse-summary-content .rtl-block .summary-table th { text-align: right; }
.browse-summary-content .summary-table td {
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    color: rgba(255,255,255,0.7);
}
.browse-summary-content .summary-table tr:hover td { background: rgba(99, 102, 241, 0.04); }
.browse-summary-content .type-cell { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #c4b5fd; }
.browse-summary-content .line-cell { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: rgba(255,255,255,0.3); }

/* Visibility tags */
.browse-summary-content .vis-tag {
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
}
.browse-summary-content .vis-public { background: rgba(16, 185, 129, 0.1); color: #6ee7b7; }
.browse-summary-content .vis-private { background: rgba(239, 68, 68, 0.1); color: #fca5a5; }
.browse-summary-content .vis-protected { background: rgba(245, 158, 11, 0.1); color: #fcd34d; }

/* Method items */
.browse-summary-content .summary-method-item {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.browse-summary-content .summary-method-item:last-child { border-bottom: none; }
.browse-summary-content .method-signature {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    font-size: 12px;
}
.browse-summary-content .method-async {
    font-size: 9px;
    background: rgba(16, 185, 129, 0.1);
    color: #6ee7b7;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 600;
}
.browse-summary-content .method-name { color: #e0e7ff; font-weight: 600; font-size: 13px; background: none; padding: 0; }
.browse-summary-content .method-params { color: rgba(255,255,255,0.45); font-size: 11px; background: none; padding: 0; }
.browse-summary-content .method-return { color: #c4b5fd; font-size: 11px; font-family: 'JetBrains Mono', monospace; }
.browse-summary-content .method-doc { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 2px; font-style: italic; padding-left: 12px; }
.browse-summary-content .rtl-block .method-doc { padding-left: 0; padding-right: 12px; }

/* Interface block */
.browse-summary-content .summary-iface-block {
    margin: 14px 0;
    background: rgba(6, 182, 212, 0.04);
    border: 1px solid rgba(6, 182, 212, 0.1);
    border-radius: 10px;
    padding: 14px 16px;
}

/* Type items */
.browse-summary-content .summary-type-item {
    padding: 5px 0;
    font-size: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}
.browse-summary-content .type-name { color: #e0e7ff; font-weight: 600; background: none; padding: 0; }
.browse-summary-content .type-value { color: #c4b5fd; font-size: 11px; background: none; padding: 0; }

/* Enum values */
.browse-summary-content .summary-enum-values {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.browse-summary-content .enum-val {
    font-size: 11px;
    padding: 3px 10px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.12);
    border-radius: 6px;
    color: #fcd34d;
}

/* Empty state */
.browse-summary-content .summary-empty {
    text-align: center;
    padding: 24px;
    color: rgba(255,255,255,0.3);
    font-style: italic;
}

/* ── Light theme overrides ── */
[data-theme="light"] .browse-summary-content .summary-section-title { color: #3730a3; }
[data-theme="light"] .browse-summary-content .summary-count { background: #e0e7ff; color: #4338ca; }
[data-theme="light"] .browse-summary-content .summary-import-item:hover { background: #f5f3ff; }
[data-theme="light"] .browse-summary-content .import-from { background: #eef2ff; color: #4338ca; }
[data-theme="light"] .browse-summary-content .import-what { color: #64748b; }
[data-theme="light"] .browse-summary-content .import-type-tag { background: #ede9fe; color: #6d28d9; }
[data-theme="light"] .browse-summary-content .summary-class-block { background: #f8faff; border-color: #c7d2fe; }
[data-theme="light"] .browse-summary-content .summary-class-name { color: #1e293b; }
[data-theme="light"] .browse-summary-content .summary-class-doc { color: #64748b; }
[data-theme="light"] .browse-summary-content .tag-export { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
[data-theme="light"] .browse-summary-content .tag-extends { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
[data-theme="light"] .browse-summary-content .tag-impl { background: #fdf2f8; color: #be185d; border-color: #fbcfe8; }
[data-theme="light"] .browse-summary-content .summary-line-ref { color: #94a3b8; }
[data-theme="light"] .browse-summary-content .summary-sub-title { color: #4f46e5; }
[data-theme="light"] .browse-summary-content .summary-table th { color: #64748b; }
[data-theme="light"] .browse-summary-content .summary-table td { color: #334155; }
[data-theme="light"] .browse-summary-content .type-cell { color: #7c3aed; }
[data-theme="light"] .browse-summary-content .line-cell { color: #94a3b8; }
[data-theme="light"] .browse-summary-content .vis-public { background: #ecfdf5; color: #047857; }
[data-theme="light"] .browse-summary-content .vis-private { background: #fef2f2; color: #dc2626; }
[data-theme="light"] .browse-summary-content .vis-protected { background: #fffbeb; color: #b45309; }
[data-theme="light"] .browse-summary-content .method-async { background: #ecfdf5; color: #047857; }
[data-theme="light"] .browse-summary-content .method-name { color: #1e293b; }
[data-theme="light"] .browse-summary-content .method-params { color: #64748b; }
[data-theme="light"] .browse-summary-content .method-return { color: #7c3aed; }
[data-theme="light"] .browse-summary-content .method-doc { color: #64748b; }
[data-theme="light"] .browse-summary-content .summary-iface-block { background: #f0fdfa; border-color: #99f6e4; }
[data-theme="light"] .browse-summary-content .type-name { color: #1e293b; }
[data-theme="light"] .browse-summary-content .type-value { color: #7c3aed; }
[data-theme="light"] .browse-summary-content .enum-val { background: #fffbeb; border-color: #fde68a; color: #92400e; }
[data-theme="light"] .browse-summary-content .summary-empty { color: #94a3b8; }
