/* ============================================================
   Boardview Viewer — Dark cyberpunk theme
   ============================================================ */

:root {
    --bv-bg: #0d0d14;
    --bv-bg2: #12121a;
    --bv-bg3: #1a1a25;
    --bv-panel: #12121a;
    --bv-border: #2a2a3a;
    --bv-border-light: #3a3a4a;
    --bv-accent: #00e5ff;
    --bv-accent-dim: rgba(0, 229, 255, 0.15);
    --bv-top: #22aa66;
    --bv-bot: #cc4444;
    --bv-text: #b0b8c8;
    --bv-text-muted: #6a7080;
    --bv-text-bright: #e0e6ef;
    --bv-highlight: #ffcc00;
    --bv-selected: #00e5ff;
    --bv-search-hl: #ff6600;
    --bv-radius: 6px;
    --bv-font: 'Inter', -apple-system, sans-serif;
    --bv-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* === PIN Gate === */
.bv-pin-gate {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--bv-bg);
    display: flex; align-items: center; justify-content: center;
}
.bv-pin-gate__card {
    background: var(--bv-bg2);
    border: 1px solid var(--bv-border);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    text-align: center;
    max-width: 340px; width: 90%;
}
.bv-pin-gate__icon {
    font-size: 2.5rem;
    color: var(--bv-accent);
    margin-bottom: 1rem;
}
.bv-pin-gate__title {
    font-family: var(--bv-font);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--bv-text-bright);
    margin: 0 0 0.3rem;
}
.bv-pin-gate__subtitle {
    font-size: 0.82rem;
    color: var(--bv-text-muted);
    margin: 0 0 1.5rem;
}
.bv-pin-gate__input {
    width: 100%; box-sizing: border-box;
    background: var(--bv-bg);
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius);
    padding: 0.7rem;
    text-align: center;
    font-family: var(--bv-mono);
    font-size: 1.4rem;
    letter-spacing: 0.5rem;
    color: var(--bv-accent);
    outline: none;
    transition: border-color 0.2s;
}
.bv-pin-gate__input:focus { border-color: var(--bv-accent); }
.bv-pin-gate__btn {
    width: 100%; margin-top: 1rem;
    padding: 0.6rem;
    background: var(--bv-accent);
    color: #000;
    border: none;
    border-radius: var(--bv-radius);
    font-family: var(--bv-font);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
}
.bv-pin-gate__btn:hover { opacity: 0.85; }
.bv-pin-gate__error {
    color: #f44;
    font-size: 0.78rem;
    margin: 0.75rem 0 0;
    font-family: var(--bv-mono);
}

/* === Wrapper === */
.bv-wrapper {
    position: fixed; inset: 0;
    background: var(--bv-bg);
    display: flex; flex-direction: column;
    font-family: var(--bv-font);
    color: var(--bv-text);
    z-index: 500;
}

/* === Toolbar === */
.bv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem;
    height: 42px;
    background: var(--bv-bg2);
    border-bottom: 1px solid var(--bv-border);
    flex-shrink: 0;
    gap: 0.5rem;
    backdrop-filter: blur(8px);
    z-index: 10;
}
.bv-toolbar__left, .bv-toolbar__right {
    display: flex; align-items: center; gap: 0.35rem;
}
.bv-toolbar__btn {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    background: transparent;
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius);
    color: var(--bv-text);
    font-family: var(--bv-font);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.bv-toolbar__btn:hover { border-color: var(--bv-accent); color: var(--bv-accent); }
