/**
 * Taishan Theme Responsive Media Queries
 * 
 * Breakpoints: 1200px (Desktop Large), 1024px (Tablet Landscape), 768px (Tablet/Mobile), 576px (Mobile Portrait)
 */

/* ==========================================================================
   1. Large Screens & Laptops (< 1280px)
   ========================================================================== */
@media (max-width: 1280px) {
	.brands-grid-wrap {
		grid-template-columns: repeat(4, 1fr);
	}

	.products-grid {
		grid-template-columns: repeat(3, 1fr);
	}

	.footer-main-inner {
		grid-template-columns: auto 1fr 1fr 1fr 1fr;
		gap: 20px;
	}
}

/* ==========================================================================
   2. Tablets & Small Laptops (< 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
	/* Logo sizing */
	.header-logo .custom-logo {
		max-height: 48px;
		max-width: 210px;
	}

	.footer-col-logo .custom-logo {
		max-height: 44px;
		max-width: 200px;
	}

	/* Hero Section */
	.hero-grid-layout {
		grid-template-columns: 1fr;
	}

	.hero-topics-box {
		height: auto;
	}

	.hero-topics-list {
		max-height: 260px;
		overflow-y: auto;
	}

	.equipment-sidebar {
		display: none; /* Collapsed on mobile, accessible via navigation / menu */
	}

	.quick-access-bar {
		display: none; /* Mobile uses the hamburger drawer nav instead */
	}

	.hero-slider-container {
		min-height: 320px;
	}

	.hero-title {
		font-size: 26px;
	}

	.hero-subtitle {
		font-size: 14px;
	}

	/* Single Equipment Top Showcase */
	.equipment-showcase-top {
		grid-template-columns: 1fr;
		gap: 20px;
		padding: 20px;
	}

	/* Archive & Post Layouts */
	.archive-grid-layout,
	.post-layout-grid,
	.contact-page-grid {
		grid-template-columns: 1fr;
	}

	.archive-sidebar-col,
	.post-sidebar-col,
	.contact-info-col {
		order: 2;
	}

	.archive-content-col,
	.single-article,
	.page-article-box,
	.contact-form-col {
		order: 1;
	}

	/* Footer Main 4-Columns to 2x2 Grid */
	.footer-main-inner {
		grid-template-columns: 1fr 1fr;
		gap: 30px;
	}

	/* Trust Badges */
	.trust-badges-inner {
		grid-template-columns: 1fr;
		gap: 16px;
	}

	.trust-badge-item {
		border-right: none;
		border-bottom: 1px solid rgba(255, 255, 255, 0.2);
		padding-bottom: 14px;
	}

	.trust-badge-item:last-child {
		border-bottom: none;
		padding-bottom: 0;
	}
}

