/* Path: assets/css/datasheet-cells.css */
/*
 * Filevue Data Sheet — cell layer (Excel-like grid)
 * ---------------------------------------------------------------------------
 * Scoped exclusively under .filevue-datasheet-modal (admin + client dashboard).
 * Modal chrome (toolbar, tabs, overlay shell) stays in admin/frontend-spreadsheet.css.
 *
 * Cell model:
 * - Every data/header/index cell is locked to 22px height (fixed + auto-width).
 * - Auto-width toggles table-layout:auto on the modal via .auto-width-enabled only.
 * - Column widths expand from cell content; JS may set width (px) after resize, never height.
 * - Inputs/spans sit inside the cell box (no sizer elements, no JS height injection).
 */

/* ── Table wrapper: scroll in both axes (never compress columns to viewport) ─ */
.filevue-datasheet-modal .filevue-datasheet-table-wrapper,
.filevue-datasheet-modal .scp-ss-table-wrap,
.filevue-datasheet-modal .scp-fe-ss-table-wrap {
	overflow-x: auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	width: 100%;
}

/* Mobile: 44px tap band via wrapper padding (cell height stays 22px) */
@media (max-width: 600px) {
	.filevue-datasheet-modal .filevue-datasheet-table-wrapper,
	.filevue-datasheet-modal .scp-ss-table-wrap,
	.filevue-datasheet-modal .scp-fe-ss-table-wrap {
		padding-top: 11px;
		padding-bottom: 11px;
	}
}

/* ── Table shell ─────────────────────────────────────────────────────────── */
.filevue-datasheet-modal .scp-ss-table,
.filevue-datasheet-modal .scp-fe-ss-table,
.filevue-datasheet-modal table {
	border-collapse: collapse;
	border-spacing: 0;
	table-layout: fixed;
	width: max-content;
	min-width: 100%;
	font-size: 13px;
	font-family: Calibri, 'Segoe UI', Arial, sans-serif;
	box-sizing: border-box;
}

.filevue-datasheet-modal .scp-ss-table,
.filevue-datasheet-modal .scp-fe-ss-table,
.filevue-datasheet-modal .scp-ss-table *,
.filevue-datasheet-modal .scp-fe-ss-table * {
	box-sizing: border-box;
}

/* Auto Width: horizontal sizing from content — heights unchanged */
.filevue-datasheet-modal.auto-width-enabled .scp-ss-table,
.filevue-datasheet-modal.auto-width-enabled .scp-fe-ss-table,
.filevue-datasheet-modal.auto-width-enabled table,
.filevue-datasheet-modal .scp-ss-table-wrap--auto .scp-ss-table,
.filevue-datasheet-modal .scp-fe-ss-table-wrap--auto .scp-fe-ss-table {
	table-layout: auto;
	width: max-content;
	min-width: 100%;
}

/* Auto Width: release fixed column widths so the browser can measure content */
.filevue-datasheet-modal.auto-width-enabled th,
.filevue-datasheet-modal.auto-width-enabled td,
.filevue-datasheet-modal .scp-ss-table-wrap--auto th,
.filevue-datasheet-modal .scp-ss-table-wrap--auto td,
.filevue-datasheet-modal .scp-fe-ss-table-wrap--auto th,
.filevue-datasheet-modal .scp-fe-ss-table-wrap--auto td {
	width: auto !important; /* beats inline width from fixed-mode resize/colgroup */
	min-width: 60px;
	max-width: none !important;
	overflow: visible;
	text-overflow: clip;
}

.filevue-datasheet-modal.auto-width-enabled .scp-ss-rownum,
.filevue-datasheet-modal.auto-width-enabled .scp-fe-ss-rownum,
.filevue-datasheet-modal .scp-ss-table-wrap--auto .scp-ss-rownum,
.filevue-datasheet-modal .scp-fe-ss-table-wrap--auto .scp-fe-ss-rownum {
	width: 46px !important;
	min-width: 46px !important;
	max-width: 46px !important;
	overflow: hidden;
	text-overflow: ellipsis;
}

.filevue-datasheet-modal.auto-width-enabled .scp-ss-cell-input,
.filevue-datasheet-modal.auto-width-enabled .scp-ss-col-input,
.filevue-datasheet-modal .scp-ss-table-wrap--auto .scp-ss-cell-input,
.filevue-datasheet-modal .scp-ss-table-wrap--auto .scp-ss-col-input {
	width: auto !important; /* 100% width prevents content-driven column measure */
	min-width: 100%;
	max-width: none !important;
	overflow: visible !important;
	text-overflow: clip !important;
}

.filevue-datasheet-modal.auto-width-enabled .scp-fe-ss-cell,
.filevue-datasheet-modal.auto-width-enabled .scp-fe-ss-col-name,
.filevue-datasheet-modal .scp-fe-ss-table-wrap--auto .scp-fe-ss-cell,
.filevue-datasheet-modal .scp-fe-ss-table-wrap--auto .scp-fe-ss-col-name {
	width: auto !important;
	min-width: 100%;
	max-width: none !important;
	overflow: visible !important;
	text-overflow: clip !important;
}

