/* ==========================================================================
   SPREADSHEET GRID
   ========================================================================== */
.notion-grid-wrapper {
    flex: 1;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 250px);
    min-height: 220px;
}
.notion-grid-inner { overflow: auto; flex: 1; }

.notion-style-table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; font-size: 13px; }
.notion-style-table th {
    background: var(--surface-2);
    color: var(--ink-2);
    font-weight: 500;
    font-size: 12px;
    padding: 8px 12px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line-strong);
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
}
.notion-style-table th:last-child { border-right: none; }
.th-content { display: flex; align-items: center; gap: 8px; }
.th-content i { font-size: 10px; color: var(--ink-3); }
.th-content .sort-icon { margin-left: auto; color: var(--ink); }

.notion-style-table td {
    padding: 5px 12px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    height: 36px;
    vertical-align: middle;
    position: relative;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notion-style-table td:last-child { border-right: none; }
.notion-style-table tr { transition: background-color 0.1s ease; }
.notion-style-table tbody tr:hover { background: var(--surface-2); }

.action-cell { width: 44px; padding: 0 !important; text-align: center; }
.btn-cell-delete {
    background: none; border: none; color: var(--ink-3); cursor: pointer;
    width: 28px; height: 28px; border-radius: 6px; font-size: 12px; transition: var(--transition-fast);
}
.btn-cell-delete:hover { color: var(--danger-strong); background: var(--danger-soft); }
/* Deleting archived rows for good (admins only) */
.btn.btn-danger { color: var(--danger-strong); border-color: var(--danger); }
.btn.btn-danger:hover { background: var(--danger-soft); }

.checkbox-cell { width: 40px; text-align: center; padding: 4px !important; }
.row-selector { cursor: pointer; accent-color: var(--nml-deep); }
:root[data-theme="dark"] .row-selector { accent-color: var(--nml-electric); }

.grid-cell-value { width: 100%; height: 100%; display: flex; align-items: center; cursor: cell; }
.grid-cell-value.empty-cell { color: var(--ink-3); font-style: italic; }
.grid-cell-value.uuid { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); }
.grid-cell-value.rel-link { color: var(--link); }
.grid-cell-value.rel-link i { font-size: 10px; margin-right: 6px; color: var(--ink-3); }

.cell-editor, .cell-select-editor {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    border: 2px solid var(--focus);
    background: var(--surface);
    color: var(--ink);
    padding: 0 12px;
    outline: none;
    font-family: inherit; font-size: inherit;
    z-index: 5;
}
.cell-select-editor { padding: 0 8px; }
.cell-editor.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.badge-cell-type {
    display: inline-block; padding: 2px 9px; border-radius: 20px;
    font-size: 11.5px; font-weight: 500;
    background: var(--surface-3); color: var(--ink-2);
}
.badge-status-draft { background: var(--surface-3); color: var(--ink-2); }
.badge-status-published { background: var(--accent-soft); color: var(--ink); }
.badge-status-active, .badge-status-running { background: var(--ok-soft); color: var(--ink); }
.badge-status-completed { background: var(--nml-deep); color: #FFFFFF; }
:root[data-theme="dark"] .badge-status-completed { background: #FFFFFF; color: var(--nml-deep); }
.badge-status-failed { background: var(--danger-soft); color: var(--danger-strong); }
.badge-status-pending { background: var(--warn-soft); color: var(--ink); }

.grid-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 56px 20px; color: var(--ink-3); gap: 12px; text-align: center;
}
.grid-empty i { font-size: 32px; color: var(--line-strong); }
