/**
 * DafinCore Frontend Shortcode Styles
 *
 * Styles for shortcode output scoped to the .dafin-frontend wrapper
 * class to avoid conflicts with theme styles. Includes list layouts
 * (grid, list, table), filter bar, pagination, loading state, and
 * responsive breakpoints.
 *
 * @package DafinCore
 * @since   1.0.0
 */

/* ==========================================================================
   Base wrapper
   ========================================================================== */

.dafin-frontend {
	position: relative;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
	font-size: 15px;
	line-height: 1.6;
	color: #1e1e2d;
	box-sizing: border-box;
}

.dafin-frontend *,
.dafin-frontend *::before,
.dafin-frontend *::after {
	box-sizing: border-box;
}

/* ==========================================================================
   Loading state
   ========================================================================== */

.dafin-frontend--loading {
	pointer-events: none;
}

.dafin-frontend--loading .dafin-frontend__list {
	opacity: 0.5;
	transition: opacity 0.2s ease;
}

.dafin-frontend__loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
	background: rgba(255, 255, 255, 0.6);
}

.dafin-frontend__spinner {
	display: block;
	width: 32px;
	height: 32px;
	border: 3px solid #e5e7eb;
	border-top-color: #3b82f6;
	border-radius: 50%;
	animation: dafin-spin 0.7s linear infinite;
}

@keyframes dafin-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ==========================================================================
   Filter bar (frontend context)
   ========================================================================== */

.dafin-frontend .dafin-filter-bar {
	background: #f9fafb;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	padding: 16px;
	margin-bottom: 20px;
}

.dafin-frontend .dafin-filter-form {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 12px;
}

.dafin-frontend .dafin-filter-fields {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	flex: 1;
}

.dafin-frontend .dafin-filter-field {
	min-width: 150px;
}

.dafin-frontend .dafin-filter-field label {
	display: block;
	margin-bottom: 4px;
	font-size: 13px;
	font-weight: 500;
	color: #374151;
}

.dafin-frontend .dafin-filter-field input,
.dafin-frontend .dafin-filter-field select {
	width: 100%;
	padding: 8px 12px;
	font-size: 14px;
	line-height: 1.5;
	color: #1e1e2d;
	background: #ffffff;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dafin-frontend .dafin-filter-field input:focus,
.dafin-frontend .dafin-filter-field select:focus {
	outline: none;
	border-color: #3b82f6;
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.dafin-frontend .dafin-filter-field select {
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	padding-right: 32px;
}

.dafin-frontend .dafin-filter-date-inputs {
	display: flex;
	align-items: center;
	gap: 6px;
}

.dafin-frontend .dafin-filter-date-separator {
	color: #9ca3af;
}

.dafin-frontend .dafin-filter-actions {
	display: flex;
	gap: 8px;
}

.dafin-frontend .dafin-filter-actions button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 8px 16px;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.4;
	border: 1px solid transparent;
	border-radius: 6px;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
	white-space: nowrap;
}

.dafin-frontend .dafin-filter-actions .dafin-btn--filter {
	background: #3b82f6;
	color: #ffffff;
	border-color: #3b82f6;
}

.dafin-frontend .dafin-filter-actions .dafin-btn--filter:hover {
	background: #2563eb;
	border-color: #2563eb;
}

.dafin-frontend .dafin-filter-actions .dafin-btn--reset {
	background: transparent;
	color: #6b7280;
	border-color: #d1d5db;
}

.dafin-frontend .dafin-filter-actions .dafin-btn--reset:hover {
	background: #f9fafb;
	color: #374151;
}

/* ==========================================================================
   List container
   ========================================================================== */

.dafin-frontend__list {
	transition: opacity 0.2s ease;
}

.dafin-frontend__empty {
	text-align: center;
	padding: 40px 20px;
	color: #6b7280;
	font-style: italic;
}

/* ==========================================================================
   Grid layout (.dafin-frontend--grid)
   ========================================================================== */

.dafin-frontend--grid .dafin-frontend__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 20px;
}