/* ── Base cell (all td/th) ───────────────────────────────────────────────── */
.filevue-datasheet-modal td,
.filevue-datasheet-modal th {
	padding: 3px 8px;
	height: 22px;
	min-height: 22px;
	max-height: 22px;
	line-height: 1.35;
	font-size: 13px;
	font-family: Calibri, 'Segoe UI', Arial, sans-serif;
	vertical-align: middle;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	box-sizing: border-box;
	border: 1px solid #d0d0d0;
	background-color: #ffffff;
	color: #1a1a1a;
	position: relative;
}

/* Fixed mode: explicit widths come from <colgroup>, not equal % split */
.filevue-datasheet-modal:not(.auto-width-enabled):not(.scp-ss-table-wrap--auto):not(.scp-fe-ss-table-wrap--auto) col.scp-ss-col-data {
	width: 120px;
}

.filevue-datasheet-modal:not(.auto-width-enabled) th:not(.scp-ss-rownum):not(.scp-fe-ss-rownum),
.filevue-datasheet-modal:not(.auto-width-enabled) td:not(.scp-ss-rownum):not(.scp-fe-ss-rownum) {
	min-width: 0;
}

/* WP 6.7+ admin bleeds min-height on inputs/tables — scoped overrides */
.filevue-datasheet-modal .scp-ss-table tr,
.filevue-datasheet-modal .scp-fe-ss-table tr {
	height: 22px;
	min-height: 22px;
	max-height: 22px;
}

.filevue-datasheet-modal.auto-width-enabled td,
.filevue-datasheet-modal.auto-width-enabled th,
.filevue-datasheet-modal .scp-ss-table-wrap--auto td,
.filevue-datasheet-modal .scp-ss-table-wrap--auto th,
.filevue-datasheet-modal .scp-fe-ss-table-wrap--auto td,
.filevue-datasheet-modal .scp-fe-ss-table-wrap--auto th {
	height: 22px;
	min-height: 22px;
	max-height: 22px;
	padding: 3px 8px;
	line-height: 1.35;
}

/* ── Header rows ─────────────────────────────────────────────────────────── */
.filevue-datasheet-modal thead th {
	background-color: #f2f2f2;
	font-weight: 600;
	color: #333333;
	border-bottom: 2px solid #bdbdbd;
	user-select: none;
}

/* Admin: column index row (1, 2, 3…) */
.filevue-datasheet-modal .scp-ss-colnum-row th {
	background-color: #e8e8e8;
	color: #666666;
	font-size: 11px;
	font-weight: 600;
	padding: 3px 6px;
	z-index: 4;
}

.filevue-datasheet-modal .scp-ss-colnum-row th {
	position: sticky;
	top: 0;
}

/* Admin: column name row */
.filevue-datasheet-modal .scp-ss-colname-row th {
	background-color: #f2f2f2;
	z-index: 3;
}

.filevue-datasheet-modal .scp-ss-colname-row th {
	position: sticky;
	top: 22px;
}

/* Frontend: single header row */
.filevue-datasheet-modal .scp-fe-ss-table thead th {
	position: sticky;
	top: 0;
	z-index: 2;
	background-color: #f2f2f2;
}

/* ── Row / column index cells ────────────────────────────────────────────── */
.filevue-datasheet-modal .scp-ss-rownum,
.filevue-datasheet-modal .scp-fe-ss-rownum {
	width: 46px;
	min-width: 46px;
	max-width: 46px;
	text-align: center;
	font-size: 11px;
	font-weight: 600;
	color: #666666;
	background-color: #f2f2f2 !important;
	user-select: none;
	cursor: default;
	padding: 3px 4px;
}

.filevue-datasheet-modal .scp-ss-colnum {
	text-align: center;
	cursor: default;
}

/* ── Zebra + hover (Excel-like) ──────────────────────────────────────────── */
.filevue-datasheet-modal tbody tr:nth-child(even) td:not(.scp-ss-rownum):not(.scp-fe-ss-rownum) {
	background-color: #fafafa;
}

.filevue-datasheet-modal tbody tr:hover td:not(.scp-ss-rownum):not(.scp-fe-ss-rownum) {
	background-color: #e8f0fe;
}

/* ── In-cell editors (admin) ─────────────────────────────────────────────── */
.filevue-datasheet-modal .scp-ss-cell-input,
.filevue-datasheet-modal .scp-ss-col-input {
	display: block;
	width: 100%;
	height: 16px;
	max-height: 16px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: none;
	border-radius: 0;
	box-shadow: none;
	outline: none;
	background: transparent;
	font-size: 13px;
	font-family: inherit;
	line-height: 1.35;
	color: #1a1a1a;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* WP 6.7+: block ~32px min-height on admin text inputs */
.filevue-datasheet-modal .scp-ss-table input[type="text"],
.filevue-datasheet-modal .scp-ss-table input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]) {
	min-height: 0 !important;
	height: 16px !important;
	max-height: 16px !important;
	line-height: 1.35 !important;
	padding: 0 !important;
	margin: 0 !important;
	font-size: 13px !important;
	box-sizing: border-box !important;
}

