/**
 * Template Library Styles
 * Matches the Elementor-style Choose Template popup design.
 *
 * @package Softech_Addons_for_Elementor
 */

/* Overlay */
.sits-tpl-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.7);
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.sits-tpl-overlay--visible {
	opacity: 1;
}

/* Modal */
.sits-tpl-modal {
	background: #ffffff;
	width: 95%;
	max-width: 1100px;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
	overflow: hidden;
	transform: scale(0.97);
	transition: transform 0.3s ease;
}

.sits-tpl-overlay--visible .sits-tpl-modal {
	transform: scale(1);
}

/* Header – dark teal strip */
.sits-tpl-modal-header {
	padding: 10px 20px;
	background: #083d49;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
	gap: 16px;
}

.sits-tpl-modal-header-left {
	display: flex;
	align-items: center;
	gap: 14px;
}

.sits-tpl-modal-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22px;
	color: #ffffff;
	opacity: 0.85;
}

.sits-tpl-modal-title-wrap h2 {
	margin: 0;
	font-size: 17px;
	font-weight: 600;
	color: #ffffff;
}

.sits-tpl-modal-subtitle {
	margin: 4px 0 0;
	font-size: 12px;
	color: rgba(255, 255, 255, 0.65);
}

.sits-tpl-modal-close {
	background: transparent;
	border: none;
	font-size: 22px;
	line-height: 1;
	color: rgba(255, 255, 255, 0.8);
	cursor: pointer;
	padding: 4px;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 3px;
	transition: all 0.2s;
}

.sits-tpl-modal-close:hover {
	background: rgba(255, 255, 255, 0.15);
	color: #ffffff;
}

/* Body – light gray background */
.sits-tpl-modal-body {
	padding: 10px 30px;
	overflow-y: auto;
	flex: 1;
	background: #f0f0f1;
	min-height: 360px;
}

/* Loading */
.sits-tpl-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 80px 20px;
}

.sits-tpl-spinner {
	width: 38px;
	height: 38px;
	border: 3px solid rgba(0, 0, 0, 0.1);
	border-top-color: #083d49;
	border-radius: 50%;
	animation: sits-tpl-spin 0.7s linear infinite;
}

@keyframes sits-tpl-spin {
	to { transform: rotate(360deg); }
}

.sits-tpl-loading p {
	margin-top: 16px;
	color: #777;
	font-size: 13px;
}

/* Error */
.sits-tpl-error {
	text-align: center;
	padding: 60px 20px;
	color: #c0392b;
}

.sits-tpl-error p {
	margin: 0;
	font-size: 13px;
}

/* ── Type dropdown – in body, shown after templates load ── */
.sits-tpl-type-wrap {
	display: flex;
	align-items: center;
	margin-bottom: 16px;
	/* Extra bottom padding so open dropdown doesn't cover template cards */
	padding-bottom: 140px;
	margin-bottom: -124px; /* visual gap stays 16px; extra space reserved for dropdown */
}

.sits-tpl-type-select {
	background: #083d49;
	border: 1px solid rgba(255, 255, 255, 0.35);
	color: #ffffff;
	padding: 7px 32px 7px 12px;
	border-radius: 3px;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	outline: none;
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23ffffff' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
	background-color: #083d49;
	background-repeat: no-repeat;
	background-position: right 10px center;
	transition: background-color 0.2s, border-color 0.2s;
	min-width: 130px;
	/* Ensure dropdown sits above the grid */
	position: relative;
	z-index: 10;
}



.sits-tpl-type-select option {
	background: #083d49;
	color: #ffffff;
}

/* Template Grid – 3 columns by default */
.sits-tpl-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 20px;
	/* Push grid below dropdown options when open */
	position: relative;
	z-index: 1;
}

/* No-library wrapper for archive / single_page types.
   This is a FLEX container (not a grid) so the centred empty-state
   inside it is properly centred regardless of the grid CSS above. */
.sits-tpl-nolibrary-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 260px;
	padding: 20px 0;
}
/* The .sits-tpl-empty-state inside the no-library wrapper must also flex-center */
.sits-tpl-nolibrary-wrap .sits-tpl-empty-state {
	width: 100%;
}

