/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --whatsapp-color: #25D366;
    --danger-color: #e74c3c;
    --light-bg: #f5f6fa;
    --white: #ffffff;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #dfe6e9;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --transition: all 0.3s ease;
    --radius: 12px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
}

img {
    display: block;
    max-width: 100%;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--white);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.25rem 2rem;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 0.15rem;
}

.tagline {
    font-size: 0.85rem;
    opacity: 0.85;
    font-weight: 300;
}

.main-nav {
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border: 2px solid transparent;
    padding: 0.5rem 1.3rem;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    font-family: inherit;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.nav-btn.active {
    background: var(--white);
    color: var(--primary-color);
}

/* ============================================
   MAIN CONTAINER
   ============================================ */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 2rem;
    align-items: start;
}

/* ============================================
   CATALOG
   ============================================ */
.catalog-section {
    min-height: 400px;
}

.category-header {
    margin-bottom: 1.5rem;
}

.category-header h2 {
    font-size: 1.6rem;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.product-count {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ============================================
   FILTERS
   ============================================ */
.filters-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
}

.filter-select {
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--white);
    color: var(--text-dark);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.filter-select:hover {
    border-color: var(--accent-color);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

/* ============================================
   PRODUCT CARD
   ============================================ */
.product-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

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

.product-image {
    width: 100%;
    height: 280px;
    object-fit: cover;
    background: var(--light-bg);
}

.product-info {
    padding: 1rem 1.15rem 1.15rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.3rem;
}

.product-brand {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.6rem;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.product-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-color);
}

.product-status {
    font-size: 0.75rem;
    padding: 0.2rem 0.65rem;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.status-available {
    background: #d4edda;
    color: #155724;
}

.status-sold {
    background: #f8d7da;
    color: #721c24;
}

/* Added status when item is in Tus Cosas */
.status-added {
    background: #ffd700;
    color: #1a1a1a;
}

.product-card.selected {
    box-shadow: 0 10px 30px rgba(52,73,94,0.08);
    outline: 2px solid rgba(52,73,94,0.04);
}

/* ============================================
   CART SIDEBAR
   ============================================ */
.cart-sidebar {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 110px;
    max-height: calc(100vh - 130px);
    display: flex;
    flex-direction: column;
}

/* Hide sidebar on mobile, show on desktop */
@media (max-width: 1024px) {
    .cart-sidebar {
        display: none !important;
    }
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 0.75rem;
}

.cart-header h2 {
    font-size: 1.25rem;
    color: var(--text-dark);
}

.cart-badge {
    background: var(--accent-color);
    color: var(--white);
    min-width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.cart-items {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    margin-bottom: 0.75rem;
}

.empty-cart {
    text-align: center;
    color: var(--text-light);
    padding: 2rem 1rem;
    font-style: italic;
}

.cart-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.cart-item-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--light-bg);
    flex-shrink: 0;
}

.cart-item-details {
    flex: 1;
    min-width: 0;
}

.cart-item-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-brand {
    font-size: 0.75rem;
    color: var(--text-light);
}

.cart-item-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-color);
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    padding: 0.25rem;
    flex-shrink: 0;
    transition: var(--transition);
}

.cart-item-remove:hover {
    color: #c0392b;
    font-weight: bold;
}

.cart-summary {
    border-top: 2px solid var(--border-color);
    padding-top: 0.75rem;
    flex-shrink: 0;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
}

.total-amount {
    color: var(--accent-color);
    font-size: 1.35rem;
}

.checkout-btn {
    width: 100%;
    background: var(--accent-color);
    color: var(--white);
    border: none;
    padding: 0.85rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
}

.checkout-btn:hover:not(:disabled) {
    background: #2980b9;
    box-shadow: var(--shadow-md);
}

.checkout-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.copy-icon {
    width: 18px;
    height: 18px;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1000;
    padding: 2rem;
    overflow-y: auto;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--white);
    border-radius: 16px;
    max-width: 960px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-30px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: var(--white);
    border: none;
    font-size: 1.8rem;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    z-index: 10;
    color: var(--text-dark);
    line-height: 1;
}

.modal-close:hover {
    background: var(--danger-color);
    color: var(--white);
}

.modal-body {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 2rem;
    padding: 2rem;
}

.modal-gallery {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.main-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--light-bg);
    cursor: pointer;
}

.main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnails {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.thumbnail {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
    flex-shrink: 0;
}

.thumbnail:hover,
.thumbnail.active {
    border-color: var(--accent-color);
}

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

.modal-info {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-top: 0.5rem;
}

.modal-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
}

.modal-brand {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-top: -0.75rem;
}

.modal-price {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--accent-color);
}

