/* =============================================================================
   ADPi Forms Viewer – stylesheet
   ============================================================================= */

/* Wrapper ------------------------------------------------------------------- */
.adpi-fv-wrapper {
	width: 100%;
	overflow-x: auto;
	margin: 1.25em 0;
	font-family: inherit;
}

/* Table -------------------------------------------------------------------- */
table.adpi-fv-table {
	width: 100% !important;
	border-collapse: collapse;
	font-size: 0.9em;
}

table.adpi-fv-table thead th {
	background-color: #2c3e50;
	color: #ffffff;
	padding: 10px 12px;
	text-align: left;
	white-space: nowrap;
}

table.adpi-fv-table thead th.sorting,
table.adpi-fv-table thead th.sorting_asc,
table.adpi-fv-table thead th.sorting_desc {
	cursor: pointer;
}

/* DataTables injects sort arrows via :before/:after on the first header row.
   Hide them from the filter row so only the label row gets sort arrows. */
table.adpi-fv-table thead tr.adpi-fv-filter-row th {
	background-color: #3d5166;
	padding: 6px 8px;
}

table.adpi-fv-table thead tr.adpi-fv-filter-row th::before,
table.adpi-fv-table thead tr.adpi-fv-filter-row th::after {
	display: none !important;
}

/* Per-column filter inputs -------------------------------------------------- */
.adpi-fv-col-filter {
	width: 100%;
	box-sizing: border-box;
	padding: 5px 7px;
	font-size: 0.85em;
	border: 1px solid #5a7a96;
	border-radius: 3px;
	background-color: #ffffff;
	color: #333;
	outline-offset: 1px;
}

.adpi-fv-col-filter:focus {
	border-color: #2980b9;
	outline: 2px solid rgba(41, 128, 185, 0.35);
}

/* Body rows ----------------------------------------------------------------- */
table.adpi-fv-table tbody tr {
	border-bottom: 1px solid #e0e0e0;
	transition: background-color 0.1s ease;
}

table.adpi-fv-table tbody tr:nth-child(even) {
	background-color: #f7f9fb;
}

table.adpi-fv-table tbody tr:hover {
	background-color: #eaf3fb;
}

table.adpi-fv-table tbody td {
	padding: 9px 12px;
	vertical-align: top;
	word-break: break-word;
}

/* Footer ------------------------------------------------------------------- */
table.adpi-fv-table tfoot th {
	background-color: #2c3e50;
	color: #cccccc;
	padding: 8px 12px;
	font-weight: normal;
	font-size: 0.8em;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

/* DataTables controls layout ----------------------------------------------- */
/* DataTables wraps length, buttons, and search in .dataTables_wrapper.
   Override default layout for a cleaner look. */

div.dataTables_wrapper div.dataTables_length {
	float: none;
	display: inline-block;
	margin-bottom: 8px;
}

div.dataTables_wrapper div.dataTables_length label {
	font-size: 0.9em;
	white-space: nowrap;
}

div.dataTables_wrapper div.dataTables_length select {
	padding: 3px 6px;
	border: 1px solid #ccc;
	border-radius: 3px;
}

div.dataTables_wrapper div.dataTables_filter {
	float: none;
	display: inline-block;
	margin-bottom: 8px;
}

div.dataTables_wrapper div.dataTables_filter label {
	font-size: 0.9em;
	white-space: nowrap;
}

div.dataTables_wrapper div.dataTables_filter input {
	padding: 5px 8px;
	border: 1px solid #ccc;
	border-radius: 3px;
	margin-left: 6px;
}

/* Toolbar row (contains length chooser, export button, global search) ------- */
.adpi-fv-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 8px;
}

.adpi-fv-toolbar-left,
.adpi-fv-toolbar-right {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

/* Bottom bar (pagination + info) ------------------------------------------- */
.adpi-fv-bottom-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 8px;
}

/* DataTables dom overrides: the custom dom string places divs with these IDs */
div.dataTables_wrapper div.adpi-fv-dt-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px;
	padding: 6px 0 10px;
	border-bottom: 1px solid #e0e0e0;
	margin-bottom: 6px;
}

div.dataTables_wrapper div.adpi-fv-dt-bottom {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px;
	padding: 10px 0 4px;
	border-top: 1px solid #e0e0e0;
	margin-top: 6px;
}

/* DataTables pagination ---------------------------------------------------- */
div.dataTables_wrapper div.dataTables_paginate {
	text-align: right;
}

div.dataTables_wrapper div.dataTables_paginate ul.pagination {
	margin: 0;
}

div.dataTables_wrapper div.dataTables_info {
	font-size: 0.85em;
	color: #666;
	padding-top: 2px;
}

/* DataTables Buttons (Export CSV) ------------------------------------------ */
div.dataTables_wrapper div.dt-buttons {
	display: inline-block;
}

.dt-button {
	display: inline-block;
	padding: 6px 14px;
	font-size: 0.88em;
	font-weight: 600;
	color: #fff;
	background-color: #27ae60;
	border: none;
	border-radius: 3px;
	cursor: pointer;
	text-decoration: none;
	transition: background-color 0.15s ease;
}

.dt-button:hover,
.dt-button:focus {
	background-color: #219a52;
	color: #fff;
	outline: none;
}

.dt-button:active {
	background-color: #1a7a40;
}

/* Error notice ------------------------------------------------------------- */
.adpi-fv-error {
	padding: 10px 14px;
	border: 1px solid #c0392b;
	border-left-width: 4px;
	background-color: #fdf3f2;
	color: #c0392b;
	border-radius: 3px;
	font-size: 0.9em;
}

/* Responsive: shrink font on small screens ---------------------------------- */
@media screen and (max-width: 640px) {
	table.adpi-fv-table tbody td,
	table.adpi-fv-table thead th {
		font-size: 0.82em;
		padding: 7px 8px;
	}

	.adpi-fv-col-filter {
		font-size: 0.8em;
	}

	div.dataTables_wrapper div.adpi-fv-dt-top,
	div.dataTables_wrapper div.adpi-fv-dt-bottom {
		flex-direction: column;
		align-items: flex-start;
	}
}
