/* ============================================================
   ModaStore - Estilos Globales
   Bootstrap 5 + CSS personalizado
   ============================================================ */

/* ============================================================
   VARIABLES CSS
   ============================================================ */
:root {
    --ms-primary:     #2563eb;
    --ms-primary-dark:#1d4ed8;
    --ms-secondary:   #64748b;
    --ms-accent:      #f59e0b;
    --ms-danger:      #ef4444;
    --ms-success:     #22c55e;
    --ms-dark:        #0f172a;
    --ms-light-bg:    #f8fafc;
    --ms-border:      #e2e8f0;
    --ms-shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --ms-shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --ms-shadow-lg:   0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --ms-radius:      .5rem;
    --ms-radius-lg:   1rem;
    --ms-transition:  all .2s ease;
    --font-body:      'Inter', sans-serif;
    --font-heading:   'Playfair Display', serif;
}

/* ============================================================
   RESET Y BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    color: #1e293b;
    background: #fff;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .font-display {
    font-family: var(--font-heading);
}

a { transition: var(--ms-transition); }

img { max-width: 100%; height: auto; }

.main-content { min-height: calc(100vh - 300px); }

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
    padding: .75rem 0;
    z-index: 1030;
}

.navbar-brand { font-size: 1.5rem !important; }

.navbar .nav-link {
    font-weight: 500;
    font-size: .9rem;
    color: #374151;
    padding: .5rem .75rem;
    border-radius: var(--ms-radius);
    transition: var(--ms-transition);
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: var(--ms-primary);
    background: #eff6ff;
}

.topbar { font-size: .8rem; }

/* Mega menu */
.mega-menu {
    border-radius: var(--ms-radius-lg) !important;
    border: 1px solid var(--ms-border) !important;
    animation: fadeInDown .15s ease;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Búsqueda */
#searchForm { position: relative; max-width: 420px; }

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--ms-border);
    border-top: none;
    border-radius: 0 0 var(--ms-radius) var(--ms-radius);
    z-index: 9999;
    max-height: 320px;
    overflow-y: auto;
    display: none;
}

.search-suggestions.active { display: block; }

.suggestion-item {
    padding: .6rem 1rem;
    cursor: pointer;
    font-size: .875rem;
    border-bottom: 1px solid #f1f5f9;
    transition: var(--ms-transition);
    display: flex;
    align-items: center;
    gap: .75rem;
}

.suggestion-item:hover { background: #f8fafc; }
.suggestion-item img { width: 40px; height: 40px; object-fit: cover; border-radius: .25rem; }

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero-section {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #7c3aed 100%);
    color: white;
    padding: 5rem 0;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: rgba(255,255,255,.05);
    border-radius: 50%;
}

.hero-section h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1.2;
    margin-bottom: 1.5rem;
}

/* ============================================================
   CARDS DE PRODUCTOS
   ============================================================ */
.product-card {
    border: 1px solid var(--ms-border);
    border-radius: var(--ms-radius-lg);
    overflow: hidden;
    transition: var(--ms-transition);
    background: #fff;
    height: 100%;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--ms-shadow-lg);
    border-color: transparent;
}

.product-card-img {
    position: relative;
    overflow: hidden;
    aspect-ratio: 3/4;
    background: #f8fafc;
}

.product-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s ease;
}

.product-card:hover .product-card-img img {
    transform: scale(1.06);
}

/* Badges sobre imagen */
.product-badge {
    position: absolute;
    top: .6rem;
    left: .6rem;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

/* Acciones sobre imagen */
.product-actions {
    position: absolute;
    top: .6rem;
    right: .6rem;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    opacity: 0;
    transform: translateX(10px);
    transition: var(--ms-transition);
}

.product-card:hover .product-actions {
    opacity: 1;
    transform: translateX(0);
}

.product-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ms-shadow);
    cursor: pointer;
    font-size: .875rem;
    transition: var(--ms-transition);
    text-decoration: none;
    color: #374151;
}

.product-action-btn:hover {
    background: var(--ms-primary);
    color: white;
    transform: scale(1.1);
}