.filevue-datasheet-modal .scp-ss-col-input {
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.3px;
	color: #333333;
}

.filevue-datasheet-modal .scp-ss-col-input:focus {
	background: #ffffff;
	text-transform: none;
	font-weight: 500;
	box-shadow: inset 0 0 0 2px var(--scp-primary, #1570ef);
}

.filevue-datasheet-modal .scp-ss-cell-input:focus {
	background: #e8f0fe;
	box-shadow: inset 0 0 0 2px var(--scp-primary, #1570ef);
}

.filevue-datasheet-modal .scp-ss-cell-input.scp-ss-cell-link {
	color: #1570ef !important;
	text-decoration: underline !important;
}

/* ── Read-only cell content (frontend) ───────────────────────────────────── */
.filevue-datasheet-modal .scp-fe-ss-cell,
.filevue-datasheet-modal .scp-fe-ss-col-name {
	display: block;
	width: 100%;
	height: 16px;
	max-height: 16px;
	line-height: 1.35;
	font-size: 13px;
	padding: 0;
	margin: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	background: transparent;
}

.filevue-datasheet-modal .scp-fe-ss-col-name {
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.3px;
	color: #333333;
}

.filevue-datasheet-modal .scp-fe-ss-link {
	color: #1570ef !important;
	text-decoration: underline !important;
}

/* ── Cell utilities (admin): links, delete, resize ───────────────────────── */
.filevue-datasheet-modal .scp-ss-cell-td {
	padding: 3px 8px;
}

.filevue-datasheet-modal .scp-ss-cell-link-go {
	position: absolute;
	right: 2px;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 14px;
	height: 14px;
	background: #fff;
	border: 1px solid #d0d0d0;
	border-radius: 3px;
	color: #1570ef;
	z-index: 5;
	text-decoration: none !important;
}

.filevue-datasheet-modal .scp-ss-row-del,
.filevue-datasheet-modal .scp-ss-col-del {
	display: none;
	position: absolute;
	inset: 0;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #999;
	background: inherit;
	z-index: 2;
}

.filevue-datasheet-modal .scp-ss-colnum:hover .scp-ss-col-del,
.filevue-datasheet-modal tbody tr:hover .scp-ss-row-del {
	display: flex;
}

.filevue-datasheet-modal .scp-ss-row-del:hover,
.filevue-datasheet-modal .scp-ss-col-del:hover {
	color: #b42318;
}

/* Row height is locked — disable row resize affordance */
.filevue-datasheet-modal .scp-ss-row-resize {
	display: none !important;
}

.filevue-datasheet-modal .scp-ss-col-resize {
	position: absolute;
	top: 0;
	right: -2px;
	width: 5px;
	height: 100%;
	cursor: col-resize;
	z-index: 4;
	background: transparent;
}

.filevue-datasheet-modal .scp-ss-col-resize:hover,
.filevue-datasheet-modal .scp-ss-col-resize:active {
	background: var(--scp-primary, #1570ef);
	opacity: 0.35;
}

.filevue-datasheet-modal.auto-width-enabled .scp-ss-col-resize {
	display: none;
}

/* ── Tablet (601px–1024px) ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
	.filevue-datasheet-modal table {
		font-size: 12px;
	}

	.filevue-datasheet-modal td,
	.filevue-datasheet-modal th {
		padding: 3px 6px;
		font-size: 12px;
	}

	.filevue-datasheet-modal .scp-ss-cell-input,
	.filevue-datasheet-modal .scp-ss-col-input,
	.filevue-datasheet-modal .scp-fe-ss-cell,
	.filevue-datasheet-modal .scp-fe-ss-col-name {
		font-size: 12px;
	}
}

/* ── Mobile (320px–600px) ────────────────────────────────────────────────── */
@media (max-width: 600px) {
	.filevue-datasheet-modal table {
		font-size: 11px;
		min-width: 480px;
	}

	.filevue-datasheet-modal td,
	.filevue-datasheet-modal th {
		padding: 3px 5px;
		font-size: 11px;
	}

	.filevue-datasheet-modal .scp-ss-rownum,
	.filevue-datasheet-modal .scp-fe-ss-rownum {
		width: 32px;
		min-width: 32px;
		max-width: 32px;
		font-size: 11px;
	}

	.filevue-datasheet-modal .scp-ss-cell-input,
	.filevue-datasheet-modal .scp-ss-col-input,
	.filevue-datasheet-modal .scp-fe-ss-cell,
	.filevue-datasheet-modal .scp-fe-ss-col-name {
		font-size: 11px;
	}
}
