/**
 * Onpy Dynamic Header — styles
 * 7 botoes em linha, gradient amarelo, dropdowns vindos de wp_nav_menu.
 */

.onpy-dh {
	--onpy-dh-bg-start: #FFEE15;
	--onpy-dh-bg-end: #FFD315;
	--onpy-dh-bg-angle: 156deg;
	width: 100%;
	background: linear-gradient(var(--onpy-dh-bg-angle), var(--onpy-dh-bg-start) 9%, var(--onpy-dh-bg-end) 91%);
	font-family: "Roboto", system-ui, -apple-system, sans-serif;
	z-index: 100;
}

.onpy-dh--sticky {
	position: sticky;
	top: 0;
}

.onpy-dh__inner {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	max-width: 1600px;
	margin: 0 auto;
	padding: 8px 24px;
	min-height: 73px;
	flex-wrap: wrap;
}

/* Nav row — preenche 100% e distribui os botoes conforme alinhamento */
.onpy-dh__nav {
	display: flex;
	align-items: stretch;
	gap: var(--onpy-dh-btn-gap, 12px);
	flex: 1 1 100%;
	width: 100%;
}

/* Wrapper de botao — block por padrao (display:flex causava conflito com dropdown) */
.onpy-dh__btn-wrap {
	position: relative;
	min-width: 0;
}

/* ────── ALINHAMENTO DOS BOTOES — DESKTOP ────── */
.onpy-dh--align-left   .onpy-dh__nav { justify-content: flex-start; }
.onpy-dh--align-center .onpy-dh__nav { justify-content: center; }
.onpy-dh--align-right  .onpy-dh__nav { justify-content: flex-end; }
.onpy-dh--align-stretch .onpy-dh__nav { justify-content: space-between; }

.onpy-dh--align-left   .onpy-dh__btn-wrap,
.onpy-dh--align-center .onpy-dh__btn-wrap,
.onpy-dh--align-right  .onpy-dh__btn-wrap { flex: 0 0 auto; }
.onpy-dh--align-stretch .onpy-dh__btn-wrap { flex: 1 1 0; }

/* ────── ALINHAMENTO — TABLET ────── */
@media (max-width: 1024px) {
	.onpy-dh--align-tablet-left   .onpy-dh__nav { justify-content: flex-start; }
	.onpy-dh--align-tablet-center .onpy-dh__nav { justify-content: center; }
	.onpy-dh--align-tablet-right  .onpy-dh__nav { justify-content: flex-end; }
	.onpy-dh--align-tablet-stretch .onpy-dh__nav { justify-content: space-between; }

	.onpy-dh--align-tablet-left   .onpy-dh__btn-wrap,
	.onpy-dh--align-tablet-center .onpy-dh__btn-wrap,
	.onpy-dh--align-tablet-right  .onpy-dh__btn-wrap { flex: 0 0 auto; }
	.onpy-dh--align-tablet-stretch .onpy-dh__btn-wrap { flex: 1 1 0; }
}

/* ────── ALINHAMENTO — MOBILE ────── */
@media (max-width: 767px) {
	.onpy-dh--align-mobile-left   .onpy-dh__nav { justify-content: flex-start; }
	.onpy-dh--align-mobile-center .onpy-dh__nav { justify-content: center; }
	.onpy-dh--align-mobile-right  .onpy-dh__nav { justify-content: flex-end; }
	.onpy-dh--align-mobile-stretch .onpy-dh__nav { justify-content: space-between; }

	.onpy-dh--align-mobile-left   .onpy-dh__btn-wrap,
	.onpy-dh--align-mobile-center .onpy-dh__btn-wrap,
	.onpy-dh--align-mobile-right  .onpy-dh__btn-wrap { flex: 0 0 auto; }
	.onpy-dh--align-mobile-stretch .onpy-dh__btn-wrap { flex: 1 1 0; }
}

/* Botoes — todos com mesma largura/altura */
.onpy-dh__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	min-height: 48px;
	padding: 10px 12px;
	color: #111;
	background: transparent;
	border-radius: 8px;
	text-decoration: none;
	font-family: "Roboto", system-ui, -apple-system, sans-serif;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
	text-align: center;
	transition: background 0.2s, color 0.2s, transform 0.1s;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}
.onpy-dh__btn-label {
	overflow: hidden;
	text-overflow: ellipsis;
}
.onpy-dh__btn:hover {
	color: #000;
	background: rgba(0, 0, 0, 0.06);
}
.onpy-dh__btn:active { transform: translateY(1px); }