.modal-details {
    background: var(--light-bg);
    padding: 1.25rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-label {
    font-weight: 600;
    color: var(--text-dark);
}

.detail-value {
    font-weight: 500;
}

/* Modal status styles - text color only, no background */
.detail-value.status-available {
    background: none;
    color: #155724;
    padding: 0;
    border-radius: 0;
}

.detail-value.status-sold {
    background: none;
    color: #721c24;
    padding: 0;
    border-radius: 0;
}

.detail-value.status-added {
    background: none;
    color: #d4a000;
    padding: 0;
    border-radius: 0;
    font-weight: 600;
}

.add-to-cart-btn {
    background: var(--success-color);
    color: var(--white);
    border: none;
    padding: 1.1rem;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: auto;
    font-family: inherit;
}

.add-to-cart-btn:hover:not(:disabled) {
    background: #229954;
    box-shadow: var(--shadow-md);
}

.add-to-cart-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

/* ============================================
   TOAST NOTIFICATION
   ============================================ */
.toast {
    position: fixed;
    top: 90px;
    right: 1.5rem;
    background: var(--success-color);
    color: var(--white);
    padding: 0.85rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    font-weight: 500;
    animation: toastIn 0.3s ease;
}

.toast.fade-out {
    animation: toastOut 0.4s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* ============================================
   FLOATING CART BUTTON (Mobile Only)
   ============================================ */
.floating-cart-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 72px;
    height: 72px;
    background: var(--white);
    color: var(--accent-color);
    border: 1px solid rgba(0,0,0,0.04);
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(15, 23, 29, 0.06);
    z-index: 160;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    display: none;
    align-items: center;
    justify-content: center;
}

/* Show on mobile, hide on desktop */
@media (max-width: 1024px) {
    .floating-cart-btn {
        display: flex !important;
    }
}

@media (max-width: 640px) {
    .floating-cart-btn {
        bottom: 16px;
        right: 16px;
        width: 64px;
        height: 64px;
    }
    
    .floating-cart-btn svg {
        width: 36px;
        height: 36px;
    }
}

.floating-cart-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(15, 23, 29, 0.09);
}

.floating-cart-btn svg {
    width: 40px;
    height: 40px;
}

.floating-cart-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--danger-color);
    color: var(--white);
    min-width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--white);
}

.floating-cart-badge.show {
    display: flex;
}

/* Ensure inline SVG icon scales and inherits color */
.floating-cart-icon svg {
    width: 44px;
    height: 44px;
    display: block;
}

.floating-cart-btn { color: var(--accent-color); }

/* ============================================
   CART MODAL (Mobile Only)
   ============================================ */
.cart-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1000;
    padding: 1rem;
    overflow-y: auto;
    backdrop-filter: blur(4px);
}

.cart-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-modal-content {
    background: var(--white);
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}

.cart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
}

.cart-modal-header h2 {
    font-size: 1.35rem;
    color: var(--text-dark);
}

.cart-modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-dark);
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    border-radius: 50%;
}

.cart-modal-close:hover {
    background: var(--danger-color);
    color: var(--white);
}

.cart-modal-items {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

.cart-modal-summary {
    border-top: 2px solid var(--border-color);
    padding: 1.25rem;
    flex-shrink: 0;
}

/* ============================================
   FULLSCREEN GALLERY
   ============================================ */
.fullscreen-gallery {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

/* Disable default touch scrolling while interacting with gallery */
.fullscreen-gallery, .fullscreen-gallery * {
    touch-action: none;
    -ms-touch-action: none;
}

.fullscreen-gallery img {
    user-select: none;
    -webkit-user-drag: none;
}

.fullscreen-gallery.active {
    display: flex;
}

.gallery-image-container {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.gallery-image-container img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
}

.gallery-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: var(--white);
    font-size: 2.5rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    line-height: 1;
    z-index: 10;
}

.gallery-close:hover {
    background: var(--danger-color);
    border-color: var(--danger-color);
    transform: rotate(90deg);
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: var(--white);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.gallery-nav:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
}

.gallery-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.gallery-nav svg {
    width: 24px;
    height: 24px;
}

.gallery-prev {
    left: 1.5rem;
}

.gallery-next {
    right: 1.5rem;
}

.gallery-counter {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: var(--white);
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    backdrop-filter: blur(10px);
}

@media (max-width: 640px) {
    .gallery-close {
        top: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
        font-size: 2rem;
    }

    .gallery-nav {
        width: 44px;
        height: 44px;
    }

    .gallery-nav svg {
        width: 20px;
        height: 20px;
    }

    .gallery-prev {
        left: 1rem;
    }

    .gallery-next {
        right: 1rem;
    }

    .gallery-counter {
        bottom: 1.5rem;
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 1fr;
        padding-bottom: 2rem;
    }

    .modal-body {
        grid-template-columns: 1fr;
    }

    .main-image {
        aspect-ratio: 4 / 3;
    }
}

@media (max-width: 640px) {
    .header-content {
        padding: 1rem;
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    .main-container {
        padding: 1rem;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .product-image {
        height: 200px;
    }

    .product-info {
        padding: 0.75rem;
    }

    .product-price {
        font-size: 1.05rem;
    }

    .category-header h2 {
        font-size: 1.3rem;
    }

    .modal-body {
        padding: 1.25rem;
        gap: 1.25rem;
    }

    .modal-title {
        font-size: 1.3rem;
    }

    .modal-price {
        font-size: 1.8rem;
    }

    .thumbnail {
        width: 56px;
        height: 56px;
    }
}