/* ── Spreadsheets View ─────────────────────────────────────── */

.sheets-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.sheets-header-left h2 {
    font-size: 22px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sheets-header-left p {
    color: var(--text2);
    font-size: 13px;
}

.sheets-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 14px;
    min-height: calc(100vh - 200px);
}

/* ── Sidebar ────────────────────────────────────────────────── */

.sheets-sidebar {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    overflow-y: auto;
}

.sheets-sidebar-title {
    font-size: 11px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* ── Main Panel ─────────────────────────────────────────────── */

.sheets-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.sheets-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text3);
    font-size: 14px;
    text-align: center;
}

.sheets-empty-state i {
    font-size: 40px;
    opacity: 0.35;
}

/* ── Editor ─────────────────────────────────────────────────── */

.sheets-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.sheets-name-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg3);
    padding: 4px 8px 4px 0;
}

.sheets-title-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
    padding: 10px 16px;
    outline: none;
}

.sheets-status {
    font-size: 12px;
    color: var(--text3);
    white-space: nowrap;
    padding-right: 12px;
}

/* ── Toolbar ────────────────────────────────────────────────── */

.sheets-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    border-bottom: 1px solid var(--border);
    background: var(--bg3);
    padding: 8px 10px;
}

.sheets-font-family {
    max-width: 150px;
}

.sheets-border-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sheets-border-color-label {
    padding: 4px 5px;
}

/* ── Grid ───────────────────────────────────────────────────── */

.sheets-grid-wrap {
    flex: 1;
    overflow: auto;
    position: relative;
}

.sheets-table {
    border-collapse: collapse;
    table-layout: fixed;
    min-width: max-content;
    font-size: 13px;
}

/* Column headers */
.sheets-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--bg3);
    border: 1px solid var(--border);
    height: 28px;
    min-width: 100px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text3);
    text-align: center;
    user-select: none;
    white-space: nowrap;
}

.sheets-corner {
    position: sticky !important;
    left: 0;
    z-index: 5 !important;
    min-width: 42px !important;
    width: 42px !important;
    background: var(--bg3) !important;
}

/* Row number cells */
.sheets-row-num {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg3);
    border: 1px solid var(--border);
    width: 42px;
    min-width: 42px;
    height: 26px;
    font-size: 11px;
    color: var(--text3);
    text-align: center;
    user-select: none;
    padding: 0;
    vertical-align: middle;
}

/* Data cells */
.sheets-cell {
    border: 1px solid var(--border);
    padding: 0;
    height: 26px;
    min-width: 100px;
    vertical-align: middle;
    position: relative;
}

.sheets-cell-range {
    background: var(--primary-light, rgba(99, 102, 241, 0.08));
}

.sheets-cell-selected {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
    z-index: 1;
}

.sheets-cell-merged {
    background-clip: padding-box;
}

.sheets-cell-input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    padding: 0 6px;
    outline: none;
    box-sizing: border-box;
    min-width: 0;
}

.sheets-cell-input:focus {
    background: var(--primary-light, rgba(99, 102, 241, 0.06));
}

.sheets-col-header,
.sheets-row-num {
    position: relative;
}

.sheets-axis-selected {
    background: var(--primary-light, rgba(99, 102, 241, 0.12)) !important;
    color: var(--text) !important;
}

.sheets-col-resize-handle {
    position: absolute;
    top: 0;
    right: -3px;
    width: 7px;
    height: 100%;
    cursor: col-resize;
    z-index: 6;
}

.sheets-col-resize-handle:hover {
    background: rgba(99, 102, 241, 0.22);
}

.sheets-row-resize-handle {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -3px;
    height: 7px;
    cursor: row-resize;
    z-index: 6;
}

.sheets-row-resize-handle:hover {
    background: rgba(99, 102, 241, 0.22);
}

body.sheets-resizing,
body.sheets-resizing * {
    user-select: none !important;
}

@media (max-width: 900px) {
    .sheets-layout {
        grid-template-columns: 1fr;
    }

    .sheets-sidebar {
        max-height: 180px;
    }
}
