/*
 * SheetMirror for Google Sheets — Frontend Styles
 */

/* ---- Wrapper / scroll container ---- */
/* display:block and overflow-x:auto need !important to override themes
   (e.g. Cocoon) that impose conflicting styles on block-level elements. */
.sheetmirror-wrap {
	display: block !important;
	overflow-x: auto !important;
	-webkit-overflow-scrolling: touch;
	margin: 1.5em 0;
	max-width: 100%;
}

/* ---- Table base ---- */
.sheetmirror-wrap .sheetmirror-table {
	border-collapse: separate;
	border-spacing: 0;
	width: 100%;
	font-size: 0.9em;
}

/* ---- Hard reset: prevent theme styles from bleeding in ---- */
.sheetmirror-wrap .sheetmirror-table,
.sheetmirror-wrap .sheetmirror-table thead,
.sheetmirror-wrap .sheetmirror-table tbody,
.sheetmirror-wrap .sheetmirror-table tr,
.sheetmirror-wrap .sheetmirror-table tr:nth-child(even),
.sheetmirror-wrap .sheetmirror-table tr:nth-child(odd),
.sheetmirror-wrap .sheetmirror-table td,
.sheetmirror-wrap .sheetmirror-table th {
	border: none;
	background: transparent;
	color: inherit;
}

/* ---- Cell defaults ---- */
.sheetmirror-wrap .sheetmirror-table td,
.sheetmirror-wrap .sheetmirror-table th {
	padding: 6px 12px;
	text-align: left;
	vertical-align: middle;
	box-sizing: border-box;
	line-height: 1.3;
}

/* Reset theme height for CSV and Auto modes only. */
.sheetmirror-wrap .sheetmirror-table--csv td,
.sheetmirror-wrap .sheetmirror-table--csv th,
.sheetmirror-wrap .sheetmirror-table--auto td,
.sheetmirror-wrap .sheetmirror-table--auto th {
	height: auto !important;
	min-height: 0 !important;
}

/* ---- Fixed mode — API ---- */
.sheetmirror-wrap .sheetmirror-table--fixed.sheetmirror-table--api {
	width: max-content !important;
	min-width: 0 !important;
	table-layout: fixed;
}
.sheetmirror-wrap .sheetmirror-table--fixed.sheetmirror-table--api td,
.sheetmirror-wrap .sheetmirror-table--fixed.sheetmirror-table--api th {
	overflow: hidden;
}

/* ---- Fixed mode — CSV ---- */
.sheetmirror-wrap .sheetmirror-table--fixed.sheetmirror-table--csv {
	width: 100% !important;
	table-layout: fixed;
}
.sheetmirror-wrap .sheetmirror-table--fixed.sheetmirror-table--csv td,
.sheetmirror-wrap .sheetmirror-table--fixed.sheetmirror-table--csv th {
	white-space: normal;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

/* ---- Auto mode ---- */
.sheetmirror-wrap .sheetmirror-table--auto {
	width: max-content !important;
	min-width: 0 !important;
	table-layout: auto !important;
	display: table !important;
}
.sheetmirror-wrap .sheetmirror-table--auto col {
	width: auto !important;
	min-width: 0 !important;
	max-width: none !important;
}
.sheetmirror-wrap .sheetmirror-table--auto td,
.sheetmirror-wrap .sheetmirror-table--auto th {
	width: auto !important;
	white-space: normal !important;
	overflow-wrap: break-word;
}

/* ================================================================
   HEADER ROW
   ================================================================ */

/* CSV mode: uniform header style */
.sheetmirror-wrap .sheetmirror-table--bordered.sheetmirror-table--csv.sheetmirror-table--has-header thead th {
	font-weight: 700 !important;
	text-align: center !important;
	border-bottom: 2px solid #9ca3af !important;
}

/* API mode: per-cell inline styles handle borders; just enforce font/align */
.sheetmirror-wrap .sheetmirror-table--bordered.sheetmirror-table--api.sheetmirror-table--has-header thead th,
.sheetmirror-wrap .sheetmirror-table:not(.sheetmirror-table--bordered).sheetmirror-table--has-header thead th {
	font-weight: 700 !important;
	text-align: center !important;
}

/* ================================================================
   BORDERS — CSV mode only
   ================================================================ */
.sheetmirror-wrap .sheetmirror-table--bordered.sheetmirror-table--csv {
	border: 1px solid #d1d5db;
}
.sheetmirror-wrap .sheetmirror-table--bordered.sheetmirror-table--csv td,
.sheetmirror-wrap .sheetmirror-table--bordered.sheetmirror-table--csv th {
	border-top:  1px solid #d1d5db;
	border-left: 1px solid #d1d5db;
}
.sheetmirror-wrap .sheetmirror-table--bordered.sheetmirror-table--csv tr:last-child td,
.sheetmirror-wrap .sheetmirror-table--bordered.sheetmirror-table--csv tr:last-child th {
	border-bottom: 1px solid #d1d5db;
}
.sheetmirror-wrap .sheetmirror-table--bordered.sheetmirror-table--csv td:last-child,
.sheetmirror-wrap .sheetmirror-table--bordered.sheetmirror-table--csv th:last-child {
	border-right: 1px solid #d1d5db;
}

/* ---- Column type alignment (CSV mode) ---- */
.sheetmirror-wrap .sheetmirror-table td.col-text,
.sheetmirror-wrap .sheetmirror-table th.col-text {
	text-align: left !important;
}
.sheetmirror-wrap .sheetmirror-table td.col-num,
.sheetmirror-wrap .sheetmirror-table th.col-num {
	text-align: right !important;
	font-variant-numeric: tabular-nums;
}
.sheetmirror-wrap .sheetmirror-table td.col-bool,
.sheetmirror-wrap .sheetmirror-table th.col-bool {
	text-align: center !important;
}

/* ---- Error message ---- */
.sheetmirror-error {
	background: #fef2f2;
	border-left: 4px solid #dc2626;
	padding: 10px 14px;
	color: #7f1d1d;
	font-size: 0.9em;
	border-radius: 0 4px 4px 0;
}
