/* Smart Tables — адаптивные таблицы */

/* ---------- Базовые переменные (стиль «Чистый») ---------- */
.st-wrap {
	--st-accent: #2271b1;
	--st-bg: #fff;
	--st-color: inherit;
	--st-head-bg: #f6f7f9;
	--st-head-color: #1d2327;
	--st-border: #e2e5e9;
	--st-stripe: var(--st-bg);
	--st-hover: #f1f5fa;
	--st-hover: color-mix(in srgb, var(--st-accent) 7%, var(--st-bg));
	--st-label: #50575e;
	--st-radius: 8px;
	--st-card-radius: 8px;
	--st-card-shadow: none;
	--st-outer: 1px solid var(--st-border);
	--st-shadow: none;
	--st-pad: .7em 1em;
	--st-font: .95em;
	--st-shade: rgba(0, 0, 0, .16);
	--st-min-col: 7.5em;

	container: st / inline-size;
	position: relative;
	max-width: 100%;
	margin: 1.5em 0;
	clear: both;
}

/* Внутри блока «Таблица» Gutenberg отступы уже есть у figure */
.wp-block-table > .st-wrap { margin: 0; }
.wp-block-table:has(> .st-wrap) { overflow: visible; }

.st-wrap .st-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior-x: contain;
	border: var(--st-outer);
	border-radius: var(--st-radius);
	box-shadow: var(--st-shadow);
	background: var(--st-bg);
}
.st-wrap .st-scroll:focus { outline: none; }
.st-wrap .st-scroll:focus-visible { outline: 2px solid var(--st-accent); outline-offset: 2px; }

/* ---------- Таблица ---------- */
.st-wrap .st-scroll .st-table {
	width: 100%;
	min-width: 100%;
	margin: 0;
	border: 0;
	border-collapse: separate;
	border-spacing: 0;
	table-layout: auto;
	background: var(--st-bg);
	color: var(--st-color);
	font-size: var(--st-font);
	line-height: 1.45;
}

.st-wrap .st-table th,
.st-wrap .st-table td {
	padding: var(--st-pad);
	border: 0;
	border-bottom: 1px solid var(--st-border);
	text-align: left;
	vertical-align: top;
	background: none;
	/* не рвём слова по буквам: если не помещается — пусть листается */
	overflow-wrap: normal;
	word-break: normal;
	hyphens: manual;
	min-width: min(var(--st-min-col), 45cqw);
}

.st-wrap .st-table thead th {
	background: var(--st-head-bg);
	color: var(--st-head-color);
	font-weight: 600;
	vertical-align: bottom;
}

.st-wrap .st-table tbody th {
	font-weight: 600;
}

.st-wrap .st-table tbody tr:last-child > * ,
.st-wrap .st-table tfoot tr:last-child > * {
	border-bottom: 0;
}

.st-wrap .st-table tfoot td,
.st-wrap .st-table tfoot th {
	font-weight: 600;
	border-top: 2px solid var(--st-border);
}

.st-wrap .st-table caption {
	caption-side: top;
	padding: .75em 1em;
	text-align: left;
	font-weight: 600;
	color: inherit;
	background: var(--st-bg);
}

.st-wrap .st-val > :first-child { margin-top: 0; }
.st-wrap .st-val > :last-child  { margin-bottom: 0; }
.st-wrap .st-table img { max-width: none; height: auto; }

/* Строки: фон задаётся на tr, чтобы липкая колонка могла его унаследовать */
.st-wrap .st-scroll .st-table tbody tr { background: var(--st-bg); }
.st-wrap .st-scroll .st-table tbody tr:nth-child(even) { background: var(--st-stripe); }
.st-wrap.st-hover .st-scroll .st-table tbody tr:hover { background: var(--st-hover); }

/* ---------- Тени-подсказки прокрутки ---------- */
.st-wrap::before,
.st-wrap::after {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	width: 16px;
	pointer-events: none;
	opacity: 0;
	transition: opacity .2s ease;
	z-index: 4;
}
.st-wrap::before { left: 0;  background: linear-gradient(to right, var(--st-shade), transparent); border-radius: var(--st-radius) 0 0 var(--st-radius); }
.st-wrap::after  { right: 0; background: linear-gradient(to left,  var(--st-shade), transparent); border-radius: 0 var(--st-radius) var(--st-radius) 0; }
.st-wrap.st-can-left::before  { opacity: 1; }
.st-wrap.st-can-right::after  { opacity: 1; }