/* Destaque azul (Autorepuestos, Ferreteria, Login) */
.onpy-dh__btn--highlight {
	background: #6AB1EC;
	color: #fff;
}
.onpy-dh__btn--highlight:hover {
	background: #4F96D1;
	color: #fff;
}

/* Icones */
.onpy-dh__btn-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	flex-shrink: 0;
}
.onpy-dh__btn-icon svg,
.onpy-dh__btn-icon img {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: contain;
}

.onpy-dh__caret {
	margin-left: 2px;
	font-size: 10px;
	transition: transform 0.2s;
}

/* ────────── Dropdowns (WP nav menus) ────────── */

.onpy-dh__dropdown {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	min-width: 260px;
	max-width: 360px;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
	padding: 8px 0;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px);
	transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
	z-index: 10;
}
.onpy-dh__btn-wrap.is-open > .onpy-dh__dropdown {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}
.onpy-dh__btn-wrap.is-open > .onpy-dh__btn .onpy-dh__caret {
	transform: rotate(180deg);
}
@media (hover: hover) {
	.onpy-dh__btn-wrap:hover > .onpy-dh__dropdown {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
	}
	.onpy-dh__btn-wrap:hover > .onpy-dh__btn .onpy-dh__caret {
		transform: rotate(180deg);
	}
}

/* wp_nav_menu markup */
.onpy-dh__menu-list,
.onpy-dh__menu-list ul {
	list-style: none;
	margin: 0;
	padding: 0;
}
.onpy-dh__menu-list li { position: relative; }
.onpy-dh__menu-list a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 16px;
	color: #333;
	text-decoration: none;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.3;
	transition: background 0.15s, color 0.15s;
}
.onpy-dh__menu-list a:hover,
.onpy-dh__menu-list a:focus {
	background: #f5f7fa;
	color: #4F96D1;
}

/* Submenus (nivel 2+) — aparecem a direita */
.onpy-dh__menu-list li > ul {
	display: none;
	position: absolute;
	top: 0;
	left: 100%;
	min-width: 240px;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
	padding: 8px 0;
	z-index: 11;
}
.onpy-dh__menu-list li.is-open > ul {
	display: block;
}
@media (hover: hover) {
	.onpy-dh__menu-list li:hover > ul { display: block; }
}
/* "Ver todos" — separador visual no dropdown de marca */
.onpy-dh__brand-all {
	border-top: 1px solid #eee;
	margin-top: 4px;
	padding-top: 4px;
}
.onpy-dh__brand-all a {
	color: #4F96D1;
	font-weight: 600;
}

