/**
 * Vivero Daliz — Header / Navbar
 *
 * Colores: fondo #F9FFF5, texto #111111
 * Tipografía: DM Sans
 * Enfoque: mobile-first
 */

/* ==========================================================================
   Sobreescribir overflow del tema padre Storefront para permitir dropdowns
   ========================================================================== */
#page.hfeed.site,
#masthead .col-full {
	overflow: visible !important;
}

/* Sticky header */
#masthead {
	position: sticky;
	top: 0;
	z-index: 9999;
}

/* Compensar barra de admin de WordPress cuando está logueado */
.admin-bar #masthead {
	top: 32px;
}

@media screen and (max-width: 782px) {
	.admin-bar #masthead {
		top: 46px;
	}
}

/* ==========================================================================
   Header contenedor
   ========================================================================== */
.vivero-header {
	background-color: #F9FFF5;
	border-bottom: 2px solid #2A4428;
	position: sticky;
	top: 0;
	z-index: 9999;
}

.vivero-header__container {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 0.5rem 2rem;
	gap: 1rem;
	box-sizing: border-box;
}

/* ==========================================================================
   Logo
   ========================================================================== */
.vivero-header__logo {
	flex-shrink: 0;
}

.vivero-header__logo a {
	display: block;
	line-height: 0;
}

.vivero-header__logo img,
.custom-logo {
	height: 55px;
	width: auto;
	border-radius: 50%;
	object-fit: contain;
}

.vivero-header__site-name {
	font-family: 'DM Sans', sans-serif;
	font-size: 1.25rem;
	font-weight: 700;
	color: #111111;
	text-decoration: none;
}

/* ==========================================================================
   Navegación principal
   ========================================================================== */
.vivero-header__nav {
	flex: 1;
	display: none;
}

.vivero-header__menu {
	display: flex;
	align-items: center;
	justify-content: center;
	list-style: none;
	margin: 0;
	padding: 0;
	gap: 1.5rem;
}

.vivero-header__menu > .menu-item > a {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	padding: 0.6rem 0.75rem;
	font-family: 'DM Sans', sans-serif;
	font-size: 0.875rem;
	font-weight: 500;
	color: #111111;
	text-decoration: none;
	border-radius: 6px;
	transition: background-color 0.2s, color 0.2s;
	white-space: nowrap;
}

.vivero-header__menu > .menu-item > a:hover,
.vivero-header__menu > .menu-item > a:focus {
	background-color: rgba(42, 68, 40, 0.08);
	color: #2A4428;
}

/* Indicador de dropdown (flecha) */
.vivero-header__menu > .menu-item-has-children > a::after {
	content: '';
	display: inline-block;
	width: 0;
	height: 0;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 4px solid currentColor;
	margin-left: 4px;
	transition: transform 0.2s;
}

/* ==========================================================================
   Submenús / Dropdowns
   ========================================================================== */
.vivero-header__menu .sub-menu {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 200px;
	background-color: #fff;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
	padding: 0.5rem 0;
	list-style: none;
	margin: 0;
	z-index: 100;
}

.vivero-header__menu > .menu-item {
	position: relative;
}

.vivero-header__menu > .menu-item:hover > .sub-menu,
.vivero-header__menu > .menu-item:focus-within > .sub-menu {
	display: block;
}

.vivero-header__menu .sub-menu .menu-item a {
	display: block;
	padding: 0.5rem 1rem;
	font-family: 'DM Sans', sans-serif;
	font-size: 0.85rem;
	color: #111111;
	text-decoration: none;
	transition: background-color 0.15s;
}

.vivero-header__menu .sub-menu .menu-item a:hover,
.vivero-header__menu .sub-menu .menu-item a:focus {
	background-color: #F9FFF5;
	color: #2A4428;
}

/* ==========================================================================
   Acciones (iconos de la derecha)
   ========================================================================== */
.vivero-header__actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-shrink: 0;
}

.vivero-header__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	color: #111111;
	text-decoration: none;
	border-radius: 50%;
	transition: background-color 0.2s, color 0.2s;
	position: relative;
}

.vivero-header__icon:hover {
	background-color: rgba(42, 68, 40, 0.08);
	color: #2A4428;
}

.vivero-header__icon svg {
	display: block;
}

/* Badge del carrito */
.vivero-header__badge {
	position: absolute;
	top: 2px;
	right: 2px;
	background-color: #2A4428;
	color: #fff;
	font-family: 'DM Sans', sans-serif;
	font-size: 0.65rem;
	font-weight: 700;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

/* ==========================================================================
   Buscador
   ========================================================================== */
.vivero-header__search {
	display: flex;
	align-items: center;
	position: relative;
}

.vivero-header__search-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	background: none;
	border: none;
	cursor: pointer;
	color: #111111;
	border-radius: 50%;
	transition: background-color 0.2s;
	padding: 0;
}

.vivero-header__search-toggle:hover {
	background-color: rgba(42, 68, 40, 0.08);
}

.vivero-header__search-form {
	display: flex;
	align-items: center;
	margin: 0;
	padding: 0;
}

