/*================================================================
  1️⃣  RESET GLOBAL
================================================================*/
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Mejora de accesibilidad: foco visible */
:focus-visible {
    outline: 2px solid var(--color-focus, #ff9900);
    outline-offset: 2px;
}

/*================================================================
  2️⃣  DESIGN TOKENS (variables)
================================================================*/
:root {
    /* ---------- Paleta de colores ---------- */
    --color-primary-dark:   #131921;   /* barra superior */
    --color-primary-light:  #232f3e;   /* barra de búsqueda */
    --color-accent:         #febd69;   /* amarillo “Add to Cart” */
    --color-accent-hover:   #f3a847;
    --color-primary-btn:    #ffd814;   /* botón “Buy now” */
    --color-primary-btn-h:  #f7ca00;
    --color-success:        #00a859;
    --color-error:          #d93025;
    --color-warning:        #ff9900;
    --color-focus:          #ff9900;   /* foco accesible */

    /* ---------- Escala de espaciado (4 px base) ---------- */
    --space-xxs: 0.125rem;   /* 2 px  */
    --space-xs:  0.25rem;    /* 4 px  */
    --space-s:   0.5rem;     /* 8 px  */
    --space-m:   0.75rem;    /* 12 px */
    --space-l:   1rem;       /* 16 px */
    --space-xl:  1.5rem;     /* 24 px */
    --space-xxl: 2rem;      /* 32 px */

    /* ---------- Tipografía ---------- */
    --font-family-base: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-size-base: 1rem;               /* 16 px */
    --font-size-xs:   0.75rem;            /* 12 px */
    --font-size-sm:   0.875rem;           /* 14 px */
    --font-size-lg:   1.125rem;           /* 18 px */
    --font-size-xl:   1.25rem;            /* 20 px */

    /* ---------- Bordes, sombras y radios ---------- */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.12);
    --shadow-md: 0 4px 6px rgba(0,0,0,.15);
    --shadow-lg: 0 10px 20px rgba(0,0,0,.2);

    /* ---------- Transiciones ---------- */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-ease-in-out: cubic-bezier(.4,0,.2,1);

    /* ---------- Colores y fondo por defecto ---------- */
    --color-bg-page: #eaeded;     /* gris claro de fondo */
    --color-text-primary: #0f1111;
}

/* Tema oscuro (opcional) */
@media (prefers-color-scheme: dark) {
    :root {
        --color-primary-dark:   #0a0a0a;
        --color-primary-light:  #1c1c1c;
        --color-bg-page:        #121212;
        --color-text-primary:   #e0e0e0;
    }
}

/*================================================================
  3️⃣  ESTILOS BASE (body, tipografía, enlaces)
================================================================*/
html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}
body {
    background-color: var(--color-bg-page);
    color: var(--color-text-primary);
    font-family: var(--font-family-base);
    font-size: var(--font-size-base);
    line-height: 1.5;
}

/* Enlaces */
a {
    color: var(--color-primary-dark);
    text-decoration: none;
    transition: color var(--transition-base);
}
a:hover,
a:focus {
    color: var(--color-accent);
    text-decoration: underline;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--space-s);
    color: var(--color-primary-dark);
}
h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

/* Párrafos y listas */
p { margin-bottom: var(--space-m); }
ul, ol { margin-left: var(--space-xl); }
li { margin-bottom: var(--space-xxs); }

/*================================================================
  4️⃣  BOTONES (reutilizables)
================================================================*/
.btn {
    display: inline-block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    border: none;
    border-radius: var(--radius-md);
    padding: var(--space-s) var(--space-l);
    transition: background-color var(--transition-base),
                box-shadow var(--transition-fast);
}

/* Primario (Comprar) */
.btn-primary {
    background-color: var(--color-primary-btn);
    color: #111;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover,
.btn-primary:focus-visible {
    background-color: var(--color-primary-btn-h);
    box-shadow: var(--shadow-md);
}

/* Secundario (Añadir al carrito) */
.btn-secondary {
    background-color: var(--color-accent);
    color: #111;
}
.btn-secondary:hover,
.btn-secondary:focus-visible {
    background-color: var(--color-accent-hover);
}

/* Ghost (solo borde) */
.btn-ghost {
    background: transparent;
    border: 2px solid var(--color-primary-dark);
    color: var(--color-primary-dark);
}
.btn-ghost:hover,
.btn-ghost:focus-visible {
    background: rgba(0,0,0,.04);
}

/* Desactivado */
.btn[disabled],
.btn.disabled {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}

/*================================================================
  5️⃣  NAVEGACIÓN (header + dropdown + móvil)
================================================================*/
.site-header {
    background-color: var(--color-primary-dark);
    color: #fff;
    padding: var(--space-s) var(--space-m);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Logo */
.site-header .logo {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-accent);
}

/* Contenedor principal de navegación */
.nav-primary {
    display: flex;
    gap: var(--space-m);
}

/* Items de la barra */
.nav-item {
    position: relative;
}
.nav-link {
    color: #fff;
    font-size: var(--font-size-sm);
    padding: var(--space-xs) var(--space-s);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}
.nav-link:hover,
.nav-link:focus-visible {
    background-color: rgba(255,255,255,.1);
}

/* Dropdown */
.nav-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    min-width: 200px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity var(--transition-fast),
                transform var(--transition-fast);
    z-index: 1000;
}
.nav-item:hover .nav-dropdown,
.nav-item:focus-within .nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Items del dropdown */
.nav-dropdown a {
    display: block;
    color: var(--color-primary-dark);
    padding: var(--space-s) var(--space-m);
    font-size: var(--font-size-xs);
}
.nav-dropdown a:hover,
.nav-dropdown a:focus-visible {
    background: var(--color-accent);
}