.bv-toolbar__btn.active { background: var(--bv-accent-dim); border-color: var(--bv-accent); color: var(--bv-accent); }
.bv-toolbar__btn--top { border-color: var(--bv-top) !important; color: var(--bv-top) !important; }
.bv-toolbar__btn--bot { border-color: var(--bv-bot) !important; color: var(--bv-bot) !important; }
.bv-toolbar__sep { width: 1px; height: 20px; background: var(--bv-border); margin: 0 0.25rem; }
.bv-toolbar__board-name {
    font-family: var(--bv-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--bv-accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

/* Search */
.bv-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.bv-search-icon {
    position: absolute; left: 0.5rem;
    color: var(--bv-text-muted);
    font-size: 0.72rem;
    pointer-events: none;
}
.bv-search-input {
    width: 220px;
    padding: 0.3rem 0.5rem 0.3rem 1.6rem;
    background: var(--bv-bg);
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius);
    color: var(--bv-text);
    font-family: var(--bv-mono);
    font-size: 0.78rem;
    outline: none;
    transition: border-color 0.2s;
}
.bv-search-input:focus { border-color: var(--bv-accent); }
.bv-search-count {
    position: absolute; right: 0.4rem;
    font-size: 0.65rem;
    color: var(--bv-text-muted);
    font-family: var(--bv-mono);
}

/* === Main area === */
.bv-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* === Canvas viewport === */
.bv-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bv-bg);
}
.bv-viewport canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Empty state */
.bv-empty-state {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--bv-text-muted);
    pointer-events: none;
}
.bv-empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.3; }
.bv-empty-state h3 { font-size: 1.1rem; margin: 0 0 0.5rem; color: var(--bv-text); }
.bv-empty-state p { font-size: 0.82rem; margin: 0 0 1.5rem; max-width: 320px; text-align: center; }
.bv-empty-state__btn {
    pointer-events: auto;
    padding: 0.5rem 1.2rem;
    background: var(--bv-accent);
    color: #000;
    border: none;
    border-radius: var(--bv-radius);
    font-family: var(--bv-font);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: opacity 0.2s;
}
.bv-empty-state__btn:hover { opacity: 0.85; }

/* Loading */
.bv-loading {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: rgba(13, 13, 20, 0.85);
    color: var(--bv-accent);
    font-size: 0.85rem;
    gap: 0.75rem;
    z-index: 5;
}
.bv-loading__spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--bv-border);
    border-top-color: var(--bv-accent);
    border-radius: 50%;
    animation: bvSpin 0.7s linear infinite;
}
@keyframes bvSpin { to { transform: rotate(360deg); } }