.product-action-btn.active { background: #fee2e2; color: var(--ms-danger); }

/* Info de producto */
.product-card-body { padding: 1rem; }

.product-card-title {
    font-size: .9rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: .25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card-brand { font-size: .75rem; color: var(--ms-secondary); }

.product-price { font-size: 1rem; font-weight: 700; color: var(--ms-primary); }
.product-price-old { font-size: .825rem; color: var(--ms-secondary); text-decoration: line-through; }
.product-price-offer { color: var(--ms-danger); }

/* Botón añadir al carrito */
.btn-add-cart {
    width: 100%;
    padding: .5rem;
    font-size: .85rem;
    font-weight: 600;
    border-radius: var(--ms-radius);
    border: 2px solid var(--ms-primary);
    background: transparent;
    color: var(--ms-primary);
    transition: var(--ms-transition);
    cursor: pointer;
}

.btn-add-cart:hover {
    background: var(--ms-primary);
    color: white;
}

/* ============================================================
   SECCIÓN CATEGORÍAS
   ============================================================ */
.category-card {
    border-radius: var(--ms-radius-lg);
    overflow: hidden;
    position: relative;
    aspect-ratio: 1;
    cursor: pointer;
    transition: var(--ms-transition);
}

.category-card:hover { transform: translateY(-4px); box-shadow: var(--ms-shadow-lg); }

.category-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s ease;
}

.category-card:hover img { transform: scale(1.08); }

.category-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,.7) 0%, transparent 60%);
    display: flex;
    align-items: flex-end;
    padding: 1rem;
}

.category-card-overlay h6 {
    color: white;
    font-weight: 700;
    font-size: 1rem;
    margin: 0;
    text-shadow: 0 1px 3px rgba(0,0,0,.5);
}

/* Icono de categoría (fallback sin imagen) */
.category-icon-card {
    border-radius: var(--ms-radius-lg);
    padding: 2rem 1rem;
    text-align: center;
    background: var(--ms-light-bg);
    border: 2px solid var(--ms-border);
    transition: var(--ms-transition);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.category-icon-card:hover {
    border-color: var(--ms-primary);
    background: #eff6ff;
    color: var(--ms-primary);
    transform: translateY(-3px);
    box-shadow: var(--ms-shadow-md);
}

.category-icon-card .icon { font-size: 2rem; margin-bottom: .5rem; }
.category-icon-card h6 { font-size: .9rem; font-weight: 600; margin: 0; }

/* ============================================================
   FILTROS DEL CATÁLOGO
   ============================================================ */
.filters-sidebar {
    background: #fff;
    border: 1px solid var(--ms-border);
    border-radius: var(--ms-radius-lg);
    padding: 1.25rem;
}

.filter-group { margin-bottom: 1.5rem; }
.filter-group-title {
    font-weight: 700;
    font-size: .875rem;
    color: #374151;
    margin-bottom: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* Filtro de colores */
.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--ms-transition);
    display: inline-block;
}

.color-swatch:hover,
.color-swatch.active {
    border-color: var(--ms-primary);
    transform: scale(1.2);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--ms-primary);
}

/* Rango de precio */
.price-range { display: flex; gap: .5rem; align-items: center; }
.price-range input[type="range"] { flex: 1; accent-color: var(--ms-primary); }

/* ============================================================
   DETALLE DE PRODUCTO
   ============================================================ */
.product-gallery { position: sticky; top: 80px; }

.gallery-main {
    border-radius: var(--ms-radius-lg);
    overflow: hidden;
    aspect-ratio: 3/4;
    border: 1px solid var(--ms-border);
}

.gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
}

.gallery-thumbs {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: .75rem;
}

.gallery-thumb {
    width: 70px;
    height: 70px;
    border-radius: .375rem;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--ms-transition);
}

.gallery-thumb:hover,
.gallery-thumb.active { border-color: var(--ms-primary); }

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Selector de talla */
.size-selector { display: flex; gap: .5rem; flex-wrap: wrap; }

.size-option {
    min-width: 44px;
    padding: .4rem .75rem;
    border: 2px solid var(--ms-border);
    border-radius: .375rem;
    text-align: center;
    cursor: pointer;
    font-size: .875rem;
    font-weight: 600;
    transition: var(--ms-transition);
    background: white;
}

.size-option:hover { border-color: var(--ms-primary); color: var(--ms-primary); }
.size-option.active { border-color: var(--ms-primary); background: var(--ms-primary); color: white; }
.size-option.out-of-stock { opacity: .4; cursor: not-allowed; text-decoration: line-through; }