/* ==========================================================================
   3. Tablets Portrait & Mobile Devices (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
	/* Main Header — wraps to 2 rows here (logo/actions + full-width search), so it can't hold the fixed 72px desktop height */
	.main-header {
		height: auto;
		padding: 12px 0;
	}

	.main-header-inner {
		flex-wrap: wrap;
		gap: 12px;
	}

	.header-logo .custom-logo {
		max-height: 42px;
		max-width: 175px;
	}

	.footer-col-logo .custom-logo {
		max-height: 42px;
		max-width: 190px;
	}

	.header-search {
		order: 3;
		width: 100%;
		max-width: 100%;
	}

	.header-actions {
		gap: 10px;
	}

	.header-hotline {
		display: none;
	}

	.header-social-link {
		width: 36px;
		height: 36px;
	}

	.mobile-menu-toggle {
		display: flex;
	}

	/* Mobile Menu Drawer (Slide-out) */
	.main-navigation.nav-red {
		display: block !important;
		position: static;
		box-shadow: none;
		background: transparent;
	}

	.categories-dropdown-toggle {
		display: none;
	}

	.primary-nav-wrapper {
		position: fixed;
		top: 0;
		left: -300px;
		width: 300px;
		height: 100vh;
		background: #fff;
		box-shadow: 4px 0 25px rgba(0, 0, 0, 0.3);
		z-index: 99999;
		transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
		overflow-y: auto;
		display: flex;
		flex-direction: column;
	}

	.primary-nav-wrapper.mobile-menu-open {
		left: 0;
	}

	/* Drawer Header */
	.mobile-drawer-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 16px 20px;
		background-color: var(--ts-primary);
		color: #fff;
		border-bottom: 1px solid rgba(255, 255, 255, 0.15);
	}

	.mobile-drawer-title {
		font-size: 15px;
		font-weight: 800;
		letter-spacing: 0.5px;
	}

	.mobile-drawer-close {
		background: rgba(255, 255, 255, 0.2);
		border: none;
		color: #fff;
		width: 32px;
		height: 32px;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		cursor: pointer;
		transition: var(--ts-transition);
	}

	.mobile-drawer-close:hover {
		background: rgba(255, 255, 255, 0.35);
	}

	.primary-menu {
		flex-direction: column;
		align-items: stretch;
		height: auto;
		padding: 10px 0;
		flex: 1;
	}

	.primary-menu > li {
		height: auto;
		display: block;
		border-bottom: 1px solid var(--ts-border-light);
	}

	.primary-menu > li > a {
		padding: 12px 20px;
		color: var(--ts-text-main);
		font-size: 13.5px;
		justify-content: space-between;
	}

	.primary-menu > li:hover > a,
	.primary-menu > li.current-menu-item > a {
		background-color: var(--ts-primary-light);
		color: var(--ts-primary);
	}

	.primary-menu .sub-menu {
		position: static;
		box-shadow: none;
		border-top: none;
		background: #F8F9FA;
		opacity: 1;
		visibility: visible;
		transform: none;
		display: none;
		padding: 0;
	}

	.primary-menu .sub-menu.toggled-on {
		display: block;
	}

	.primary-menu .sub-menu li a {
		padding-left: 30px;
	}

	/* Drawer Footer */
	.mobile-drawer-footer {
		padding: 16px 20px;
		background: #F8F9FA;
		border-top: 1px solid var(--ts-border);
		margin-top: auto;
	}

	.mobile-drawer-hotline {
		display: flex;
		align-items: center;
		gap: 10px;
		color: var(--ts-primary);
		font-size: 13.5px;
	}

	/* Hero Slider & Card on Mobile */
	.hero-slider-container {
		min-height: 360px;
	}

	.hero-slide-item {
		padding: 20px 15px;
	}

	.hero-card-box {
		padding: 18px 20px;
		max-width: 100%;
	}

	.hero-card-title {
		font-size: 18px;
	}

	.hero-card-desc {
		font-size: 12.5px;
		-webkit-line-clamp: 2;
		margin-bottom: 15px;
	}

	.hero-card-actions {
		flex-direction: column;
		align-items: stretch;
		gap: 8px;
	}

	.hero-arrow-btn {
		display: none; /* Hide arrows on touch screens, use swipe or dots */
	}

	.hero-dots-indicator {
		right: 15px;
		bottom: 10px;
	}

	/* Hero Highlights */
	.hero-highlights-bar {
		grid-template-columns: 1fr;
		gap: 8px;
	}

	/* Hero Hot Topics */
	.hero-topics-header {
		padding: 10px 14px;
	}

	.hero-topic-link {
		padding: 10px 14px;
	}

	.hero-topics-list {
		max-height: 220px;
	}

	/* Products Grid 2 Columns */
	.products-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 10px;
	}

	.product-card-info {
		padding: 10px;
	}

	.product-title {
		font-size: 12.5px;
		min-height: 34px;
	}

	/* News Listing Page (Tin Tức) */
	.news-page-featured {
		flex-direction: column;
	}

	.featured-page-thumb {
		max-width: 100%;
		flex-basis: auto;
	}

	.featured-page-info {
		padding: 18px;
	}

	.news-cards-grid {
		grid-template-columns: 1fr;
	}

	.product-price {
		font-size: 13.5px;
	}

	/* Brands Grid - horizontal scroll when it doesn't fit */
	.brands-grid-wrap {
		display: flex;
		flex-wrap: nowrap;
		overflow-x: auto;
		gap: 8px;
		padding-bottom: 6px;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: thin;
	}

	.brands-grid-wrap .brand-item-card {
		flex: 0 0 auto;
		width: 110px;
	}

	/* Quote Form */
	.quote-request-card {
		padding: 20px 15px;
	}

	/* Contact Page ("Liên hệ") */
	.contact-form-card {
		padding: 20px 15px;
	}

	.contact-map-embed {
		height: 220px;
	}

	.contact-info-box,
	.contact-department-card {
		padding: 18px;
	}

	.form-row-2col {
		grid-template-columns: 1fr;
		gap: 12px;
	}

	.form-submit-row {
		flex-direction: column;
		align-items: stretch;
		gap: 12px;
	}

	.quote-hotline-fast {
		justify-content: center;
	}

	.product-search-clear {
		width: 32px;
		height: 32px;
	}

	/* Header & Logo on Mobile (< 576px) */
	.header-logo .custom-logo {
		max-height: 36px;
		max-width: 145px;
	}

	.header-social {
		gap: 8px;
	}

	.header-social-link {
		width: 34px;
		height: 34px;
	}

	.header-social-link svg {
		width: 16px;
		height: 16px;
	}

	/* Footer Main */
	.footer-main-inner {
		grid-template-columns: 1fr;
		gap: 25px;
	}

	.copyright-inner {
		flex-direction: column;
		gap: 8px;
		text-align: center;
	}

	/* Floating Contact Quick Bar */
	.floating-contact-sidebar {
		right: 10px;
		bottom: 30px;
		gap: 8px;
	}

	.floating-btn {
		width: 42px;
		height: 42px;
	}

	.floating-tooltip {
		display: none;
	}

	/* Live Chat Popup */
	.chat-popup {
		right: 12px;
		bottom: 80px;
		width: 300px;
		max-width: calc(100vw - 24px);
	}

	/* Post Comments */
	.comment-body {
		gap: 10px;
		padding: 12px;
	}

	.comment-avatar .avatar-img {
		width: 38px;
		height: 38px;
	}

	.comment-list .children {
		margin-left: 14px;
		padding-left: 12px;
	}

	.comment-respond {
		padding: 16px;
	}

	.form-row-2col {
		grid-template-columns: 1fr;
	}

	.btn-comment-submit {
		align-self: stretch;
	}

	.ts-empty-state {
		padding: 40px 16px;
	}

	.ts-empty-state__icon {
		width: 60px;
		height: 60px;
	}

	.ts-empty-state__icon svg {
		width: 26px;
		height: 26px;
	}

	.no-results-hotline {
		flex-direction: column;
		gap: 8px;
	}

	/* Forum Listing Page (Diễn Đàn Kỹ Thuật): collapse the table into
	   stacked label:value rows since a 4-column table has no room on
	   narrow screens. */
	.forum-category-cards {
		grid-template-columns: 1fr 1fr;
	}

	/* Photo Gallery Page (Thư Viện Ảnh) */
	.gallery-page-grid {
		grid-template-columns: 1fr 1fr;
	}

	.forum-topics-table thead {
		display: none;
	}

	.forum-topics-table,
	.forum-topics-table tbody,
	.forum-topics-table tr,
	.forum-topics-table td {
		display: block;
		width: 100%;
	}

	.forum-topics-table tr {
		padding: 12px 0;
		border-bottom: 1px solid var(--ts-border-light);
	}

	.forum-topics-table td {
		border-bottom: none;
		padding: 3px 0;
	}

	.forum-topics-table td.col-category,
	.forum-topics-table td.col-replies,
	.forum-topics-table td.col-updated {
		display: flex;
		justify-content: space-between;
		text-align: left;
	}

	.forum-topics-table td.col-category::before,
	.forum-topics-table td.col-replies::before,
	.forum-topics-table td.col-updated::before {
		content: attr(data-label);
		font-weight: 600;
		color: var(--ts-text-light);
	}
}