/* ---------- Фиксированная шапка ---------- */
.st-wrap.st-sticky-head .st-scroll {
	max-height: min(75vh, 720px);
	overflow: auto;
}
.st-wrap.st-sticky-head .st-table thead th {
	position: sticky;
	top: 0;
	z-index: 2;
}

/* ---------- Фиксированная первая колонка ---------- */
.st-wrap.st-sticky-col .st-table tr > :first-child {
	position: sticky;
	left: 0;
	z-index: 1;
	background-color: inherit;
	box-shadow: inset -1px 0 0 var(--st-border);
}
.st-wrap.st-sticky-col .st-table thead tr > :first-child {
	background: var(--st-head-bg);
	z-index: 3;
}

/* =========================================================
   Стили оформления
   ========================================================= */

/* Полосатый */
.st-style-striped {
	--st-head-bg: var(--st-accent);
	--st-head-color: #fff;
	--st-stripe: #f5f7fa;
	--st-border: #e6e9ee;
}

/* С рамками */
.st-style-bordered {
	--st-head-bg: #eef1f4;
	--st-border: #d5dae0;
	--st-radius: 4px;
	--st-card-radius: 4px;
}
.st-style-bordered .st-table th,
.st-style-bordered .st-table td { border-right: 1px solid var(--st-border); }
.st-style-bordered .st-table tr > :last-child { border-right: 0; }

/* Минимализм */
.st-style-minimal {
	--st-bg: #fff;
	--st-head-bg: #fff;
	--st-head-color: inherit;
	--st-outer: 0;
	--st-radius: 0;
	--st-border: #ececec;
	--st-pad: .75em .9em;
}
.st-style-minimal .st-table thead th {
	border-bottom: 2px solid var(--st-accent);
	font-size: .8em;
	letter-spacing: .04em;
	text-transform: uppercase;
}
.st-style-minimal .st-table th:first-child,
.st-style-minimal .st-table td:first-child { padding-left: 0; }
.st-style-minimal .st-table th:last-child,
.st-style-minimal .st-table td:last-child { padding-right: 0; }

/* Современный */
.st-style-modern {
	--st-head-bg: var(--st-accent);
	--st-head-color: #fff;
	--st-stripe: #f7f9fc;
	--st-stripe: color-mix(in srgb, var(--st-accent) 4%, #fff);
	--st-border: #edf0f4;
	--st-outer: 0;
	--st-radius: 12px;
	--st-card-radius: 12px;
	--st-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .08);
	--st-card-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
	--st-pad: .85em 1.15em;
}
.st-style-modern .st-table thead th { font-weight: 600; letter-spacing: .01em; }

/* Тёмный */
.st-style-dark {
	--st-bg: #1f2430;
	--st-color: #e6e8ec;
	--st-head-bg: #151922;
	--st-head-color: #fff;
	--st-border: #2f3644;
	--st-stripe: #232937;
	--st-hover: #2a3242;
	--st-hover: color-mix(in srgb, var(--st-accent) 18%, #1f2430);
	--st-label: #9aa3b2;
	--st-shade: rgba(0, 0, 0, .5);
}
.st-style-dark .st-table thead th { border-bottom: 2px solid var(--st-accent); }
.st-style-dark .st-table a { color: #8ab4ff; }

/* Компактный */
.st-style-compact {
	--st-head-bg: #f3f4f6;
	--st-border: #dfe3e8;
	--st-pad: .35em .65em;
	--st-font: .85em;
	--st-min-col: 5.5em;
	--st-radius: 4px;
	--st-card-radius: 4px;
	--st-stripe: #fafbfc;
}
.st-style-compact .st-table th,
.st-style-compact .st-table td { border-right: 1px solid var(--st-border); }
.st-style-compact .st-table tr > :last-child { border-right: 0; }

/* ---------- Печать ---------- */
@media print {
	.st-wrap .st-scroll { overflow: visible; max-height: none; box-shadow: none; }
	.st-wrap::before, .st-wrap::after { display: none; }
}