/* Selector de color */
.color-selector { display: flex; gap: .6rem; flex-wrap: wrap; }

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    box-shadow: 0 0 0 1px var(--ms-border);
    transition: var(--ms-transition);
}

.color-option:hover,
.color-option.active {
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--ms-primary);
    transform: scale(1.15);
}

/* Cantidad */
.qty-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--ms-border);
    border-radius: var(--ms-radius);
    overflow: hidden;
    width: fit-content;
}

.qty-btn {
    width: 38px;
    height: 38px;
    background: #f8fafc;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--ms-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover { background: var(--ms-primary); color: white; }

.qty-input {
    width: 50px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--ms-border);
    border-right: 1px solid var(--ms-border);
    font-weight: 600;
    padding: .4rem 0;
    -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ============================================================
   CARRITO
   ============================================================ */
.cart-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--ms-border);
    border-radius: var(--ms-radius-lg);
    background: white;
    transition: var(--ms-transition);
}

.cart-item:hover { box-shadow: var(--ms-shadow-md); }

.cart-item-img {
    width: 80px;
    height: 100px;
    border-radius: .5rem;
    object-fit: cover;
    flex-shrink: 0;
}

.cart-summary {
    background: white;
    border: 1px solid var(--ms-border);
    border-radius: var(--ms-radius-lg);
    padding: 1.5rem;
    position: sticky;
    top: 80px;
}

/* ============================================================
   CHECKOUT
   ============================================================ */
.checkout-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 2rem;
}

.checkout-step {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--ms-secondary);
}

.checkout-step.active { color: var(--ms-primary); }
.checkout-step.done   { color: var(--ms-success); }

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ms-border);
    color: var(--ms-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}

.checkout-step.active .step-number { background: var(--ms-primary); color: white; }
.checkout-step.done .step-number   { background: var(--ms-success);  color: white; }

.step-divider { flex: 1; height: 2px; background: var(--ms-border); max-width: 60px; }
.step-divider.done { background: var(--ms-success); }

/* ============================================================
   PANELES (Admin / Vendedor)
   ============================================================ */
.sidebar-panel {
    background: white;
    border-right: 1px solid var(--ms-border);
    min-height: 100vh;
    padding: 1.5rem 0;
    width: 260px;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1020;
    overflow-y: auto;
    transition: transform .3s ease;
}

.sidebar-panel .sidebar-logo {
    padding: 1rem 1.5rem 1.5rem;
    border-bottom: 1px solid var(--ms-border);
    margin-bottom: 1rem;
}

.sidebar-nav-item {
    padding: .6rem 1.5rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .875rem;
    font-weight: 500;
    color: #4b5563;
    text-decoration: none;
    border-radius: 0;
    transition: var(--ms-transition);
    border-left: 3px solid transparent;
}

.sidebar-nav-item:hover {
    background: #f8fafc;
    color: var(--ms-primary);
    border-left-color: var(--ms-primary);
}

.sidebar-nav-item.active {
    background: #eff6ff;
    color: var(--ms-primary);
    font-weight: 600;
    border-left-color: var(--ms-primary);
}

.sidebar-nav-item .icon { width: 20px; text-align: center; flex-shrink: 0; }

.panel-content {
    margin-left: 260px;
    padding: 2rem;
    min-height: 100vh;
    background: var(--ms-light-bg);
}

/* Stat cards */
.stat-card {
    background: white;
    border-radius: var(--ms-radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--ms-border);
    transition: var(--ms-transition);
}

.stat-card:hover { box-shadow: var(--ms-shadow-md); }

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--ms-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

/* ============================================================
   VALORACIONES
   ============================================================ */
