/* ============================================================
   Layout Global Crecienta — Tucumascotas (Fase 2)
   Prefijo .cg- · Tokens de variables.css
   ============================================================ */

.cg-body {
	font-family: var(--tc-font-primary);
	color: var(--tc-text-dark);
	background: #fff;
}
.cg-page { min-height: 100vh; display: flex; flex-direction: column; }
.cg-page > main { flex: 1; }

/* ---------- Topbar ---------- */
.cg-topbar { background: var(--tc-color-secondary); color: #fff; font-size: 0.8rem; }
.cg-topbar__inner {
	max-width: 1200px; margin: 0 auto; padding: 7px 20px;
	display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.cg-topbar__mail { color: #fff; font-weight: 600; }
.cg-topbar__mail:hover { text-decoration: underline; }
.cg-topbar__hours { opacity: 0.9; }

/* ---------- Barra principal ---------- */
.cg-header { position: sticky; top: 0; z-index: 990; background: #fff; }
.cg-bar { border-bottom: 1px solid #f0eef4; transition: box-shadow 0.25s ease; }
.cg-header.is-scrolled .cg-bar { box-shadow: 0 6px 20px rgba(43, 12, 74, 0.1); }
.cg-bar__inner {
	max-width: 1200px; margin: 0 auto; padding: 10px 20px;
	display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.cg-logo img { max-height: 48px; width: auto; }
.cg-logo__text { font-size: 1.5rem; font-weight: 800; color: var(--tc-color-secondary); text-decoration: none; }

/* ---------- Acciones ---------- */
.cg-actions { display: flex; align-items: center; gap: 4px; }
.cg-icon-btn {
	position: relative; display: inline-flex; align-items: center; justify-content: center;
	width: 42px; height: 42px; border: none; background: transparent; border-radius: 12px;
	color: var(--tc-color-secondary); cursor: pointer; text-decoration: none;
	transition: background 0.2s ease, transform 0.2s ease;
}
.cg-icon-btn:hover { background: #f4e8f8; transform: translateY(-1px); }
.cg-cart__count {
	position: absolute; top: 2px; right: 0;
	background: var(--tc-color-primary); color: #fff; font-size: 0.68rem; font-weight: 700;
	min-width: 17px; height: 17px; border-radius: 999px;
	display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.cg-cart__count[data-count="0"] { display: none; }

/* ---------- Menú desktop ---------- */
.cg-nav-drawer { display: contents; }
.cg-nav { display: block; }
.cg-menu { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; }
.cg-item { position: relative; }
.cg-link {
	display: inline-flex; align-items: center; gap: 4px;
	padding: 9px 13px; border-radius: 10px;
	font-size: 0.95rem; font-weight: 600; color: var(--tc-text-dark);
	text-decoration: none; white-space: nowrap;
	transition: color 0.2s ease, background 0.2s ease;
}
.cg-link:hover, .cg-item--current > .cg-link { color: var(--tc-color-secondary); background: #f4e8f8; }
.cg-subarrow {
	display: none; /* desktop: hover */
	border: none; background: transparent; color: var(--tc-color-secondary);
	cursor: pointer; padding: 4px; margin-left: -8px; margin-right: 4px;
}
.cg-item--has-children:hover > .cg-subarrow svg { transform: rotate(180deg); }
.cg-subarrow svg { transition: transform 0.2s ease; }

.cg-submenu {
	position: absolute; top: 100%; left: 0; z-index: 991;
	min-width: 230px; list-style: none; margin: 0; padding: 8px;
	background: #fff; border-radius: 14px;
	box-shadow: 0 18px 45px rgba(43, 12, 74, 0.18);
	border: 1px solid #f0eef4;
	opacity: 0; visibility: hidden; transform: translateY(8px);
	transition: all 0.22s ease;
}
.cg-item--has-children:hover > .cg-submenu,
.cg-item--has-children:focus-within > .cg-submenu { opacity: 1; visibility: visible; transform: translateY(4px); }

.cg-submenu .cg-link { display: block; width: 100%; padding: 8px 12px; font-size: 0.9rem; font-weight: 500; border-radius: 9px; }
.cg-submenu .cg-item--has-children > .cg-link { font-weight: 700; color: var(--tc-color-secondary); }
.cg-submenu--nivel2 { position: absolute; left: calc(100% + 12px); top: -4px; }
.cg-submenu .cg-submenu { min-width: 200px; }
.cg-submenu .cg-submenu .cg-link { padding-left: 14px; }
/* Reserva de aire a la derecha en filas con submenú (desktop) */
.cg-submenu .cg-item--has-children > .cg-link { padding-right: 38px; }
.cg-submenu .cg-item--has-children > .cg-subarrow svg { transform: rotate(-90deg); }

/* ---------- Hamburger (oculto en desktop) ---------- */
.cg-hamburger {
	display: none; flex-direction: column; justify-content: center; gap: 5px;
	width: 42px; height: 42px; border: none; background: transparent; cursor: pointer; padding: 8px;
}
.cg-hamburger span { display: block; height: 2.5px; border-radius: 2px; background: var(--tc-color-secondary); transition: all 0.25s ease; }


/* ---------- Buscador overlay ---------- */
.cg-search {
	position: fixed; inset: 0; z-index: 999;
	background: rgba(43, 12, 74, 0.92); backdrop-filter: blur(4px);
	display: flex; align-items: flex-start; justify-content: center; padding: 12vh 20px 20px;
}
.cg-search[hidden] { display: none; }
.cg-search__panel { width: 100%; max-width: 640px; animation: cg-fade-up 0.25s ease; }
@keyframes cg-fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.cg-search__close {
	float: right; border: none; background: rgba(255,255,255,0.14); color: #fff;
	width: 44px; height: 44px; border-radius: 12px; cursor: pointer; margin-bottom: 18px;
}
.cg-search__close:hover { background: rgba(255,255,255,0.28); }
.cg-search__form { display: flex; gap: 8px; }
.cg-search__input {
	flex: 1; border: none; border-radius: 14px; padding: 15px 18px;
	font-size: 16px; font-family: inherit; background: #fff; color: var(--tc-text-dark);
}
.cg-search__input:focus { outline: 3px solid var(--tc-color-primary); }
.cg-search__btn { border: none; border-radius: 14px; padding: 0 18px; cursor: pointer; background: var(--tc-color-primary); color: #fff; }
.cg-search__btn:hover { background: #ff9d3d; }
.cg-search__freq { margin-top: 22px; color: #e9dcf3; font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cg-search__freq a {
	color: #fff; background: rgba(255,255,255,0.14); padding: 6px 13px; border-radius: 999px;
	font-weight: 600; text-decoration: none; transition: background 0.2s ease;
}
.cg-search__freq a:hover { background: var(--tc-color-primary); }

/* ---------- Footer ---------- */
.cg-footer { background: var(--tc-color-secondary); color: #efe6f5; margin-top: auto; }
.cg-footer__inner {
	max-width: 1200px; margin: 0 auto; padding: 52px 20px 34px;
	display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.2fr; gap: 34px;
}
.cg-footer__logo img { max-height: 46px; width: auto; filter: brightness(0) invert(1); }
.cg-footer__brand-name { font-size: 1.5rem; font-weight: 800; color: #fff; }
.cg-footer__tagline { margin: 14px 0 10px; font-size: 0.95rem; line-height: 1.55; }
.cg-footer__email a { color: #fff; font-weight: 600; text-decoration: none; }
.cg-footer__email a:hover { text-decoration: underline; }
.cg-footer__hours { font-size: 0.85rem; opacity: 0.85; margin-top: 6px; }
.cg-footer__col-title {
	color: #fff; font-size: 1rem; font-weight: 800; text-transform: uppercase;
	letter-spacing: 0.06em; margin: 0 0 16px; padding-bottom: 10px;
	border-bottom: 2px solid rgba(255,255,255,0.18);
}
.cg-footer__links { list-style: none; margin: 0; padding: 0; }
.cg-footer__links li { margin-bottom: 9px; }
.cg-footer__links a { color: #efe6f5; font-size: 0.92rem; text-decoration: none; transition: color 0.2s; }
.cg-footer__links a:hover { color: var(--tc-color-primary); }
.cg-footer__locations { list-style: none; margin: 0; padding: 0; }
.cg-footer__locations li { margin-bottom: 15px; font-size: 0.92rem; line-height: 1.5; }
.cg-footer__locations strong { color: #fff; }
.cg-footer__locations a { color: #efe6f5; text-decoration: none; }
.cg-footer__locations a:hover { text-decoration: underline; }
.cg-footer__social { display: flex; gap: 10px; margin-top: 16px; }
.cg-footer__social a {
	display: inline-flex; align-items: center; justify-content: center;
	width: 40px; height: 40px; border-radius: 12px;
	background: rgba(255,255,255,0.12); color: #fff; transition: background 0.2s, transform 0.2s;
}
.cg-footer__social a:hover { background: var(--tc-color-primary); transform: translateY(-2px); }
.cg-footer__bottom { border-top: 1px solid rgba(255,255,255,0.15); }
.cg-footer__bottom p { max-width: 1200px; margin: 0 auto; padding: 16px 20px; text-align: center; font-size: 0.8rem; opacity: 0.8; }
.cg-footer__bottom a { color: #fff; text-decoration: none; }

/* ============================================================
   RESPONSIVE — Drawer móvil (≤ 991px) y ajustes
   ============================================================ */
@media (max-width: 991px) {

	.cg-topbar__hours { display: none; }
	.cg-topbar__inner { justify-content: center; }

	.cg-nav-drawer {
		display: block; /* deja de ser display:contents */
		position: fixed; top: 0; left: 0; bottom: 0; z-index: 998;
		width: min(86vw, 360px);
		background: #fff; padding: 0;
		transform: translateX(-105%); transition: transform 0.3s ease;
		box-shadow: 20px 0 60px rgba(43, 12, 74, 0.25);
		overflow-y: auto; overscroll-behavior: contain;
	}
	.cg-nav-drawer.is-open { transform: translateX(0); }
	body.cg-drawer-open { overflow: hidden; }

	.cg-drawer-overlay {
		position: fixed; inset: 0; z-index: 997;
		background: rgba(43, 12, 74, 0.5); opacity: 0; pointer-events: none;
		transition: opacity 0.3s ease;
	}
	.cg-drawer-overlay.is-open { opacity: 1; pointer-events: auto; }

	.cg-hamburger { display: flex; }
	.cg-nav-drawer .cg-nav { padding-top: 18px; }
	.cg-menu { display: block; }
	.cg-item { border-bottom: 1px solid #f4f1f8; }
	.cg-link {
		width: 100%; justify-content: flex-start; border-radius: 0;
		padding: 15px 62px 15px 18px; font-size: 1rem;
	}
	.cg-subarrow {
		display: inline-flex; position: absolute; right: 14px; top: 50%;
		transform: translateY(-50%); padding: 7px; border-radius: 10px; background: transparent;
	}
	.cg-subarrow svg { transform: rotate(0deg) !important; transition: transform 0.2s; }
	.cg-item.is-open > .cg-subarrow svg { transform: rotate(180deg) !important; }

	/* Submenús = accordions */
	.cg-submenu, .cg-submenu .cg-submenu {
		position: static; opacity: 1; visibility: visible; transform: none;
		box-shadow: none; border: none; min-width: 0;
		background: #faf7fc; border-radius: 0; padding: 0 0 0 18px;
		max-height: 0; overflow: hidden; transition: max-height 0.35s ease;
	}
	.cg-item.is-open > .cg-submenu { max-height: 900px; }
	.cg-submenu .cg-item { border-bottom: none; }
	.cg-submenu .cg-item--has-children > .cg-link { font-weight: 700; color: var(--tc-color-secondary); }
	.cg-submenu--nivel2 { padding-left: 18px; }

	.cg-nav-drawer__foot { padding: 20px 18px 30px; display: flex; flex-direction: column; gap: 4px; }
	.cg-nav-drawer__link {
		display: block; padding: 11px 0; color: var(--tc-text-dark);
		font-weight: 600; text-decoration: none; font-size: 0.95rem;
	}

	/* Cierre del drawer dentro de la barra */
	.cg-drawer-close {
		display: flex; align-items: center; justify-content: space-between;
		padding: 16px 18px; border-bottom: 2px solid #f0eef4; margin-bottom: 4px;
	}
	.cg-drawer-close__brand { font-weight: 800; color: var(--tc-color-secondary); font-size: 1.1rem; }
}

@media (min-width: 992px) {
	.cg-drawer-overlay, .cg-drawer-close, .cg-nav-drawer__foot { display: none; }
}

@media (max-width: 767px) {
	.cg-logo img { max-height: 40px; }
	.cg-bar__inner { padding: 8px 14px; gap: 8px; }
	.cg-footer__inner { grid-template-columns: 1fr 1fr; gap: 28px; padding: 40px 16px 26px; }
	.cg-footer__col--brand { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
	.cg-footer__inner { grid-template-columns: 1fr; }
	.cg-search { padding-top: 8vh; }
	.cg-icon-btn { width: 40px; height: 40px; }
}

/* Accesibilidad: foco visible */
.cg-link:focus-visible, .cg-icon-btn:focus-visible, .cg-subarrow:focus-visible,
.cg-hamburger:focus-visible, .cg-search__input:focus-visible {
	outline: 3px solid var(--tc-color-accent); outline-offset: 2px;
}

.cg-footer__bottom a:hover { text-decoration: underline; }