.dafin-frontend--grid .dafin-frontend__item {
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	padding: 20px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.dafin-frontend--grid .dafin-frontend__item:hover {
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
	transform: translateY(-1px);
}

.dafin-frontend--grid .dafin-frontend__item-title {
	font-size: 16px;
	font-weight: 600;
	margin: 0 0 8px;
	color: #1e1e2d;
}

.dafin-frontend--grid .dafin-frontend__item-title a {
	color: inherit;
	text-decoration: none;
}

.dafin-frontend--grid .dafin-frontend__item-title a:hover {
	color: #3b82f6;
}

.dafin-frontend--grid .dafin-frontend__item-meta {
	font-size: 13px;
	color: #6b7280;
	margin-bottom: 8px;
}

.dafin-frontend--grid .dafin-frontend__item-excerpt {
	font-size: 14px;
	color: #374151;
	line-height: 1.5;
}

.dafin-frontend--grid .dafin-frontend__item-image {
	width: 100%;
	height: 180px;
	object-fit: cover;
	border-radius: 6px;
	margin-bottom: 12px;
}

/* ==========================================================================
   List layout (.dafin-frontend--list)
   ========================================================================== */

.dafin-frontend--list .dafin-frontend__list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.dafin-frontend--list .dafin-frontend__item {
	display: flex;
	align-items: flex-start;
	gap: 16px;
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	padding: 16px 20px;
	transition: background 0.15s ease;
}

.dafin-frontend--list .dafin-frontend__item:hover {
	background: #f9fafb;
}

.dafin-frontend--list .dafin-frontend__item-image {
	width: 80px;
	height: 80px;
	object-fit: cover;
	border-radius: 6px;
	flex-shrink: 0;
}

.dafin-frontend--list .dafin-frontend__item-content {
	flex: 1;
	min-width: 0;
}

.dafin-frontend--list .dafin-frontend__item-title {
	font-size: 16px;
	font-weight: 600;
	margin: 0 0 4px;
	color: #1e1e2d;
}

.dafin-frontend--list .dafin-frontend__item-title a {
	color: inherit;
	text-decoration: none;
}

.dafin-frontend--list .dafin-frontend__item-title a:hover {
	color: #3b82f6;
}

.dafin-frontend--list .dafin-frontend__item-meta {
	font-size: 13px;
	color: #6b7280;
	margin-bottom: 6px;
}

.dafin-frontend--list .dafin-frontend__item-excerpt {
	font-size: 14px;
	color: #374151;
	line-height: 1.5;
}

/* ==========================================================================
   Table layout (.dafin-frontend--table)
   ========================================================================== */

.dafin-frontend--table .dafin-frontend__list {
	display: table;
	width: 100%;
	border-collapse: collapse;
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	overflow: hidden;
}

.dafin-frontend--table .dafin-frontend__list-header {
	display: table-header-group;
	background: #f9fafb;
}

.dafin-frontend--table .dafin-frontend__list-header .dafin-frontend__item {
	font-weight: 600;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: #6b7280;
	border-bottom: 1px solid #e5e7eb;
}

.dafin-frontend--table .dafin-frontend__item {
	display: table-row;
}

.dafin-frontend--table .dafin-frontend__item:hover {
	background: #f0f7ff;
}

.dafin-frontend--table .dafin-frontend__item-cell {
	display: table-cell;
	padding: 12px 16px;
	border-bottom: 1px solid #f3f4f6;
	vertical-align: middle;
	font-size: 14px;
	color: #374151;
}

.dafin-frontend--table .dafin-frontend__item:last-child .dafin-frontend__item-cell {
	border-bottom: none;
}

.dafin-frontend--table .dafin-frontend__item-cell a {
	color: #3b82f6;
	text-decoration: none;
}

.dafin-frontend--table .dafin-frontend__item-cell a:hover {
	color: #2563eb;
	text-decoration: underline;
}

/* ==========================================================================
   Pagination (frontend context)
   ========================================================================== */

.dafin-frontend .dafin-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	padding: 24px 0 8px;
}

.dafin-frontend .dafin-pagination__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding: 4px 10px;
	font-size: 14px;
	font-weight: 500;
	color: #374151;
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 6px;
	text-decoration: none;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.dafin-frontend .dafin-pagination__link:hover {
	background: #f3f4f6;
	border-color: #d1d5db;
	text-decoration: none;
	color: #1e1e2d;
}

.dafin-frontend .dafin-pagination__link--active {
	background: #3b82f6;
	border-color: #3b82f6;
	color: #ffffff;
}

.dafin-frontend .dafin-pagination__link--active:hover {
	background: #2563eb;
	color: #ffffff;
}

.dafin-frontend .dafin-pagination__link--disabled {
	color: #d1d5db;
	cursor: not-allowed;
	pointer-events: none;
}

.dafin-frontend .dafin-pagination__prev,
.dafin-frontend .dafin-pagination__next {
	padding: 4px 12px;
}

/* ==========================================================================
   Responsive breakpoints
   ========================================================================== */