/* Botón hamburguesa (solo móvil) */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

/*================================================================
  6️⃣  TARJETA DE PRODUCTO
================================================================*/
.product-card {
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-fast),
                box-shadow var(--transition-base);
}
.product-card:hover,
.product-card:focus-within {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Imagen del producto */
.product-card__img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: contain;
    background: #fafafa;
}

/* Contenedor interno */
.product-card__body {
    padding: var(--space-m);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Título */
.product-card__title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-primary-dark);
    margin-bottom: var(--space-xxs);
    line-height: 1.3;
    flex-grow: 1;
}

/* Precio */
.product-card__price {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-accent);
    margin-top: var(--space-xs);
}

/* Valoración (estrellas) */
.product-card__rating {
    display: flex;
    align-items: center;
    gap: var(--space-xxs);
    margin-top: var(--space-xs);
}
.product-card__rating span {
    color: #ffa41c;
    font-size: 0.875rem;
}

/* Badges (ej. “Prime”, “En oferta”) */
.product-card__badge {
    position: absolute;
    top: var(--space-xs);
    left: var(--space-xs);
    background: var(--color-accent);
    color: #111;
    padding: var(--space-xxs) var(--space-xs);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

/*================================================================
  7️⃣  FORMULARIOS Y CONTROLES
================================================================*/
.form-group {
    margin-bottom: var(--space-m);
    display: flex;
    flex-direction: column;
}
label {
    margin-bottom: var(--space-xxs);
    font-size: var(--font-size-sm);
    color: var(--color-primary-dark);
}
input,
select,
textarea {
    padding: var(--space-s) var(--space-m);
    border: 1px solid #ccc;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast);
}
input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(255,191,105,.3);
    outline: none;
}

/* Estado de error */
.input-error {
    border-color: var(--color-error);
}
.error-msg {
    color: var(--color-error);
    font-size: var(--font-size-xs);
    margin-top: var(--space-xxs);
}

/*================================================================
  8️⃣  UTILIDADES (helpers)
================================================================*/
/* Márgenes top y bottom */
.mt-xxs { margin-top: var(--space-xxs) !important; }
.mt-xs  { margin-top: var(--space-xs)  !important; }
.mt-s   { margin-top: var(--space-s)   !important; }
.mt-m   { margin-top: var(--space-m)   !important; }
.mt-l   { margin-top: var(--space-l)   !important; }
.mt-xl  { margin-top: var(--space-xl)  !important; }

.mb-xxs { margin-bottom: var(--space-xxs) !important; }
.mb-xs  { margin-bottom: var(--space-xs)  !important; }
.mb-s   { margin-bottom: var(--space-s)   !important; }
.mb-m   { margin-bottom: var(--space-m)   !important; }
.mb-l   { margin-bottom: var(--space-l)   !important; }
.mb-xl  { margin-bottom: var(--space-xl)  !important; }

/* Flex helpers */
.d-flex { display: flex !important; }
.flex-col { flex-direction: column !important; }
.justify-center { justify-content: center !important; }
.align-center   { align-items: center !important; }
.gap-xxs { gap: var(--space-xxs) !important; }
.gap-xs  { gap: var(--space-xs)  !important; }
.gap-s   { gap: var(--space-s)   !important; }
.gap-m   { gap: var(--space-m)   !important; }
.gap-l   { gap: var(--space-l)   !important; }

/* Ocultos */
.hidden { display: none !important; }
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Texto truncado */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/*================================================================
  9️⃣  CONTENEDORES Y GRID DE PRODUCTOS
================================================================*/
.container {
    width: 100%;
    margin-inline: auto;
    padding-inline: var(--space-m);
}
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-l);
}

/*================================================================
  🔟  BREAKPOINTS (mobile‑first)
================================================================*/
@media (min-width: 480px) {
    .container { max-width: 440px; }
}
@media (min-width: 640px) {
    .container { max-width: 600px; }
}
@media (min-width: 768px) {
    .container { max-width: 740px; }

    .nav-toggle { display: none; }
    .nav-primary {
        position: static;
        flex-direction: row;
        gap: var(--space-m);
    }
}
@media (min-width: 1024px) {
    .container { max-width: 960px; }
}
@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .nav-primary {
        position: fixed;
        top: 0;
        right: -100%;
        height: 100vh;
        width: 260px;
        background: var(--color-primary-dark);
        flex-direction: column;
        padding-top: var(--space-xxl);
        transition: right var(--transition-base);
        gap: var(--space-s);
        z-index: 999;
    }
    .nav-primary.show { right: 0; }
    .nav-link { color: #fff; }
    .nav-dropdown {
        position: static;
        background: transparent;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        padding-left: var(--space-m);
    }
}
