/* ==========================================================================
   Tienda Base - Sistema de Temas y Estilos Base
   ========================================================================== */

/* Variables CSS Dinámicas */
:root {
    /* Colores principales (se sobreescriben con PHP) */
    --color-primario: #007bff;
    --color-secundario: #6c757d;
    --color-fondo: #f8f9fa;
    --radio-bordes: 12px;

    /* Tema Claro (default) */
    --bg-body: var(--color-fondo);
    --bg-card: #ffffff;
    --bg-card-hover: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.15);
    --navbar-bg: var(--color-primario);
    --input-bg: #ffffff;
    --input-border: #dee2e6;
}

/* Tema Oscuro */
[data-theme="oscuro"] {
    --bg-body: #0f0f0f;
    --bg-card: #1a1a1a;
    --bg-card-hover: #222222;
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    --text-muted: #6c757d;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --input-bg: #2a2a2a;
    --input-border: #404040;
}

/* ========== Estilos Base ========== */
body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ========== Cards de Producto - Estilos ========== */

/* Estilo Moderno (default) */
.producto-card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--radio-bordes);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.producto-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primario), var(--color-secundario));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.producto-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    background: var(--bg-card-hover);
}

.producto-card:hover::before {
    opacity: 1;
}

/* Estilo Clásico */
.estilo-clasico .producto-card {
    border: 1px solid var(--border-color);
    box-shadow: none;
    border-radius: 8px;
}

.estilo-clasico .producto-card::before {
    display: none;
}

.estilo-clasico .producto-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primario);
}

/* Estilo Minimal */
.estilo-minimal .producto-card {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.estilo-minimal .producto-card::before {
    display: none;
}

.estilo-minimal .producto-card:hover {
    transform: none;
    box-shadow: none;
    background: rgba(var(--color-primario), 0.05);
}

.estilo-minimal .producto-img {
    border-radius: 8px;
}

/* ========== Imágenes de Producto ========== */
.producto-img {
    height: 200px;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.producto-card:hover .producto-img {
    transform: scale(1.08);
}

.estilo-minimal .producto-card:hover .producto-img {
    transform: scale(1.02);
}

/* ========== Badge de Oferta ========== */
.oferta-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 20px;
    z-index: 10;
    box-shadow: 0 4px 15px rgba(255, 75, 43, 0.4);
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

/* ========== Precios ========== */
.precio {
    color: var(--text-primary);
}

.precio .precio-actual {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-primario);
}

.precio .precio-original {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-decoration: line-through;
}

/* ========== Botones ========== */
.btn-tienda {
    background: linear-gradient(135deg, var(--color-primario) 0%, var(--color-secundario) 100%);
    border: none;
    color: white;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: 25px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-tienda::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-tienda:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--color-primario), 0.4);
    color: white;
}

.btn-tienda:hover::before {
    left: 100%;
}

.btn-tienda:active {
    transform: translateY(0);
}

/* Botón agregado al carrito */
.btn-tienda.added {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}

/* ========== Categorías Sidebar ========== */
.categorias-card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--radio-bordes);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.categorias-card .card-header {
    background: linear-gradient(135deg, var(--color-primario) 0%, var(--color-secundario) 100%);
    color: white;
    font-weight: 600;
    border: none;
}

.categorias-card .list-group-item {
    background: var(--bg-card);
    color: var(--text-primary);
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    transition: all 0.2s ease;
}

.categorias-card .list-group-item:hover {
    background: rgba(var(--color-primario), 0.1);
    padding-left: 20px;
}

.categorias-card .list-group-item.active {
    background: var(--color-primario);
    color: white;
}

/* ========== Buscador ========== */
.form-control {
    background: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-primary);
    border-radius: var(--radio-bordes);
}

.form-control:focus {
    background: var(--input-bg);
    border-color: var(--color-primario);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primario), 0.15);
}