@media (max-width: 768px) {
	/* Grid collapses to single column on mobile */
	.dafin-frontend--grid .dafin-frontend__list {
		grid-template-columns: 1fr;
	}

	/* List items stack vertically */
	.dafin-frontend--list .dafin-frontend__item {
		flex-direction: column;
		gap: 12px;
	}

	.dafin-frontend--list .dafin-frontend__item-image {
		width: 100%;
		height: 160px;
	}

	/* Table becomes scrollable */
	.dafin-frontend--table .dafin-frontend__list {
		display: block;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.dafin-frontend--table .dafin-frontend__list-header,
	.dafin-frontend--table .dafin-frontend__item {
		display: table-row;
	}

	.dafin-frontend--table .dafin-frontend__item-cell {
		display: table-cell;
		white-space: nowrap;
	}

	/* Filter bar stacks */
	.dafin-frontend .dafin-filter-form {
		flex-direction: column;
		align-items: stretch;
	}

	.dafin-frontend .dafin-filter-fields {
		flex-direction: column;
	}

	.dafin-frontend .dafin-filter-field {
		min-width: 0;
		width: 100%;
	}

	.dafin-frontend .dafin-filter-actions {
		justify-content: stretch;
	}

	.dafin-frontend .dafin-filter-actions button {
		flex: 1;
	}

	/* Pagination wraps */
	.dafin-frontend .dafin-pagination {
		flex-wrap: wrap;
	}
}

@media (max-width: 480px) {
	.dafin-frontend .dafin-filter-bar {
		padding: 12px;
	}

	.dafin-frontend--grid .dafin-frontend__item {
		padding: 16px;
	}

	.dafin-frontend--list .dafin-frontend__item {
		padding: 12px 16px;
	}

	.dafin-frontend .dafin-pagination__link {
		min-width: 32px;
		height: 32px;
		font-size: 13px;
	}
}

/* ==========================================================================
   Media Video — Grid Layout
   ========================================================================== */

.dafin-videos--grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 24px;
}

.dafin-videos--grid .dafin-videos__item {
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	overflow: hidden;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.dafin-videos--grid .dafin-videos__item:hover {
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
	transform: translateY(-2px);
}

.dafin-videos__thumb-link {
	display: block;
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: #1a1a2e;
}

.dafin-videos__thumb {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.3s ease;
}

.dafin-videos__item:hover .dafin-videos__thumb {
	transform: scale(1.03);
}

.dafin-videos__thumb-placeholder {
	display: block;
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, #1a1a2e, #16213e);
}

.dafin-videos__play-icon {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.dafin-videos__item:hover .dafin-videos__play-icon {
	opacity: 1;
}

.dafin-videos--grid .dafin-videos__info {
	padding: 16px 20px 20px;
}

.dafin-videos__title {
	font-size: 16px;
	font-weight: 600;
	margin: 0 0 8px;
	line-height: 1.4;
}

.dafin-videos__title a {
	color: #1e1e2d;
	text-decoration: none;
}

.dafin-videos__title a:hover {
	color: #3b82f6;
}

.dafin-videos__meta {
	display: flex;
	align-items: center;
	gap: 12px;
	font-size: 13px;
	color: #6b7280;
}

.dafin-videos__meta span + span::before {
	content: "·";
	margin-right: 12px;
}

.dafin-videos__excerpt {
	margin: 8px 0 0;
	font-size: 14px;
	color: #4b5563;
	line-height: 1.5;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ==========================================================================
   Media Video — List Layout
   ========================================================================== */

.dafin-videos--list {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.dafin-videos--list .dafin-videos__item {
	display: flex;
	gap: 20px;
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	padding: 16px;
	transition: background 0.15s ease;
}

.dafin-videos--list .dafin-videos__item:hover {
	background: #f9fafb;
}

.dafin-videos--list .dafin-videos__thumb-link {
	flex-shrink: 0;
	width: 200px;
	aspect-ratio: 16 / 9;
	border-radius: 8px;
}

.dafin-videos--list .dafin-videos__info {
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
}

/* ==========================================================================
   Media Video — Single Page
   ========================================================================== */

.dafin-video-single {
	max-width: 900px;
	margin: 0 auto;
	padding: 40px 20px;
}

.dafin-video-single__back {
	display: inline-block;
	margin-bottom: 20px;
	font-size: 14px;
	color: #6b7280;
	text-decoration: none;
}

.dafin-video-single__back:hover {
	color: #3b82f6;
}

.dafin-video-single__embed {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	margin-bottom: 24px;
	border-radius: 12px;
	overflow: hidden;
	background: #000;
}

.dafin-video-single__embed iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

.dafin-video-single__title {
	font-size: 28px;
	font-weight: 700;
	margin: 0 0 16px;
	color: #1e1e2d;
	line-height: 1.3;
}

.dafin-video-single__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	margin-bottom: 20px;
	font-size: 14px;
	color: #4b5563;
}

.dafin-video-single__meta-item strong {
	color: #1e1e2d;
}

.dafin-video-single__tags {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 20px;
}

.dafin-video-single__tag {
	display: inline-block;
	padding: 4px 12px;
	background: #f3f4f6;
	border-radius: 20px;
	font-size: 12px;
	color: #4b5563;
}

.dafin-video-single__description {
	font-size: 16px;
	line-height: 1.7;
	color: #374151;
}

/* ==========================================================================
   Media Video — Responsive
   ========================================================================== */

@media (max-width: 768px) {
	.dafin-videos--grid {
		grid-template-columns: 1fr;
	}

	.dafin-videos--list .dafin-videos__item {
		flex-direction: column;
	}

	.dafin-videos--list .dafin-videos__thumb-link {
		width: 100%;
	}

	.dafin-video-single__title {
		font-size: 22px;
	}

	.dafin-video-single__meta {
		flex-direction: column;
		gap: 8px;
	}
}