.vivero-header__search-input {
	width: 180px;
	height: 38px;
	padding: 0 0.75rem;
	margin: 0;
	border: 1px solid #ddd;
	border-radius: 20px;
	font-family: 'DM Sans', sans-serif;
	font-size: 0.85rem;
	color: #111111;
	background-color: #fff;
	outline: none;
	transition: border-color 0.2s, width 0.3s;
	box-sizing: border-box;
	vertical-align: middle;
}

.vivero-header__search-input:focus {
	border-color: #2A4428;
	width: 220px;
}

.vivero-header__search-input::placeholder {
	color: #999;
}

/* ==========================================================================
   Hamburger (mobile)
   ========================================================================== */
.vivero-header__toggle {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 5px;
	width: 38px;
	height: 38px;
	background: none;
	border: none;
	cursor: pointer;
	padding: 0;
	border-radius: 6px;
	transition: background-color 0.2s;
}

.vivero-header__toggle:hover {
	background-color: rgba(42, 68, 40, 0.08);
}

.vivero-header__toggle span {
	display: block;
	width: 20px;
	height: 2px;
	background-color: #111111;
	border-radius: 2px;
	transition: transform 0.3s, opacity 0.3s;
}

/* Hamburger animado a X cuando abierto */
.vivero-header__toggle[aria-expanded="true"] span:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}

.vivero-header__toggle[aria-expanded="true"] span:nth-child(2) {
	opacity: 0;
}

.vivero-header__toggle[aria-expanded="true"] span:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}

/* ==========================================================================
   Ocultar header default de Storefront (fallback)
   ========================================================================== */
.site-header .site-branding,
.site-header .site-search,
.site-header .main-navigation,
.site-header .site-header-cart {
	display: none !important;
}

/* Eliminar padding/margin del header de Storefront */
#masthead.site-header {
	padding: 0 !important;
	margin: 0 !important;
}

/* Limpiar restricciones de ancho de Storefront en el header */
#masthead .col-full,
.site-header .col-full {
	max-width: 100% !important;
	width: 100% !important;
	padding: 0 !important;
	margin: 0 !important;
}

/* ==========================================================================
   Responsive — Tablet (768px)
   ========================================================================== */
@media (min-width: 768px) {
	.vivero-header__toggle {
		display: none;
	}

	.vivero-header__nav {
		display: block;
	}

	.vivero-header__search-toggle {
		display: none;
	}

	.vivero-header__search-form {
		display: flex;
	}
}

/* ==========================================================================
   Responsive — Mobile (< 768px)
   ========================================================================== */
@media (max-width: 767px) {
	.vivero-header__container {
		flex-wrap: wrap;
	}

	.vivero-header__nav {
		display: none;
		order: 10;
		width: 100%;
		border-top: 1px solid rgba(0, 0, 0, 0.06);
		padding-top: 0.5rem;
	}

	.vivero-header__nav.is-open {
		display: block;
	}

	.vivero-header__menu {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
	}

	.vivero-header__menu > .menu-item > a {
		padding: 0.75rem 1rem;
		border-radius: 0;
		font-size: 0.95rem;
	}

	/* Submenús en mobile */
	.vivero-header__menu .sub-menu {
		position: static;
		box-shadow: none;
		border: none;
		border-radius: 0;
		padding: 0;
		background-color: #f5f9f3;
	}

	.vivero-header__menu > .menu-item:hover > .sub-menu {
		display: none;
	}

	.vivero-header__menu > .menu-item.is-submenu-open > .sub-menu {
		display: block;
	}

	.vivero-header__menu .sub-menu .menu-item a {
		padding-left: 2rem;
	}

	/* Buscador en mobile */
	.vivero-header__search-form {
		display: none;
	}

	.vivero-header__search-toggle {
		display: flex;
	}

	.vivero-header__search.is-open .vivero-header__search-form {
		display: flex;
		position: absolute;
		top: 100%;
		right: 0;
		background: #fff;
		border: 1px solid #ddd;
		border-radius: 8px;
		padding: 0.5rem;
		box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
		z-index: 100;
	}

	.vivero-header__search.is-open .vivero-header__search-input {
		width: 200px;
	}

	/* Ocultar favoritos en mobile para más espacio */
	.vivero-header__favorites {
		display: none;
	}
}

/* ==========================================================================
   Responsive — Desktop grande (1024px)
   ========================================================================== */
@media (min-width: 1024px) {
	.vivero-header__container {
		padding: 0.5rem 1rem;
	}

	.vivero-header__menu {
		gap: 0.25rem;
	}

	.vivero-header__menu > .menu-item > a {
		padding: 0.5rem 0.5rem;
		font-size: 0.8rem;
	}

	.vivero-header__search-input {
		width: 160px;
	}

	.vivero-header__search-input:focus {
		width: 200px;
	}
}

/* Desktop grande (1280px+) — más espacio */
@media (min-width: 1280px) {
	.vivero-header__container {
		padding: 0.5rem 2rem;
	}

	.vivero-header__menu {
		gap: 1rem;
	}

	.vivero-header__menu > .menu-item > a {
		padding: 0.6rem 0.75rem;
		font-size: 0.875rem;
	}

	.vivero-header__search-input {
		width: 200px;
	}

	.vivero-header__search-input:focus {
		width: 250px;
	}
}
