/* byteworkz/sheet.css — byteSheet spreadsheet styles. */

.sheet-shell {
    display: flex; flex-direction: column;
    height: 100%; overflow: hidden;
}

.sheet-formula-bar {
    display: flex; align-items: center;
    gap: 6px; padding: 4px 10px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
}
.sheet-formula-bar .cell-ref-label {
    font-family: var(--mono); font-size: 12px;
    background: var(--surface);
    padding: 4px 8px; border-radius: var(--radius);
    border: 1px solid var(--border);
    min-width: 70px; text-align: center;
}
.sheet-formula-bar input[type="text"] {
    flex: 1;
    height: 26px; padding: 0 8px;
    background: var(--bg); color: var(--fg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--mono); font-size: 13px;
}
.sheet-formula-bar input:focus { border-color: var(--accent); outline: none; }

.sheet-grid-wrap {
    flex: 1; min-height: 0;
    overflow: auto;
    background: var(--bg-2);
    position: relative;
}

.sheet-grid {
    border-collapse: separate;
    border-spacing: 0;
    font-family: var(--mono);
    font-size: 12px;
    table-layout: fixed;
}
.sheet-grid th, .sheet-grid td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 0;
    margin: 0;
    height: 22px;
    box-sizing: border-box;
}
.sheet-grid th {
    background: var(--surface);
    color: var(--fg-muted);
    font-weight: 500;
    text-align: center;
    user-select: none;
    cursor: pointer;
    position: sticky;
    top: 0; z-index: 2;
    min-width: 32px;
}
.sheet-grid th.sheet-corner {
    left: 0; z-index: 3;
    min-width: 36px; width: 36px;
}
.sheet-grid th.row-head {
    position: sticky; left: 0; z-index: 1;
    min-width: 36px; width: 36px;
    background: var(--surface);
}
.sheet-grid td {
    width: 92px;
    background: var(--bg);
    color: var(--fg);
    padding: 2px 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: cell;
    line-height: 18px;
    vertical-align: middle;
}
.sheet-grid td.sel {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    z-index: 1;
}
.sheet-grid td.in-range {
    background: var(--accent-dim);
}
.sheet-grid td.has-error {
    color: var(--danger);
}
.sheet-grid td.is-number { text-align: right; }
.sheet-grid td.is-bold   { font-weight: 700; }
.sheet-grid td.is-italic { font-style: italic; }
.sheet-grid td.al-l { text-align: left; }
.sheet-grid td.al-c { text-align: center; }
.sheet-grid td.al-r { text-align: right; }

.sheet-grid .cell-editor {
    width: 100%; height: 100%;
    border: 0; padding: 1px 5px;
    background: var(--bg-2);
    color: var(--fg);
    font: inherit; font-family: var(--mono);
    outline: 2px solid var(--accent);
    box-sizing: border-box;
}

/* Sheet tabs bar at bottom */
.sheet-tabs {
    display: flex; align-items: center;
    background: var(--surface);
    border-top: 1px solid var(--border);
    min-height: 28px;
    overflow-x: auto;
}
.sheet-tab {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px;
    border-right: 1px solid var(--border-soft);
    color: var(--fg-muted);
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    user-select: none;
}
.sheet-tab:hover { background: var(--surface-2); color: var(--fg); }
.sheet-tab.active { background: var(--bg); color: var(--fg); border-top: 2px solid var(--accent); }
.sheet-tab-add {
    background: transparent; border: 0; color: var(--fg-muted);
    padding: 0 12px; cursor: pointer; font-size: 16px;
}
.sheet-tab-add:hover { color: var(--accent); }

/* Charts overlay layer */
.chart-layer {
    position: absolute;
    top: 0; left: 0;
    pointer-events: none;
}
.chart-box {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    pointer-events: auto;
    display: flex; flex-direction: column;
}
.chart-box .chart-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 8px; font-size: 11px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    cursor: move;
    user-select: none;
}
.chart-box .chart-head .chart-close {
    background: transparent; border: 0; color: var(--fg-muted);
    cursor: pointer; padding: 0 4px;
}
.chart-box canvas { flex: 1; display: block; }

/* Filter dropdown */
.filter-popover {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    max-height: 280px;
    overflow: auto;
    min-width: 180px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.filter-popover label {
    display: flex; align-items: center; gap: 6px;
    padding: 3px 6px; cursor: pointer; font-size: 12px;
}
.filter-popover label:hover { background: var(--surface-2); }
.filter-popover .filter-actions {
    display: flex; gap: 6px; padding: 6px 4px 2px;
    border-top: 1px solid var(--border-soft);
    margin-top: 4px;
}
