/* =============================================
   Open Source Finder — style.css
   Green/teal growth theme, card grid layout
   ============================================= */

:root {
    --bg: #f0fdf4;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #d1fae5;
    --text: #1a2e1a;
    --muted: #6b7280;
    --primary: #059669;
    --primary-h: #047857;
    --accent: #10b981;
    --yellow: #f59e0b;
    --red: #ef4444;
    --blue: #3b82f6;
    --purple: #8b5cf6;
    --radius: 10px;
    --radius-sm: 6px;
    --top-h: 54px;
    --sidebar-w: 260px;
    --shadow: 0 2px 12px rgba(5, 150, 105, 0.08);
}

.dark-mode {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c222c;
    --border: #21262d;
    --text: #e6edf3;
    --muted: #8b949e;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

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

html,
body {
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
    transition: background 0.25s, color 0.25s;
}

/* ── Top Bar ── */
.top-bar {
    height: var(--top-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.brand-icon {
    font-size: 1.6rem;
}

.brand-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--primary);
}

.brand-sub {
    font-size: 0.7rem;
    color: var(--muted);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.refresh-label {
    font-size: 0.7rem;
    color: var(--muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    padding: 8px 14px;
    font-size: 0.8rem;
    width: 100%;
    justify-content: center;
}

.btn-primary:hover {
    background: var(--primary-h);
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--muted);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 5px 8px;
    font-size: 0.76rem;
}

.btn-ghost:hover {
    color: var(--text);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.76rem;
}

.btn-full {
    display: flex;
    margin-top: 12px;
}

/* ── Layout ── */
.layout {
    display: flex;
    height: calc(100vh - var(--top-h));
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Sidebar ── */
.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.filter-chips.col {
    flex-direction: column;
}

.chip {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 3px 9px;
    font-family: inherit;
    font-size: 0.72rem;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.18s;
}

.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

.chip:hover:not(.active) {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.76rem;
    padding: 5px 8px;
    outline: none;
}

.filter-select:focus {
    border-color: var(--primary);
}

/* ── Checklist ── */
.checklist-panel {
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.76rem;
    cursor: pointer;
    color: var(--text);
}

.check-item input {
    accent-color: var(--primary);
    cursor: pointer;
}

.journey-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.journey-bar {
    height: 5px;
    flex: 1;
    background: var(--border);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}

.journey-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    right: auto;
    width: var(--pct, 0);
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.4s;
}

.journey-label {
    font-size: 0.68rem;
    color: var(--muted);
    white-space: nowrap;
}

/* ── Content ── */
.content-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    background: var(--surface);
    flex-shrink: 0;
}

.result-meta {
    flex: 1;
    font-size: 0.75rem;
    color: var(--muted);
}

.top-tabs {
    display: flex;
    gap: 2px;
}

.tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 0.78rem;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.18s;
}

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

.tab-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow-y: auto;
    padding: 14px;
    gap: 10px;
}

.tab-panel.active {
    display: flex;
}

/* ── States ── */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px;
    color: var(--muted);
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 60px;
    color: var(--muted);
    text-align: center;
}

.empty-state h3 {
    font-size: 0.95rem;
    color: var(--text);
}

/* ── Issue Cards ── */
.issue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 10px;
    align-content: start;
}

.issue-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s;
}

.issue-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.issue-repo {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.issue-repo:hover {
    text-decoration: underline;
}

.issue-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
}

.issue-title a {
    color: inherit;
    text-decoration: none;
}

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

.issue-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.label-chip {
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 600;
    border: 1px solid;
}

.issue-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.7rem;
    color: var(--muted);
}

.issue-meta-item {
    display: flex;
    align-items: center;
    gap: 3px;
}

.issue-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.stars-badge {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.68rem;
    color: var(--yellow);
}

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    flex-shrink: 0;
    justify-content: center;
}

.page-label {
    font-size: 0.76rem;
    color: var(--muted);
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 500px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 0.88rem;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-actions {
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.bm-item {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bm-item-repo {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 600;
}

.bm-item-title {
    font-size: 0.8rem;
}

.bm-item-remove {
    font-size: 0.7rem;
    color: var(--muted);
    cursor: pointer;
    align-self: flex-end;
}

.bm-item-remove:hover {
    color: var(--red);
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 16px;
    right: 16px;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.78rem;
    z-index: 999;
    opacity: 0;
    transform: translateY(6px);
    transition: all 0.25s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}