/**
 * Advanced Post Views Manager - Public Styles
 *
 * @package    AdvancedPostViewsManager
 * @since      1.0.0
 */

/* ========================================
   Base Styles
   ======================================== */

.apvm-view-container {
	margin: 2rem 0;
	clear: both;
}

.apvm-view {
	margin: 2rem 0;
	clear: both;
}

.apvm-no-posts,
.apvm-error {
	padding: 2rem;
	text-align: center;
	background: #f8f9fa;
	border: 1px solid #dee2e6;
	border-radius: 4px;
	color: #6c757d;
}

.apvm-error {
	background: #f8d7da;
	border-color: #f5c2c7;
	color: #842029;
}

.apvm-error-message {
	padding: 2rem;
	text-align: center;
	background: #fff3cd;
	border: 1px solid #ffc107;
	border-radius: 4px;
	color: #856404;
}

/* ========================================
   Filter UI Styles
   ======================================== */

.apvm-filters {
	background: #fff;
	padding: 1.5rem;
	margin-bottom: 2rem;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.apvm-filters-row {
	display: flex;
	flex-wrap: wrap;
	gap: 1.5rem;
	align-items: flex-end;
}

.apvm-filter-item {
	flex: 1;
	min-width: 200px;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.apvm-filter-item label {
	font-weight: 500;
	color: #495057;
	font-size: 0.875rem;
}

.apvm-filter-category,
.apvm-search-input {
	padding: 0.625rem 1rem;
	border: 1px solid #ced4da;
	border-radius: 4px;
	font-size: 1rem;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
	background: #fff;
}

.apvm-filter-category:focus,
.apvm-search-input:focus {
	outline: none;
	border-color: #0d6efd;
	box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.apvm-search-form {
	display: block;
}

.apvm-search-input {
	width: 100%;
}

/* Loading State */
.apvm-posts-container {
	position: relative;
	min-height: 200px;
}

.apvm-posts-container.apvm-loading {
	opacity: 0.6;
	pointer-events: none;
}

.apvm-loading-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.8);
	z-index: 10;
}

.apvm-spinner {
	width: 40px;
	height: 40px;
	border: 4px solid #f3f3f3;
	border-top: 4px solid #0d6efd;
	border-radius: 50%;
	animation: apvm-spin 1s linear infinite;
}

@keyframes apvm-spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

/* ========================================
   Grid View
   ======================================== */

.apvm-grid-container {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 2rem;
	margin: 0;
	padding: 0;
}

.apvm-grid-item {
	background: #fff;
	border-radius: 8px;
	overflow: hidden;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	transition: transform 0.3s ease, box-shadow 0.3s ease;
	display: flex;
	flex-direction: column;
}

.apvm-grid-item:hover {
	transform: translateY(-4px);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.apvm-grid-item-thumbnail {
	width: 100%;
	height: 220px;
	overflow: hidden;
	position: relative;
	background: #f8f9fa;
}

.apvm-grid-item-thumbnail a {
	display: block;
	width: 100%;
	height: 100%;
}

.apvm-grid-item-thumbnail img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.3s ease;
}

.apvm-grid-item:hover .apvm-grid-item-thumbnail img {
	transform: scale(1.05);
}

.apvm-grid-item-content {
	padding: 1.5rem;
	flex: 1;
	display: flex;
	flex-direction: column;
}

.apvm-grid-item-title {
	margin: 0 0 1rem;
	font-size: 1.25rem;
	line-height: 1.4;
}

.apvm-grid-item-title a {
	color: #212529;
	text-decoration: none;
	transition: color 0.2s ease;
}

.apvm-grid-item-title a:hover {
	color: #0d6efd;
}

.apvm-grid-item-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	margin-bottom: 1rem;
	font-size: 0.875rem;
	color: #6c757d;
}

.apvm-grid-item-excerpt {
	flex: 1;
	margin-bottom: 1.5rem;
	color: #495057;
	line-height: 1.6;
}