/* Indicador de submenu */
.onpy-dh__menu-list li.menu-item-has-children > a::after {
	content: '›';
	font-size: 18px;
	line-height: 1;
	margin-left: 8px;
	color: #6AB1EC;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVO — breakpoints: tablet ≤1024px, mobile ≤767px
   Modos: compact (so icones), full (icone+texto), burger
   ═══════════════════════════════════════════════════════════════ */

/* ── Ocultar totalmente (toggle hide_on_*) ── */
@media (max-width: 1024px) {
	.onpy-dh--hide-tablet { display: none !important; }
}
@media (max-width: 767px) {
	.onpy-dh--hide-mobile { display: none !important; }
}

/* ─────────── DESKTOP (≥1025px) — sem ajustes extras ─────────── */

/* ─────────── TABLET (768–1024px) ─────────── */
@media (min-width: 768px) and (max-width: 1024px) {
	.onpy-dh__inner { padding: 8px 16px; min-height: 64px; }
	.onpy-dh__btn   { padding: 8px 10px; font-size: 14px; gap: 6px; min-height: 44px; }
	.onpy-dh__nav   { gap: 8px; }
	.onpy-dh--sticky { position: sticky; top: 0; }

	/* Scroll horizontal silencioso se botoes nao couberem */
	.onpy-dh--tablet-compact .onpy-dh__nav,
	.onpy-dh--tablet-full .onpy-dh__nav {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}
	.onpy-dh--tablet-compact .onpy-dh__nav::-webkit-scrollbar,
	.onpy-dh--tablet-full .onpy-dh__nav::-webkit-scrollbar { display: none; }

	/* Compact + stretch: icones nao devem se esticar */
	.onpy-dh--tablet-compact.onpy-dh--align-stretch .onpy-dh__btn-wrap { flex: 0 0 auto; }

	/* Ultimo dropdown alinhado a direita para nao sair da tela */
	.onpy-dh--tablet-compact .onpy-dh__btn-wrap:last-child > .onpy-dh__dropdown,
	.onpy-dh--tablet-full    .onpy-dh__btn-wrap:last-child > .onpy-dh__dropdown {
		left: auto;
		right: 0;
	}

	/* TABLET — modo COMPACTO: esconde labels, mostra so icones (centralizados) */
	.onpy-dh--tablet-compact .onpy-dh__btn-label { display: none; }
	.onpy-dh--tablet-compact .onpy-dh__btn       { padding: 8px 12px; }
	.onpy-dh--tablet-compact .onpy-dh__btn-icon  { width: 22px; height: 22px; }

	/* TABLET — modo FULL: nada a mudar alem do default acima */

	/* TABLET — modo BURGER */
	.onpy-dh--tablet-burger .onpy-dh__inner {
		flex-wrap: wrap;
		min-height: auto;
	}
	.onpy-dh--tablet-burger .onpy-dh__toggle {
		display: inline-flex;
		margin-left: 0;
		margin-right: auto;
	}
	.onpy-dh--tablet-burger .onpy-dh__nav {
		order: 99;
		flex-basis: 100%;
		flex-direction: column;
		align-items: stretch;
		gap: 4px;
		max-height: 0;
		overflow: hidden;
		transition: max-height 0.3s ease;
	}
	.onpy-dh--tablet-burger.is-mobile-open .onpy-dh__nav {
		max-height: 80vh;
		overflow-y: auto;
		padding: 8px 0;
	}
	.onpy-dh--tablet-burger .onpy-dh__btn-wrap { width: 100%; flex: 0 0 auto; }
	.onpy-dh--tablet-burger .onpy-dh__btn      { width: 100%; justify-content: flex-start; min-height: 44px; }

	.onpy-dh--tablet-burger .onpy-dh__dropdown {
		position: static;
		box-shadow: none;
		background: rgba(255, 255, 255, 0.55);
		opacity: 1;
		transform: none;
		max-height: 0;
		overflow: hidden;
		padding: 0;
		min-width: 0;
		max-width: none;
		visibility: hidden;
		transition: max-height 0.25s, visibility 0s 0.25s;
	}
	.onpy-dh--tablet-burger .onpy-dh__btn-wrap.is-open > .onpy-dh__dropdown {
		visibility: visible;
		max-height: 60vh;
		overflow-y: auto;
		padding: 6px 0;
		transition: max-height 0.25s, visibility 0s;
	}
	.onpy-dh--tablet-burger .onpy-dh__btn-wrap:hover > .onpy-dh__dropdown {
		visibility: hidden;
		max-height: 0;
	}
	.onpy-dh--tablet-burger .onpy-dh__menu-list li > ul {
		position: static;
		display: block;
		box-shadow: none;
		background: transparent;
		padding-left: 16px;
	}
	.onpy-dh--tablet-burger.onpy-dh--sticky { position: static; }
}

/* ─────────── MOBILE (≤767px) ─────────── */
@media (max-width: 767px) {
	.onpy-dh__inner { padding: 8px 12px; min-height: 56px; }
	.onpy-dh__btn   { padding: 8px 10px; font-size: 14px; gap: 6px; min-height: 40px; }
	.onpy-dh__nav   { gap: 6px; }
	.onpy-dh--sticky { position: sticky; top: 0; }

	/* MOBILE — modo COMPACTO: so icones, menor padding */
	.onpy-dh--mobile-compact .onpy-dh__btn-label { display: none; }
	.onpy-dh--mobile-compact .onpy-dh__btn       { padding: 6px 8px; }
	.onpy-dh--mobile-compact .onpy-dh__btn-icon  { width: 20px; height: 20px; }
	.onpy-dh--mobile-compact .onpy-dh__caret     { display: none; }

	/* MOBILE — modo BURGER (padrao) */
	.onpy-dh--mobile-burger .onpy-dh__inner {
		flex-wrap: wrap;
		min-height: auto;
	}
	.onpy-dh--mobile-burger .onpy-dh__toggle { display: inline-flex; }
	.onpy-dh--mobile-burger .onpy-dh__nav {
		order: 99;
		flex-basis: 100%;
		flex-direction: column;
		align-items: stretch;
		gap: 4px;
		max-height: 0;
		overflow: hidden;
		transition: max-height 0.3s ease;
	}
	.onpy-dh--mobile-burger.is-mobile-open .onpy-dh__nav {
		max-height: 80vh;
		overflow-y: auto;
		padding: 8px 0;
	}
	.onpy-dh--mobile-burger .onpy-dh__btn-wrap { width: 100%; flex: 0 0 auto; }
	.onpy-dh--mobile-burger .onpy-dh__btn      { width: 100%; justify-content: flex-start; min-height: 44px; }

	.onpy-dh--mobile-burger .onpy-dh__dropdown {
		position: static;
		box-shadow: none;
		background: rgba(255, 255, 255, 0.55);
		opacity: 1;
		transform: none;
		max-height: 0;
		overflow: hidden;
		padding: 0;
		min-width: 0;
		max-width: none;
		visibility: hidden;
		transition: max-height 0.25s, visibility 0s 0.25s;
	}
	.onpy-dh--mobile-burger .onpy-dh__btn-wrap.is-open > .onpy-dh__dropdown {
		visibility: visible;
		max-height: 60vh;
		overflow-y: auto;
		padding: 6px 0;
		transition: max-height 0.25s, visibility 0s;
	}
	.onpy-dh--mobile-burger .onpy-dh__btn-wrap:hover > .onpy-dh__dropdown {
		visibility: hidden;
		max-height: 0;
	}
	.onpy-dh--mobile-burger .onpy-dh__menu-list li > ul {
		position: static;
		display: block;
		box-shadow: none;
		background: transparent;
		padding-left: 16px;
	}
	.onpy-dh--mobile-burger.onpy-dh--sticky { position: static; }
}

/* ── Botao hamburger (visual) ── */
.onpy-dh__toggle {
	display: none;
	background: transparent;
	border: 0;
	padding: 8px;
	cursor: pointer;
	margin-left: auto;
	flex-direction: column;
	gap: 4px;
	align-items: center;
	justify-content: center;
}
.onpy-dh__toggle span {
	display: block;
	width: 24px;
	height: 2px;
	background: #222;
	transition: transform 0.2s, opacity 0.2s;
}
.onpy-dh__toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.onpy-dh__toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.onpy-dh__toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ═══════════════════════════════════════════════════════════════
   APP LAYOUT (mobile + tablet)
   Top bar: hamburger + busca + carrinho
   Bottom bar: 4 botoes de acao (icone grande + label)

   A classe .onpy-dh--app-active eh aplicada via JS quando:
   - viewport <=767px E mobile_mode === 'app', OU
   - viewport 768-1024px E tablet_mode === 'app'
   ═══════════════════════════════════════════════════════════════ */

/* Por padrao, top bar e bottom bar ficam ocultos. */
.onpy-dh__mobile-top,
.onpy-dh__mobile-actions {
	display: none;
}

.onpy-dh--app-active .onpy-dh__inner {
		flex-direction: column;
		flex-wrap: nowrap;
		padding: 10px 14px;
		gap: 12px;
		min-height: auto;
	}

	/* Esconder o burger antigo do .__inner (ele eh substituido pelo do mobile-top) */
	.onpy-dh--app-active .onpy-dh__inner > .onpy-dh__toggle {
		display: none !important;
	}

	/* ── Top bar ──────────────────────────────────────────────── */
	.onpy-dh--app-active .onpy-dh__mobile-top {
		display: flex;
		align-items: center;
		gap: 10px;
		width: 100%;
	}

	.onpy-dh--app-active .onpy-dh__toggle--mobile {
		display: inline-flex;
		flex: 0 0 auto;
		margin-left: 0;
		margin-right: 0;
		width: 44px;
		height: 44px;
		padding: 0;
		background: rgba(0, 0, 0, 0.06);
		border-radius: 8px;
	}

	/* ── Busca ──────────────────────────────────────────────── */
	.onpy-dh--app-active .onpy-dh__mobile-search {
		display: flex;
		align-items: center;
		flex: 1 1 auto;
		min-width: 0;
		background: #fff;
		border-radius: 6px;
		overflow: hidden;
		box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
	}

	.onpy-dh--app-active .onpy-dh__mobile-search input {
		flex: 1 1 auto;
		min-width: 0;
		border: 0;
		outline: 0;
		padding: 10px 12px;
		font-size: 14px;
		font-family: "Roboto", system-ui, -apple-system, sans-serif;
		background: transparent;
		color: #333;
		-webkit-appearance: none;
		appearance: none;
	}

	.onpy-dh--app-active .onpy-dh__mobile-search input::-webkit-search-cancel-button {
		-webkit-appearance: none;
	}

	.onpy-dh--app-active .onpy-dh__mobile-search button {
		flex: 0 0 auto;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 40px;
		height: 40px;
		border: 0;
		cursor: pointer;
		background: #FFD700;
		color: #000;
	}

	.onpy-dh--app-active .onpy-dh__mobile-search button svg {
		width: 20px;
		height: 20px;
	}

	/* ── Carrinho ───────────────────────────────────────────── */
	.onpy-dh--app-active .onpy-dh__mobile-cart {
		position: relative;
		flex: 0 0 auto;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 44px;
		height: 44px;
		color: #111;
		text-decoration: none;
	}

	.onpy-dh--app-active .onpy-dh__mobile-cart svg {
		width: 28px;
		height: 28px;
	}

	.onpy-dh__cart-count {
		position: absolute;
		top: 0;
		right: 0;
		min-width: 18px;
		height: 18px;
		padding: 0 5px;
		background: #E53935;
		color: #fff;
		border-radius: 9px;
		font-size: 11px;
		font-weight: 700;
		line-height: 18px;
		text-align: center;
		box-sizing: border-box;
	}

	/* ── Esconder o nav original em mobile-app (so abre via burger) ── */
	.onpy-dh--app-active .onpy-dh__nav {
		order: 99;
		flex-basis: 100%;
		flex-direction: column;
		align-items: stretch;
		gap: 4px;
		max-height: 0;
		overflow: hidden;
		transition: max-height 0.3s ease;
	}
	.onpy-dh--app-active.is-mobile-open .onpy-dh__nav {
		max-height: 80vh;
		overflow-y: auto;
		padding: 8px 0;
	}
	.onpy-dh--app-active .onpy-dh__btn-wrap { width: 100%; flex: 0 0 auto; }
	.onpy-dh--app-active .onpy-dh__btn      { width: 100%; justify-content: flex-start; min-height: 44px; }
	.onpy-dh--app-active .onpy-dh__dropdown {
		position: static;
		box-shadow: none;
		background: rgba(255, 255, 255, 0.55);
		opacity: 1;
		transform: none;
		max-height: 0;
		overflow: hidden;
		padding: 0;
		min-width: 0;
		max-width: none;
		visibility: hidden;
		transition: max-height 0.25s, visibility 0s 0.25s;
	}
	.onpy-dh--app-active .onpy-dh__btn-wrap.is-open > .onpy-dh__dropdown {
		visibility: visible;
		max-height: 60vh;
		overflow-y: auto;
		padding: 6px 0;
		transition: max-height 0.25s, visibility 0s;
	}
	.onpy-dh--app-active .onpy-dh__btn-wrap:hover > .onpy-dh__dropdown {
		visibility: hidden;
		max-height: 0;
	}
	.onpy-dh--app-active .onpy-dh__menu-list li > ul {
		position: static;
		display: block;
		box-shadow: none;
		background: transparent;
		padding-left: 16px;
	}
	.onpy-dh--app-active.onpy-dh--sticky { position: static; }

	/* ── Bottom Action Bar ──────────────────────────────────── */
	.onpy-dh--app-active .onpy-dh__mobile-actions {
		display: grid;
		grid-template-columns: repeat(4, 1fr);
		width: 100%;
		gap: 0;
	}

	.onpy-dh--app-active .onpy-dh__mobile-action {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 6px;
		padding: 6px 4px;
		color: #000;
		text-decoration: none;
		font-family: "Roboto", system-ui, -apple-system, sans-serif;
		text-align: center;
		-webkit-tap-highlight-color: transparent;
	}

	.onpy-dh--app-active .onpy-dh__mobile-action:active {
		opacity: 0.6;
	}

	.onpy-dh--app-active .onpy-dh__mobile-action-icon {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 32px;
		height: 32px;
	}

	.onpy-dh--app-active .onpy-dh__mobile-action-icon svg,
	.onpy-dh--app-active .onpy-dh__mobile-action-icon img {
		width: 100%;
		height: 100%;
		display: block;
		object-fit: contain;
	}

	.onpy-dh--app-active .onpy-dh__mobile-action-label {
		font-size: 14px;
		font-weight: 700;
		line-height: 1.1;
		color: inherit;
	}

/* Em tablet, dar um pouco mais de respiro ao layout */
@media (min-width: 768px) {
	.onpy-dh--app-active .onpy-dh__inner { padding: 12px 24px; gap: 14px; }
	.onpy-dh--app-active .onpy-dh__mobile-search input { font-size: 15px; padding: 12px 14px; }
	.onpy-dh--app-active .onpy-dh__mobile-action-label { font-size: 15px; }
	.onpy-dh--app-active .onpy-dh__mobile-action-icon { width: 36px; height: 36px; }
	.onpy-dh--app-active .onpy-dh__mobile-cart svg { width: 32px; height: 32px; }
}