/* ========== Navbar ========== */
.navbar-tienda {
    background: linear-gradient(135deg, var(--color-primario) 0%, var(--color-secundario) 100%) !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.navbar-tienda.scrolled {
    background: rgba(var(--color-primario), 0.95) !important;
}

/* ========== Animaciones de Entrada ========== */
.animaciones-on .producto-card {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.6s ease forwards;
}

.animaciones-on .producto-card:nth-child(1) {
    animation-delay: 0.1s;
}

.animaciones-on .producto-card:nth-child(2) {
    animation-delay: 0.2s;
}

.animaciones-on .producto-card:nth-child(3) {
    animation-delay: 0.3s;
}

.animaciones-on .producto-card:nth-child(4) {
    animation-delay: 0.4s;
}

.animaciones-on .producto-card:nth-child(5) {
    animation-delay: 0.5s;
}

.animaciones-on .producto-card:nth-child(6) {
    animation-delay: 0.6s;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sin animaciones */
.animaciones-off .producto-card {
    opacity: 1;
    transform: none;
    animation: none;
}

/* ========== Stock Badge ========== */
.stock-badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.stock-badge.disponible {
    background: rgba(40, 167, 69, 0.15);
    color: #28a745;
}

.stock-badge.bajo {
    background: rgba(255, 193, 7, 0.15);
    color: #d39e00;
}

.stock-badge.agotado {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

/* ========== Toast Notification ========== */
.toast-carrito {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(40, 167, 69, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9999;
    transform: translateX(150%);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-carrito.show {
    transform: translateX(0);
}

.toast-carrito i {
    font-size: 1.5rem;
}

/* ========== Responsivo ========== */
@media (max-width: 768px) {
    .producto-img {
        height: 160px;
    }

    .precio .precio-actual {
        font-size: 1.2rem;
    }

    .toast-carrito {
        left: 20px;
        right: 20px;
        bottom: 20px;
    }
}

/* ========== Productos por Fila ========== */
.productos-2-por-fila {
    grid-template-columns: repeat(2, 1fr) !important;
}

.productos-3-por-fila {
    grid-template-columns: repeat(3, 1fr) !important;
}

.productos-4-por-fila {
    grid-template-columns: repeat(4, 1fr) !important;
}

@media (max-width: 992px) {
    .productos-4-por-fila {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 768px) {

    .productos-3-por-fila,
    .productos-4-por-fila {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 576px) {

    .productos-2-por-fila,
    .productos-3-por-fila,
    .productos-4-por-fila {
        grid-template-columns: 1fr !important;
    }
}

/* ========== Info Cards ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radio-bordes);
}

.card-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    color: var(--text-primary);
}

/* ========== Alert ========== */
.alert-info {
    background: rgba(var(--color-primario), 0.1);
    border: 1px solid rgba(var(--color-primario), 0.2);
    color: var(--text-primary);
    border-radius: var(--radio-bordes);
}

/* ========== Links ========== */
a {
    color: var(--color-primario);
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-secundario);
}

.text-dark {
    color: var(--text-primary) !important;
}

.text-muted {
    color: var(--text-secondary) !important;
}

/* ========== Floating Cart ========== */
.floating-cart {
    position: fixed !important;
    bottom: 25px !important;
    right: 25px !important;
    z-index: 9999 !important;
    background: linear-gradient(135deg, var(--color-primario) 0%, var(--color-secundario) 100%) !important;
    color: white !important;
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
    text-decoration: none !important;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    border: none !important;
}

.floating-cart:hover {
    transform: scale(1.1) rotate(5deg) !important;
    color: white !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5) !important;
}

.floating-cart .bi {
    font-size: 1.5rem !important;
    color: white !important;
}

.floating-cart .badge {
    position: absolute !important;
    top: 5px !important;
    right: 5px !important;
    font-size: 0.7rem !important;
    padding: 4px 6px !important;
    border-radius: 50% !important;
    border: 2px solid white !important;
    background-color: #dc3545 !important;
}

@media (max-width: 768px) {
    .floating-cart {
        bottom: 20px !important;
        right: 20px !important;
        width: 55px !important;
        height: 55px !important;
    }
}

/* ========== Validación de Formulario ========== */
.is-invalid {
    border-color: #dc3545 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right calc(0.375em + 0.1875rem) center !important;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem) !important;
}