/* === Info panel === */
.bv-info-panel {
    width: 280px;
    background: var(--bv-panel);
    border-left: 1px solid var(--bv-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: margin-right 0.25s;
}
.bv-info-panel.hidden {
    margin-right: -280px;
}
.bv-info-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.5rem 0 0;
    border-bottom: 1px solid var(--bv-border);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--bv-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.bv-info-panel__tabs {
    display: flex;
    gap: 0;
}
.bv-info-panel__tab {
    background: none; border: none;
    padding: 0.5rem 0.75rem;
    font-size: 0.72rem; font-weight: 600;
    color: var(--bv-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.bv-info-panel__tab:hover { color: var(--bv-text); }
.bv-info-panel__tab.active {
    color: var(--bv-accent);
    border-bottom-color: var(--bv-accent);
}
.bv-info-panel__close {
    background: none; border: none;
    color: var(--bv-text-muted);
    cursor: pointer;
    padding: 0.2rem;
    font-size: 0.8rem;
}
.bv-info-panel__close:hover { color: var(--bv-text); }
.bv-info-panel__content {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    font-size: 0.78rem;
    display: none;
}
.bv-info-panel__content.active {
    display: block;
}
.bv-info-panel__empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 200px;
    color: var(--bv-text-muted);
    text-align: center;
}
.bv-info-panel__empty i { font-size: 1.5rem; margin-bottom: 0.5rem; opacity: 0.3; }
.bv-info-panel__empty p { font-size: 0.75rem; }

/* Info panel component details */
.bv-info__label {
    font-size: 0.65rem;
    color: var(--bv-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.75rem;
    margin-bottom: 0.2rem;
}
.bv-info__label:first-child { margin-top: 0; }
.bv-info__value {
    font-family: var(--bv-mono);
    font-size: 0.82rem;
    color: var(--bv-text-bright);
    padding: 0.3rem 0.5rem;
    background: var(--bv-bg);
    border-radius: 4px;
    word-break: break-all;
}
.bv-info__refdes {
    font-family: var(--bv-mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--bv-accent);
}
.bv-info__layer-top { color: var(--bv-top); }
.bv-info__layer-bot { color: var(--bv-bot); }

/* Net pin list */
.bv-info__net-link {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    margin: 0.15rem 0.1rem;
    background: var(--bv-bg3);
    border: 1px solid var(--bv-border);
    border-radius: 3px;
    font-family: var(--bv-mono);
    font-size: 0.7rem;
    color: var(--bv-text);
    cursor: pointer;
    transition: all 0.15s;
}
.bv-info__net-link:hover { border-color: var(--bv-accent); color: var(--bv-accent); }
.bv-info__net-btn {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    margin-top: 0.25rem;
    background: var(--bv-accent-dim);
    border: 1px solid var(--bv-accent);
    border-radius: 4px;
    font-family: var(--bv-mono);
    font-size: 0.72rem;
    color: var(--bv-accent);
    cursor: pointer;
    transition: opacity 0.15s;
}
.bv-info__net-btn:hover { opacity: 0.7; }

/* Pin table */
.bv-info__pin-table {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 0.2rem;
    border: 1px solid var(--bv-border);
    border-radius: 4px;
}
.bv-info__pin-row {
    display: flex;
    padding: 0.15rem 0.4rem;
    font-family: var(--bv-mono);
    font-size: 0.68rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    transition: background 0.1s;
}
.bv-info__pin-row:hover {
    background: rgba(255,255,255,0.06);
}
.bv-info__pin-row:last-child { border-bottom: none; }
.bv-info__pin-num {
    width: 2.5rem;
    flex-shrink: 0;
    color: var(--bv-text-muted);
    font-weight: 600;
}
.bv-info__pin-net {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--bv-text);
}
.bv-info__pin-row--has-net .bv-info__pin-net {
    color: var(--bv-accent);
}

/* Compact row: value + package side by side */
.bv-info__row {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
}
.bv-info__row .bv-info__cell {
    flex: 1;
    min-width: 0;
}
.bv-info__cell-label {
    font-size: 0.6rem;
    color: var(--bv-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.15rem;
}
.bv-info__cell-value {
    font-family: var(--bv-mono);
    font-size: 0.78rem;
    color: var(--bv-text-bright);
    padding: 0.2rem 0.4rem;
    background: var(--bv-bg);
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Net list tab === */
.bv-net-list__search-wrap {
    margin-bottom: 0.5rem;
}
.bv-net-list__search {
    width: 100%;
    background: var(--bv-bg);
    border: 1px solid var(--bv-border);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    font-family: var(--bv-mono);
    font-size: 0.72rem;
    color: var(--bv-text);
    outline: none;
    box-sizing: border-box;
}
.bv-net-list__search:focus {
    border-color: var(--bv-accent);
}
.bv-net-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.bv-net-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0.45rem;
    background: var(--bv-bg);
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.12s;
    font-family: var(--bv-mono);
    font-size: 0.7rem;
    color: var(--bv-text);
}
.bv-net-list__item:hover {
    background: var(--bv-bg3);
    color: var(--bv-accent);
}
.bv-net-list__item.active {
    background: var(--bv-accent-dim);
    color: var(--bv-accent);
}
.bv-net-list__item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.bv-net-list__item-count {
    font-size: 0.6rem;
    color: var(--bv-text-muted);
    margin-left: 0.4rem;
    flex-shrink: 0;
}
.bv-net-list__stats {
    font-size: 0.65rem;
    color: var(--bv-text-muted);
    padding: 0.3rem 0;
    margin-bottom: 0.3rem;
}

/* === Status bar === */
.bv-status-bar {
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    height: 26px;
    background: var(--bv-bg2);
    border-top: 1px solid var(--bv-border);
    font-family: var(--bv-mono);
    font-size: 0.68rem;
    color: var(--bv-text-muted);
    gap: 1.5rem;
    flex-shrink: 0;
    overflow: hidden;
}
.bv-status-bar__item--file {
    margin-left: auto;
    color: var(--bv-accent);
    opacity: 0.7;
}

/* === File modal === */
.bv-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.bv-modal {
    background: var(--bv-bg2);
    border: 1px solid var(--bv-border);
    border-radius: 10px;
    width: 90%; max-width: 640px;
    max-height: 80vh;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.bv-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bv-border);
}
.bv-modal__header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--bv-text-bright);
    margin: 0;
}
.bv-modal__close {
    background: none; border: none;
    color: var(--bv-text-muted);
    cursor: pointer;
    font-size: 1rem;
}
.bv-modal__close:hover { color: var(--bv-text); }
.bv-modal__body { flex: 1; overflow-y: auto; padding: 0.75rem 1rem; }
.bv-modal__search-wrap {
    position: relative;
    margin-bottom: 0.75rem;
}
.bv-modal__search-wrap i {
    position: absolute; left: 0.6rem; top: 50%; transform: translateY(-50%);
    color: var(--bv-text-muted); font-size: 0.72rem;
}
.bv-modal__search {
    width: 100%; box-sizing: border-box;
    padding: 0.45rem 0.5rem 0.45rem 1.8rem;
    background: var(--bv-bg);
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius);
    color: var(--bv-text);
    font-family: var(--bv-mono);
    font-size: 0.78rem;
    outline: none;
}
.bv-modal__search:focus { border-color: var(--bv-accent); }

/* Tabs */
.bv-modal__tabs {
    display: flex; gap: 0.25rem;
    margin-bottom: 0.75rem;
}
.bv-modal__tab {
    padding: 0.35rem 0.75rem;
    background: transparent;
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius);
    color: var(--bv-text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}