/* Template Card */
.sits-tpl-card {
	background: #ffffff;
	border-radius: 4px;
	overflow: hidden;
	cursor: pointer;
	transition: box-shadow 0.25s ease, border-color 0.25s ease;
	border: 2px solid transparent;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.sits-tpl-card:hover {
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.sits-tpl-card--selected {
	border-color: #083d49;
}

.sits-tpl-card-preview {
	position: relative;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	background: #e8e8e8;
}

/* Image preview (replaces SVG) */
.sits-tpl-card-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

/* PRO label */
.sits-tpl-pro-label {
	position: absolute;
	top: 10px;
	right: 10px;
	background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
	color: #ffffff;
	padding: 4px 10px;
	border-radius: 3px;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	z-index: 10;
}

/* Hover overlay – darkens the preview */
.sits-tpl-card-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.45);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.sits-tpl-card:hover .sits-tpl-card-overlay {
	opacity: 1;
}

/* "Use This" button – shown on hover over card preview */
.sits-tpl-select-btn {
	background: #083d49;
	color: #ffffff;
	border: none;
	padding: 9px 22px;
	border-radius: 3px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s, box-shadow 0.2s;
	letter-spacing: 0.2px;
	min-width: 90px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
}

.sits-tpl-select-btn:hover:not(:disabled) {
	background: #0d5c61;
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

/* Checkmark badge on selected card */
.sits-tpl-card-check {
	display: none;
	position: absolute;
	top: 10px;
	right: 10px;
	width: 26px;
	height: 26px;
	background: #083d49;
	border-radius: 50%;
	align-items: center;
	justify-content: center;
	z-index: 15;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.sits-tpl-card-check::after {
	content: '';
	display: block;
	width: 11px;
	height: 6px;
	border-left: 2px solid #ffffff;
	border-bottom: 2px solid #ffffff;
	transform: rotate(-45deg) translateY(-1px);
}

.sits-tpl-card--selected .sits-tpl-card-check {
	display: flex;
}

/* Card info */
.sits-tpl-card-info {
	padding: 13px 16px 15px;
	background: #ffffff;
}

.sits-tpl-card-title {
	margin: 0 0 3px;
	font-size: 14px;
	font-weight: 600;
	color: #1e2a32;
}

.sits-tpl-card-desc {
	margin: 0;
	font-size: 11.5px;
	color: #777;
	line-height: 1.45;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Footer */
.sits-tpl-modal-footer {
	padding: 10px 20px;
	background: #ffffff;
	border-top: 1px solid #e0e0e0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
	min-height: 40px;
}

.sits-tpl-selected-label {
	font-size: 13px;
	color: #083d49;
}

.sits-tpl-selected-label strong {
	color: #083d49;
	font-weight: 600;
}

.sits-tpl-footer-actions {
	display: flex;
	align-items: center;
	gap: 10px;
}

.sits-tpl-btn {
	padding: 10px 20px;
	border-radius: 3px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
	border: 1px solid transparent;
	letter-spacing: 0.1px;
	display: inline-flex;
	align-items: center;
	gap: 7px;
}

/* Skip – dark filled */
.sits-tpl-skip-btn {
	background: #083d49;
	color: #ffffff;
	border-color: #ffffff;
}

.sits-tpl-skip-btn:hover:not(:disabled) {
	background: #e4e4e4;
	color: #083d49;
	border-color: #083d49;
}

/* Insert – dark filled */
.sits-tpl-insert-btn {
	background: #083d49;
	color: #ffffff;
	border-color: #ffffff;
}

.sits-tpl-insert-btn .sits-tpl-btn-check {
	display: none;
	font-size: 15px;
	line-height: 1;
}

.sits-tpl-insert-btn.sits-tpl-insert-btn--ready .sits-tpl-btn-check {
	display: inline;
}

.sits-tpl-insert-btn:hover:not(:disabled) {
	background: #0d5c61;
}

.sits-tpl-insert-btn:disabled {
	background: #c0c0c0;
	border-color: #c0c0c0;
	color: rgba(255, 255, 255, 0.7);
	cursor: not-allowed;
}

/* ── Button loading / spinner state ── */
.sits-tpl-btn--loading {
	cursor: not-allowed;
	opacity: 0.85;
}

/* Inline button spinner */
.sits-tpl-btn-spinner {
	display: inline-block;
	width: 14px;
	height: 14px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #ffffff;
	border-radius: 50%;
	animation: sits-tpl-spin 0.65s linear infinite;
	flex-shrink: 0;
}

/* Dark spinner variant (for light backgrounds) */
.sits-tpl-skip-btn .sits-tpl-btn-spinner {
	border-color: rgba(255, 255, 255, 0.4);
	border-top-color: #ffffff;
}

/* Responsive */
@media (max-width: 1000px) {
	.sits-tpl-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 640px) {
	.sits-tpl-modal {
		width: 98%;
		max-height: 98vh;
	}

	.sits-tpl-grid {
		grid-template-columns: 1fr;
	}

	.sits-tpl-modal-header {
		padding-left: 16px;
		padding-right: 16px;
		flex-wrap: wrap;
	}

	.sits-tpl-type-wrap {
		width: 100%;
		margin-left: 0;
	}

	.sits-tpl-type-select {
		width: 100%;
	}

	.sits-tpl-modal-body,
	.sits-tpl-modal-footer {
		padding-left: 16px;
		padding-right: 16px;
	}

	.sits-tpl-modal-footer {
		flex-direction: column;
		gap: 10px;
		align-items: stretch;
	}

	.sits-tpl-footer-actions {
		flex-direction: column;
	}

	.sits-tpl-btn {
		width: 100%;
		justify-content: center;
	}
}

/* ============================================================
   TEMPLATE LIBRARY — EMPTY STATE
   ============================================================ */

.sits-tpl-empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 50px 20px;
	text-align: center;
}

.sits-tpl-empty-icon {
	width: 120px;
	height: 120px;
	margin-bottom: 20px;
	opacity: 0.7;
}

.sits-tpl-empty-state h3 {
	font-size: 20px;
	font-weight: 600;
	color: #2d4a54;
	margin: 0 0 10px;
}

.sits-tpl-empty-state p {
	font-size: 13px;
	color: #7a9099;
	margin: 0 0 24px;
	max-width: 380px;
	line-height: 1.7;
}

.sits-tpl-empty-state .sits-tpl-skip-btn {
	display: inline-block;
	padding: 9px 22px;
	background: linear-gradient(45deg, #1c718a -10%, #103d4a 50.71%);
	color: #fff;
	border: 1px solid #0f3d4a;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: opacity 0.15s;
}
.sits-tpl-empty-state .sits-tpl-skip-btn:hover { opacity: 0.88; }

/* Create Template button — archive / single_page footer */
.sits-tpl-create-blank-btn {
	background: linear-gradient(45deg, #1c718a -10%, #103d4a 50.71%) !important;
	color: #fff !important;
	border: 1px solid #0f3d4a !important;
	border-radius: 6px !important;
	padding: 9px 26px !important;
	font-size: 13px !important;
	font-weight: 600 !important;
	cursor: pointer;
	transition: opacity 0.15s;
}
.sits-tpl-create-blank-btn:hover { opacity: 0.88; }