/* ==========================================================================
   3b. Small Mobile Phones (< 576px)
   ========================================================================== */
@media (max-width: 576px) {
	/* Single column so long titles/badges/prices have room to truncate cleanly */
	.products-grid {
		grid-template-columns: 1fr;
		gap: 12px;
	}

	.forum-category-cards {
		grid-template-columns: 1fr;
	}

	.gallery-page-grid {
		grid-template-columns: 1fr;
	}

	.category-section-header {
		flex-wrap: wrap;
		gap: 8px;
	}

	.header-cat-title {
		font-size: 14.5px;
	}
}

/* ==========================================================================
   4. Extra Small Mobile (< 380px)
   ========================================================================== */
@media (max-width: 380px) {
	.header-logo .custom-logo {
		max-height: 30px;
		max-width: 120px;
	}

	.header-social {
		gap: 6px;
	}

	.header-social-link {
		width: 32px;
		height: 32px;
	}

	.header-social-link svg {
		width: 14px;
		height: 14px;
	}
}

/* ==========================================================================
   4. Mobile Backdrop Overlay
   ========================================================================== */
.mobile-menu-backdrop {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	background: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(2px);
	z-index: 99998;
	opacity: 0;
	visibility: hidden;
	transition: var(--ts-transition);
}

.mobile-menu-backdrop.active {
	opacity: 1;
	visibility: visible;
}