.bv-modal__tab.active { background: var(--bv-accent-dim); border-color: var(--bv-accent); color: var(--bv-accent); }
.bv-modal__tab-content { display: none; }
.bv-modal__tab-content.active { display: block; }

/* File list */
.bv-file-list {
    max-height: 400px;
    overflow-y: auto;
}
.bv-file-list__loading {
    display: flex; align-items: center; gap: 0.5rem;
    justify-content: center;
    padding: 2rem;
    color: var(--bv-text-muted);
    font-size: 0.82rem;
}
.bv-file-list__category {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bv-accent);
    padding: 0.5rem 0.4rem 0.25rem;
    border-bottom: 1px solid var(--bv-border);
    margin-top: 0.5rem;
}
.bv-file-list__category:first-child { margin-top: 0; }
.bv-file-list__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 0.78rem;
}
.bv-file-list__item:hover { background: var(--bv-bg3); }
.bv-file-list__item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--bv-mono);
    font-size: 0.72rem;
    color: var(--bv-text);
}
.bv-file-list__item-ext {
    font-family: var(--bv-mono);
    font-size: 0.62rem;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 600;
}
.bv-file-list__item-ext--cad { background: rgba(34,170,102,0.15); color: var(--bv-top); }
.bv-file-list__item-ext--brd { background: rgba(204,68,68,0.15); color: var(--bv-bot); }
.bv-file-list__item-ext--fz { background: rgba(180,120,255,0.15); color: #b478ff; }
.bv-file-list__item-ext--other { background: rgba(100,100,120,0.15); color: var(--bv-text-muted); }
/* Category filter bar */
.bv-file-category-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.5rem 0.4rem;
    border-bottom: 1px solid var(--bv-border);
}
.bv-file-category-btn {
    font-family: var(--bv-mono);
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    border: 1px solid var(--bv-border);
    background: transparent;
    color: var(--bv-text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.bv-file-category-btn:hover { border-color: var(--bv-accent); color: var(--bv-text); }
.bv-file-category-btn.active { background: var(--bv-accent); color: #000; border-color: var(--bv-accent); font-weight: 600; }
.bv-file-category-btn--parseable { border-color: rgba(34,170,102,0.4); color: var(--bv-top); }
.bv-file-category-btn--parseable.active { background: var(--bv-top); color: #000; border-color: var(--bv-top); }
.bv-file-list__item-size {
    font-family: var(--bv-mono);
    font-size: 0.62rem;
    color: var(--bv-text-muted);
    white-space: nowrap;
}
.bv-file-list__item--disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Local upload */
.bv-local-upload {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--bv-border);
    border-radius: 8px;
    text-align: center;
    color: var(--bv-text-muted);
    transition: border-color 0.2s;
}
.bv-local-upload:hover { border-color: var(--bv-accent); }
.bv-local-upload i { font-size: 2rem; margin-bottom: 0.75rem; opacity: 0.4; }
.bv-local-upload p { font-size: 0.82rem; margin: 0 0 0.5rem; }
.bv-local-upload__formats { font-size: 0.7rem !important; color: var(--bv-text-muted); }

/* === Scrollbar === */
.bv-info-panel__content::-webkit-scrollbar,
.bv-file-list::-webkit-scrollbar {
    width: 5px;
}
.bv-info-panel__content::-webkit-scrollbar-track,
.bv-file-list::-webkit-scrollbar-track {
    background: transparent;
}
.bv-info-panel__content::-webkit-scrollbar-thumb,
.bv-file-list::-webkit-scrollbar-thumb {
    background: var(--bv-border);
    border-radius: 3px;
}

/* === Responsive === */
@media (max-width: 768px) {
    .bv-toolbar__btn-text { display: none; }
    .bv-search-input { width: 140px; }
    .bv-info-panel {
        position: absolute;
        right: 0; top: 0; bottom: 0;
        z-index: 20;
        box-shadow: -4px 0 20px rgba(0,0,0,0.4);
    }
    .bv-info-panel.hidden {
        margin-right: -280px;
    }
    .bv-status-bar { gap: 0.75rem; font-size: 0.6rem; }
}
@media (max-width: 480px) {
    .bv-search-wrap { display: none; }
    .bv-info-panel { width: 240px; }
    .bv-info-panel.hidden { margin-right: -240px; }
}

/* When PIN gate is active, prevent body scroll */
body:has(.bv-pin-gate) {
    overflow: hidden;
}
