/* ==========================================================================
   SG Directory — Front-end styles
   ========================================================================== */

.sg-directory-wrap {
	--sg-primary: #2563eb;
	--sg-primary-dark: #1d4ed8;
	--sg-border: #e2e8f0;
	--sg-text: #1e293b;
	--sg-muted: #64748b;
	--sg-bg-card: #ffffff;
	--sg-radius: 10px;
	box-sizing: border-box;
	color: var(--sg-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.sg-directory-wrap *,
.sg-directory-wrap *::before,
.sg-directory-wrap *::after {
	box-sizing: border-box;
}

/* ---- Toolbar ---- */
.sg-directory-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	margin-bottom: 20px;
	/* Some page builders (Elementor containers, etc.) default their flex
	   children to align-items: stretch and can pass a tall row/min-height
	   down to us. Refuse to inherit that -- every toolbar child sizes to
	   its own content, never to the parent row's height. */
	align-items: flex-start;
}

.sg-directory-toolbar > * {
	align-self: flex-start;
}

.sg-directory-search,
.sg-directory-category-filter {
	padding: 10px 14px;
	border: 1px solid var(--sg-border);
	border-radius: 8px;
	font-size: 14px;
	background: #fff;
	height: 42px !important;
	max-height: 42px !important;
	min-height: 0 !important;
	box-sizing: border-box !important;
	-webkit-appearance: none;
	appearance: none;
	line-height: normal;
}

.sg-directory-search {
	flex: 1 1 240px;
	min-width: 180px;
}

.sg-directory-category-filter {
	flex: 0 1 220px;
}

.sg-directory-active-toggle {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
	color: var(--sg-muted);
	white-space: nowrap;
	align-self: center;
}

.sg-directory-btn {
	padding: 10px 18px;
	border: none;
	border-radius: 8px;
	background: var(--sg-primary);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease;
	white-space: nowrap;
	height: 42px !important;
	min-height: 0 !important;
	box-sizing: border-box !important;
	align-self: center;
}

.sg-directory-btn:hover {
	background: var(--sg-primary-dark);
}

.sg-directory-status {
	min-height: 20px;
	margin-bottom: 12px;
	color: var(--sg-muted);
	font-size: 14px;
}

/* ---- Grid ---- */
.sg-directory-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 20px;
}

.sg-directory-card {
	background: var(--sg-bg-card);
	border: 1px solid var(--sg-border);
	border-radius: var(--sg-radius);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.sg-directory-card:hover {
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
	transform: translateY(-2px);
}

/* Ad sizes control how many grid columns a card spans.
   1 = full width row, 0.5 = half (2 of 4 cols), 0.25 = one column (default),
   text = one column, no image -- a compact plain-text listing. */
.sg-directory-card[data-ad-size="1"] {
	grid-column: 1 / -1;
	flex-direction: row;
}

.sg-directory-card[data-ad-size="1"] .sg-directory-card-media {
	width: 40%;
	flex-shrink: 0;
}

.sg-directory-card[data-ad-size="1"] .sg-directory-card-body {
	flex: 1;
}

.sg-directory-card[data-ad-size="0.5"] {
	grid-column: span 2;
}

.sg-directory-card[data-ad-size="0.25"],
.sg-directory-card[data-ad-size="text"] {
	grid-column: span 1;
}

.sg-directory-card-text-only {
	border-style: dashed;
	background: #fafafa;
}

.sg-directory-card-text-only .sg-directory-card-body {
	padding-top: 18px;
}

.sg-directory-card-media {
	position: relative;
	aspect-ratio: 16 / 10;
	background: #f1f5f9;
	overflow: hidden;
	cursor: zoom-in;
}

.sg-directory-card-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.sg-directory-card-media.sg-no-image::after {
	content: "\1F3E2"; /* office building emoji as a placeholder icon */
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	font-size: 42px;
	opacity: 0.35;
}

.sg-directory-card-body {
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	flex: 1;
}

.sg-directory-card-category {
	display: inline-block;
	align-self: flex-start;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--sg-primary);
	background: rgba(37, 99, 235, 0.08);
	padding: 3px 8px;
	border-radius: 999px;
}

.sg-directory-card-title {
	font-size: 17px;
	font-weight: 700;
	margin: 0;
	color: var(--sg-text);
}