.stars-rating { color: #f59e0b; letter-spacing: .05em; }
.rating-bar { height: 8px; border-radius: 4px; background: #e2e8f0; overflow: hidden; }
.rating-bar-fill { height: 100%; background: #f59e0b; border-radius: 4px; }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-control:focus,
.form-select:focus {
    border-color: var(--ms-primary);
    box-shadow: 0 0 0 .2rem rgba(37,99,235,.15);
}

.form-label { font-weight: 500; font-size: .875rem; color: #374151; }

.input-group .btn { border-radius: 0 var(--ms-radius) var(--ms-radius) 0; }

/* ============================================================
   BOTONES
   ============================================================ */
.btn { font-weight: 500; transition: var(--ms-transition); }

.btn-primary {
    background: var(--ms-primary);
    border-color: var(--ms-primary);
}

.btn-primary:hover {
    background: var(--ms-primary-dark);
    border-color: var(--ms-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--ms-shadow-md);
}

.btn-outline-primary { color: var(--ms-primary); border-color: var(--ms-primary); }
.btn-outline-primary:hover { background: var(--ms-primary); border-color: var(--ms-primary); }

.btn-lg { padding: .8rem 2rem; font-size: 1rem; }
.btn-icon { width: 38px; height: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ============================================================
   BADGES
   ============================================================ */
.badge-offer    { background: var(--ms-danger);  color: white; }
.badge-new      { background: var(--ms-success); color: white; }
.badge-featured { background: var(--ms-accent);  color: white; }

/* ============================================================
   ESTADOS DE PEDIDO
   ============================================================ */
.status-badge {
    padding: .3rem .75rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}

.status-pendiente   { background: #fef3c7; color: #92400e; }
.status-confirmado  { background: #dbeafe; color: #1e40af; }
.status-preparando  { background: #e0e7ff; color: #3730a3; }
.status-enviado     { background: #d1fae5; color: #065f46; }
.status-entregado   { background: #dcfce7; color: #14532d; }
.status-cancelado   { background: #fee2e2; color: #991b1b; }
.status-reembolsado { background: #f3e8ff; color: #6b21a8; }

/* ============================================================
   LOADING / SPINNERS
   ============================================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    display: none;
}

.loading-overlay.active { display: flex; }

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: .375rem;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   SECCIÓN "BANNER PROMO"
   ============================================================ */
.promo-banner {
    background: linear-gradient(135deg, var(--ms-accent), #f97316);
    color: white;
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    font-size: .9rem;
}

/* ============================================================
   TABLA ADMIN
   ============================================================ */
.table-panel { background: white; border-radius: var(--ms-radius-lg); overflow: hidden; border: 1px solid var(--ms-border); }
.table-panel .table { margin: 0; }
.table-panel .table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; background: #f8fafc; font-weight: 700; border-bottom: 2px solid var(--ms-border); }
.table-panel .table td { vertical-align: middle; font-size: .875rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar-panel { transform: translateX(-100%); }
    .sidebar-panel.open { transform: translateX(0); }
    .panel-content { margin-left: 0; padding: 1rem; }

    .product-gallery { position: static; }
    #searchForm { max-width: 100%; }
}

@media (max-width: 767.98px) {
    .hero-section { padding: 3rem 0; }
    .hero-section h1 { font-size: 1.8rem; }
    .cart-item { flex-direction: column; }
    .cart-item-img { width: 100%; height: 200px; }
    .checkout-steps { gap: 0; }
    .checkout-step span { display: none; }
}

/* ============================================================
   TOAST NOTIFICACIONES
   ============================================================ */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; }

.toast-custom {
    min-width: 280px;
    border-radius: var(--ms-radius-lg);
    box-shadow: var(--ms-shadow-lg);
    border: none;
    animation: slideInRight .3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

/* ============================================================
   UTILIDADES
   ============================================================ */
.text-primary  { color: var(--ms-primary)   !important; }
.bg-primary    { background: var(--ms-primary) !important; }
.border-primary { border-color: var(--ms-primary) !important; }

.hover-scale   { transition: transform .2s; }
.hover-scale:hover { transform: scale(1.03); }

.cursor-pointer { cursor: pointer; }

.section-title {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-family: var(--font-heading);
    position: relative;
    margin-bottom: 2rem;
}

.section-title::after {
    content: '';
    display: block;
    width: 50px;
    height: 3px;
    background: var(--ms-primary);
    margin-top: .5rem;
    border-radius: 2px;
}

.section-title.center::after { margin: .5rem auto 0; }

.divider { border: none; border-top: 1px solid var(--ms-border); margin: 2rem 0; }

/* Scroll suave */
html { scroll-behavior: smooth; }

/* Scrollbar personalizada */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ms-primary); }