.apvm-grid-item-link {
	display: inline-block;
	padding: 0.5rem 1.5rem;
	background: #0d6efd;
	color: #fff;
	text-decoration: none;
	border-radius: 4px;
	transition: background 0.2s ease;
	align-self: flex-start;
	font-weight: 500;
}

.apvm-grid-item-link:hover {
	background: #0b5ed7;
	color: #fff;
}

/* ========================================
   List View
   ======================================== */

.apvm-list-container {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

.apvm-list-item {
	display: flex;
	gap: 1.5rem;
	background: #fff;
	border-radius: 8px;
	overflow: hidden;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.apvm-list-item:hover {
	transform: translateX(4px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.apvm-list-item-thumbnail {
	flex-shrink: 0;
	width: 180px;
	height: 180px;
	overflow: hidden;
	background: #f8f9fa;
}

.apvm-list-item-thumbnail a {
	display: block;
	width: 100%;
	height: 100%;
}

.apvm-list-item-thumbnail img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.3s ease;
}

.apvm-list-item:hover .apvm-list-item-thumbnail img {
	transform: scale(1.1);
}

.apvm-list-item-content {
	flex: 1;
	padding: 1.5rem 1.5rem 1.5rem 0;
	display: flex;
	flex-direction: column;
}

.apvm-list-item-title {
	margin: 0 0 1rem;
	font-size: 1.5rem;
	line-height: 1.3;
}

.apvm-list-item-title a {
	color: #212529;
	text-decoration: none;
	transition: color 0.2s ease;
}

.apvm-list-item-title a:hover {
	color: #0d6efd;
}

.apvm-list-item-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 1.5rem;
	margin-bottom: 1rem;
	font-size: 0.875rem;
	color: #6c757d;
}

.apvm-list-item-meta span {
	display: flex;
	align-items: center;
	gap: 0.375rem;
}

.apvm-list-item-meta svg {
	flex-shrink: 0;
}

.apvm-list-item-excerpt {
	flex: 1;
	margin-bottom: 1.25rem;
	color: #495057;
	line-height: 1.6;
}

.apvm-list-item-link {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	color: #0d6efd;
	text-decoration: none;
	font-weight: 500;
	transition: gap 0.2s ease;
}

.apvm-list-item-link:hover {
	gap: 0.75rem;
	color: #0b5ed7;
}

.apvm-list-item-link svg {
	flex-shrink: 0;
}

/* ========================================
   Table View
   ======================================== */

.apvm-table-container {
	width: 100%;
	overflow-x: auto;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.apvm-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9375rem;
}

.apvm-table thead {
	background: #f8f9fa;
	border-bottom: 2px solid #dee2e6;
}

.apvm-table th {
	padding: 1rem;
	text-align: left;
	font-weight: 600;
	color: #212529;
	white-space: nowrap;
}

.apvm-table tbody tr {
	border-bottom: 1px solid #dee2e6;
	transition: background-color 0.2s ease;
}

.apvm-table tbody tr:hover {
	background-color: #f8f9fa;
}

.apvm-table tbody tr:last-child {
	border-bottom: none;
}

.apvm-table td {
	padding: 1rem;
	vertical-align: middle;
}

.apvm-table-col-thumbnail {
	width: 80px;
}

.apvm-table-thumbnail {
	display: block;
	border-radius: 4px;
}

.apvm-no-thumbnail {
	display: block;
	width: 60px;
	height: 60px;
	background: #f8f9fa;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #6c757d;
}

.apvm-table-title-link {
	color: #212529;
	text-decoration: none;
	font-weight: 500;
	transition: color 0.2s ease;
}

.apvm-table-title-link:hover {
	color: #0d6efd;
}

.apvm-table-col-author,
.apvm-table-col-date,
.apvm-table-col-category {
	color: #6c757d;
	white-space: nowrap;
}

/* ========================================
   Responsive Design
   ======================================== */

/* Tablets */
@media (max-width: 1024px) {
	.apvm-grid-container {
		grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
		gap: 1.5rem;
	}
}

@media (max-width: 768px) {
	/* Filters */
	.apvm-filters {
		padding: 1rem;
	}

	.apvm-filters-row {
		flex-direction: column;
		gap: 1rem;
	}

	.apvm-filter-item {
		min-width: 100%;
	}

	/* Grid View */
	.apvm-grid-container {
		grid-template-columns: 1fr;
		gap: 1.5rem;
	}

	.apvm-grid-item-thumbnail {
		height: 200px;
	}

	/* List View */
	.apvm-list-item {
		flex-direction: column;
	}

	.apvm-list-item-thumbnail {
		width: 100%;
		height: 220px;
	}

	.apvm-list-item-content {
		padding: 1.5rem;
	}

	.apvm-list-item-title {
		font-size: 1.25rem;
	}

	/* Table View - Card layout on mobile */
	.apvm-table {
		font-size: 0.875rem;
	}

	.apvm-table thead {
		display: none;
	}

	.apvm-table tbody tr {
		display: block;
		margin-bottom: 1rem;
		border: 1px solid #dee2e6;
		border-radius: 8px;
	}

	.apvm-table tbody tr:hover {
		background-color: #fff;
	}

	.apvm-table td {
		display: flex;
		justify-content: space-between;
		padding: 0.75rem 1rem;
		border-bottom: 1px solid #f8f9fa;
	}

	.apvm-table td:last-child {
		border-bottom: none;
	}

	.apvm-table td::before {
		content: attr(data-label);
		font-weight: 600;
		margin-right: 1rem;
	}

	.apvm-table-col-thumbnail {
		width: 100%;
		justify-content: center;
	}

	.apvm-table-col-thumbnail::before {
		display: none;
	}
}

/* Mobile */
@media (max-width: 480px) {
	.apvm-view {
		margin: 1rem 0;
	}

	.apvm-grid-item-content,
	.apvm-list-item-content {
		padding: 1rem;
	}

	.apvm-grid-item-title,
	.apvm-list-item-title {
		font-size: 1.125rem;
	}

	.apvm-grid-item-meta,
	.apvm-list-item-meta {
		gap: 0.75rem;
		font-size: 0.8125rem;
	}
}

/* ========================================
   Pagination Styles
   ======================================== */

.apvm-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	margin: 2rem 0;
	padding: 1rem 0;
}

.apvm-pagination-btn {
	min-width: 2.5rem;
	height: 2.5rem;
	padding: 0.5rem;
	border: 1px solid #dee2e6;
	background: #fff;
	color: #212529;
	font-size: 0.95rem;
	font-weight: 500;
	border-radius: 4px;
	cursor: pointer;
	transition: all 0.2s ease;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.apvm-pagination-btn:hover:not([disabled]) {
	background: #0d6efd;
	color: #fff;
	border-color: #0d6efd;
	transform: translateY(-2px);
	box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.apvm-pagination-btn:active:not([disabled]) {
	transform: translateY(0);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.apvm-pagination-btn.active {
	background: #0d6efd;
	color: #fff;
	border-color: #0d6efd;
	font-weight: 600;
	cursor: default;
}

.apvm-pagination-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
	background: #f8f9fa;
}

.apvm-pagination-prev,
.apvm-pagination-next {
	font-weight: 600;
	font-size: 1.2rem;
}

.apvm-pagination-ellipsis {
	padding: 0 0.25rem;
	color: #6c757d;
	font-weight: 600;
	user-select: none;
}

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Pagination with loading state */
.apvm-view-container.loading .apvm-pagination {
	pointer-events: none;
	opacity: 0.6;
}

/* Responsive pagination */
@media (max-width: 576px) {
	.apvm-pagination {
		gap: 0.25rem;
		flex-wrap: wrap;
	}

	.apvm-pagination-btn {
		min-width: 2.25rem;
		height: 2.25rem;
		font-size: 0.875rem;
	}

	.apvm-pagination-prev,
	.apvm-pagination-next {
		font-size: 1.1rem;
	}
}

/* ========================================
   Load More Button Styles
   ======================================== */

.apvm-load-more-wrapper {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1rem;
	margin: 2rem 0;
	padding: 1.5rem;
}

.apvm-load-more-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.875rem 2rem;
	background: #0d6efd;
	color: #fff;
	border: none;
	border-radius: 6px;
	font-size: 1rem;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.3s ease;
	box-shadow: 0 2px 8px rgba(13, 110, 253, 0.3);
	min-width: 150px;
}

.apvm-load-more-btn:hover:not(:disabled) {
	background: #0b5ed7;
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(13, 110, 253, 0.4);
}

.apvm-load-more-btn:active:not(:disabled) {
	transform: translateY(0);
	box-shadow: 0 2px 6px rgba(13, 110, 253, 0.3);
}

.apvm-load-more-btn:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

.apvm-load-more-spinner {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.apvm-load-more-spinner svg {
	animation: apvm-spin 1s linear infinite;
}

@keyframes apvm-spin {
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

.apvm-load-more-counter {
	margin: 0;
	color: #6c757d;
	font-size: 0.875rem;
	font-weight: 400;
}

.apvm-load-more-wrapper.apvm-all-loaded {
	padding: 1rem;
}

.apvm-load-more-message {
	margin: 0;
	color: #198754;
	font-weight: 500;
	font-size: 1rem;
	padding: 0.75rem 1.5rem;
	background: #d1e7dd;
	border-radius: 6px;
	border: 1px solid #badbcc;
}

/* Fade in animation for newly loaded posts */
@keyframes apvm-fade-in {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.apvm-grid-item,
.apvm-list-item,
.apvm-table-row {
	animation: apvm-fade-in 0.4s ease-out;
}

/* Responsive Load More */
@media (max-width: 576px) {
	.apvm-load-more-wrapper {
		padding: 1rem;
		margin: 1.5rem 0;
	}

	.apvm-load-more-btn {
		padding: 0.75rem 1.5rem;
		font-size: 0.9375rem;
		min-width: 130px;
	}

	.apvm-load-more-counter {
		font-size: 0.8125rem;
		text-align: center;
	}
}

/* ========================================
   Infinite Scroll Styles
   ======================================== */

/* Hide Load More button visually in infinite scroll mode (keeps it in DOM for observer) */
.apvm-view-container[data-pagination-type="infinite"] .apvm-load-more-btn {
	opacity: 0;
	pointer-events: none;
	height: 1px;
	min-height: 1px;
	padding: 0;
	margin: 0;
	overflow: hidden;
}

/* Keep the counter visible in infinite scroll */
.apvm-view-container[data-pagination-type="infinite"] .apvm-load-more-counter {
	text-align: center;
	margin-top: 1rem;
}

/* Infinite scroll loading indicator */
.apvm-view-container[data-pagination-type="infinite"] .apvm-load-more-wrapper {
	text-align: center;
}

/* Show subtle loading state for infinite scroll */
.apvm-view-container[data-pagination-type="infinite"] .apvm-load-more-btn[disabled] + .apvm-load-more-counter::after {
	content: "...";
	display: inline-block;
	animation: apvm-dots 1.5s infinite;
	margin-left: 0.25rem;
}

@keyframes apvm-dots {
	0%, 20% { content: "."; }
	40% { content: ".."; }
	60%, 100% { content: "..."; }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
	.apvm-grid-item,
	.apvm-list-item {
		box-shadow: none;
		border: 1px solid #dee2e6;
	}

	.apvm-grid-item-link,
	.apvm-list-item-link {
		display: none;
	}

	.apvm-table {
		font-size: 0.75rem;
	}

	.apvm-pagination,
	.apvm-load-more-wrapper {
		display: none;
	}
}