.sg-directory-card-meta {
	font-size: 13px;
	color: var(--sg-muted);
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.sg-directory-card-about {
	font-size: 13px;
	color: var(--sg-text);
	margin: 4px 0 0;
	line-height: 1.5;
}

.sg-directory-card-footer {
	margin-top: auto;
	padding-top: 10px;
	display: flex;
	gap: 10px;
}

.sg-directory-card-footer a {
	font-size: 13px;
	font-weight: 600;
	color: var(--sg-primary);
	text-decoration: none;
}

.sg-directory-card-footer a:hover {
	text-decoration: underline;
}

.sg-directory-empty {
	grid-column: 1 / -1;
	text-align: center;
	padding: 48px 16px;
	color: var(--sg-muted);
}

/* ---- Lightbox ---- */
.sg-directory-lightbox {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.9);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100000;
	padding: 24px;
}

.sg-directory-lightbox[hidden] {
	display: none;
}

.sg-directory-lightbox-img {
	max-width: 100%;
	max-height: 90vh;
	border-radius: 6px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.sg-directory-lightbox-close {
	position: absolute;
	top: 20px;
	right: 24px;
	background: transparent;
	border: none;
	color: #fff;
	font-size: 36px;
	line-height: 1;
	cursor: pointer;
}

/* ---- Modal ---- */
.sg-directory-modal {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	display: flex;
	align-items: flex-start;
	justify-content: center;
	overflow-y: auto;
	z-index: 100000;
	padding: 40px 16px;
}

.sg-directory-modal[hidden] {
	display: none;
}

.sg-directory-modal-inner {
	background: #fff;
	border-radius: 12px;
	width: 100%;
	max-width: 560px;
	padding: 28px;
	position: relative;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.sg-directory-modal-inner h2 {
	margin-top: 0;
}

.sg-directory-modal-close {
	position: absolute;
	top: 14px;
	right: 18px;
	background: transparent;
	border: none;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	color: var(--sg-muted);
}

.sg-directory-form-row {
	margin-bottom: 14px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.sg-directory-form-row label {
	font-size: 13px;
	font-weight: 600;
	color: var(--sg-text);
}

.sg-directory-form-row input[type="text"],
.sg-directory-form-row input[type="file"],
.sg-directory-form-row select,
.sg-directory-form-row textarea {
	padding: 9px 12px;
	border: 1px solid var(--sg-border);
	border-radius: 8px;
	font-size: 14px;
	width: 100%;
	font-family: inherit;
}

.sg-directory-form-actions {
	margin-top: 8px;
}

.sg-directory-form-message {
	margin-top: 10px;
	font-size: 14px;
}

.sg-directory-form-message.is-success {
	color: #15803d;
}

.sg-directory-form-message.is-error {
	color: #b91c1c;
}

/* Honeypot: visually hidden but present in the DOM/tab order-free for bots. */
.sg-directory-hp-field {
	position: absolute;
	left: -9999px;
	top: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ---- Standalone submission page ([sg_directory_submit]) ---- */
.sg-directory-standalone-wrap {
	max-width: 640px;
	margin: 0 auto;
}

.sg-directory-standalone-title {
	margin-top: 0;
	font-size: 26px;
}

.sg-directory-standalone-intro {
	color: var(--sg-muted);
	margin-bottom: 24px;
}

.sg-directory-standalone-form {
	background: var(--sg-bg-card);
	border: 1px solid var(--sg-border);
	border-radius: var(--sg-radius);
	padding: 28px;
}

.sg-directory-image-preview {
	margin-top: 10px;
}

.sg-directory-image-preview img {
	max-width: 100%;
	max-height: 220px;
	border-radius: 8px;
	display: block;
	border: 1px solid var(--sg-border);
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
	.sg-directory-grid {
		grid-template-columns: repeat(2, 1fr);
	}
	.sg-directory-card[data-ad-size="0.5"],
	.sg-directory-card[data-ad-size="0.25"],
	.sg-directory-card[data-ad-size="text"] {
		grid-column: span 1;
	}
	.sg-directory-card[data-ad-size="1"] {
		grid-column: 1 / -1;
	}
}

@media (max-width: 640px) {
	.sg-directory-grid {
		grid-template-columns: 1fr;
	}
	.sg-directory-card[data-ad-size="1"],
	.sg-directory-card[data-ad-size="0.5"],
	.sg-directory-card[data-ad-size="0.25"],
	.sg-directory-card[data-ad-size="text"] {
		grid-column: 1 / -1;
	}
	.sg-directory-card[data-ad-size="1"] {
		flex-direction: column;
	}
	.sg-directory-card[data-ad-size="1"] .sg-directory-card-media {
		width: 100%;
	}
	.sg-directory-toolbar {
		flex-direction: column;
		align-items: stretch;
	}
	.sg-directory-search,
	.sg-directory-category-filter,
	.sg-directory-btn {
		width: 100%;
	}
	.sg-directory-standalone-form {
		padding: 18px;
	}
}
