@tailwind base;
@tailwind components;
@tailwind utilities;

/*
 * Rivera Hogar 2026 — Estilos personalizados
 * Complementa Tailwind CSS con variables de marca y overrides puntuales.
 */

/* Alpine.js: ocultar elementos antes de que inicialice */
[x-cloak] {
    display: none !important;
}

/* ─── Variables de marca ──────────────────────────────────────────────────── */
:root {
    --rh-rojo: #B80B0B;
    --rh-rojo-dark: #8f0808;
    --rh-rojo-soft: #f5d5d5;
    --rh-gris: #4a4a4a;
    --rh-gris-claro: #f5f5f5;
    --rh-borde: #e5e7eb;
    --rh-sombra: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* ─── Scrollbar personalizada ─────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--rh-rojo);
    border-radius: 3px;
}

/* ─── Botón primario (rojo Rivera) ───────────────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: var(--rh-rojo);
    color: #fff;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.15s ease, transform 0.1s ease;
    cursor: pointer;
    border: none;
    text-decoration: none;
}

.btn-primary:hover {
    background-color: var(--rh-rojo-dark);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ─── Botón "en carrito" (verde) ─────────────────────────────────────────── */
.btn-incart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: #16a34a;
    color: #fff;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
}

.btn-incart:hover {
    background-color: #15803d;
}

/* ─── Botón secundario (outline) ─────────────────────────────────────────── */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: transparent;
    color: var(--rh-rojo);
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: 2px solid var(--rh-rojo);
    transition: all 0.15s ease;
    cursor: pointer;
    text-decoration: none;
}

.btn-secondary:hover {
    background-color: var(--rh-rojo);
    color: #fff;
}

/* ─── Ocultar botón "Agregar" hasta hover (evita flash en carga) ─────────── */
/* !important necesario para ganar a disabled:opacity-60 de Tailwind cuando loading=true */
@media (min-width: 640px) {
    .product-card:not(:hover) .btn-agregar {
        opacity: 0 !important;
    }

    .product-card:hover .btn-agregar {
        opacity: 1;
    }
}

/* ─── Product card ───────────────────────────────────────────────────────── */
.product-card {
    background: #fff;
    border-radius: 0.75rem;
    border: 1px solid var(--rh-borde);
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: var(--rh-sombra);
    transform: translateY(-2px);
}

.product-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    padding: 0.5rem;
    background: #fff;
}

.product-card .card-body {
    padding: 0.5rem 1rem 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-card .card-title {
    font-size: 0.9rem;
    line-height: 1.3;
    color: var(--rh-gris);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card .card-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--rh-rojo);
}

.product-card .card-lista {
    font-size: 0.8rem;
    color: #9ca3af;
    text-decoration: line-through;
}

.product-card .card-descuento {
    display: inline-block;
    background: var(--rh-rojo-soft);
    color: var(--rh-rojo);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
}

.banner-card {
    background-color: #fff;
    box-shadow:
        inset 0 0 0 1px rgba(17, 24, 39, 0.06),
        0 2px 10px rgba(17, 24, 39, 0.05);
}

.banner-card:hover {
    box-shadow:
        inset 0 0 0 1px rgba(17, 24, 39, 0.06),
        0 4px 14px rgba(17, 24, 39, 0.07);
}

/* ─── Badge del carrito ──────────────────────────────────────────────────── */
.cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--rh-rojo);
    color: #fff;
    font-size: 10px;
    line-height: 9px;
    font-weight: 700;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    text-align: center;
}

/* ─── Hero search bar ────────────────────────────────────────────────────── */
.hero-search-input {
    width: 100%;
    padding: 1rem 1.5rem;
    border-radius: 9999px;
    border: none;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    font-size: 1rem;
    color: #1f2937;
    outline: none;
}

.hero-search-input:focus {
    box-shadow: 0 0 0 3px rgba(184, 11, 11, 0.3), 0 8px 30px rgba(0, 0, 0, 0.15);
}

/* ─── Dropdown de búsqueda ───────────────────────────────────────────────── */
.search-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    z-index: 100;
    max-height: 280px;
    overflow-y: auto;
}

.search-dropdown a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #374151;
    transition: background 0.1s;
    font-size: 0.9rem;
    border-bottom: 1px solid #f3f4f6;
}

.search-dropdown a:last-child {
    border-bottom: none;
}

.search-dropdown a:hover {
    background: #f9fafb;
}

.search-dropdown .type-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
    font-weight: 600;
    white-space: nowrap;
}

.search-dropdown .type-producto {
    background: #e5e7eb;
    color: #6b7280;
}

.search-dropdown .type-categoria {
    background: var(--rh-rojo-soft);
    color: var(--rh-rojo);
}

/* ─── Spinner de carga ───────────────────────────────────────────────────── */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

/* ─── Cart drawer ───────────────────────────────────────────────────────── */
.cart-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 40;
    backdrop-filter: blur(1px);
}

.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 100%;
    max-width: 26rem;
    background: #fff;
    z-index: 50;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
}

/* ─── Form de checkout ───────────────────────────────────────────────────── */
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--rh-gris);
    margin-bottom: 0.35rem;
}

.form-input {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--rh-borde);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    color: #1f2937;
    transition: border-color 0.15s;
    outline: none;
    background: #fff;
}

.form-input:focus {
    border-color: var(--rh-rojo);
}

.form-input.error {
    border-color: #ef4444;
}

.form-error {
    font-size: 0.75rem;
    color: #ef4444;
    margin-top: 0.25rem;
}

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.text-rojo {
    color: var(--rh-rojo);
}

.bg-rojo {
    background-color: var(--rh-rojo);
}

.border-rojo {
    border-color: var(--rh-rojo);
}

/* Ocultar scrollbar manteniendo scroll funcional (slider horizontal) */
.scrollbar-hide {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}