:root {
    --bg-primary: #F8F9FA;
    --bg-white: #FFFFFF;
    --text-primary: #1B2A4A;
    --text-secondary: #5A6B8A;
    --text-light: #8896AB;
    --accent: #00ACC1;
    --accent-hover: #00838F;
    --accent-light: #E0F7FA;
    --whatsapp: #25D366;
    --whatsapp-hover: #1EBE5A;
    --danger: #E53E3E;
    --danger-hover: #C53030;
    --success: #38A169;
    --warning: #D69E2E;
    --border: #E8ECF1;
    --shadow: rgba(27, 42, 74, 0.06);
    --shadow-hover: rgba(27, 42, 74, 0.12);
    --radius: 8px;
    --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
img { max-width: 100%; height: auto; }

/* Header */
.main-header {
    background: var(--bg-white);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 2px 4px var(--shadow);
    height: 70px;
    display: flex;
    align-items: center;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}
.logo h2 {
    font-size: 1.5rem;
    color: var(--accent);
}
.header-search {
    flex: 1;
    max-width: 400px;
    margin: 0 2rem;
    position: relative;
}
.header-search input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    outline: none;
    font-family: inherit;
}
.header-search input:focus {
    border-color: var(--accent);
}
.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-light);
}
.header-actions {
    display: flex;
    gap: 1rem;
}
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--bg-white);
}
.btn-phone { background-color: var(--text-primary); }
.btn-whatsapp { background-color: var(--whatsapp); }

/* Hero */
.hero {
    margin-top: 70px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    color: var(--bg-white);
    padding: 4rem 1rem;
    text-align: center;
}
.hero h1 { font-size: 2.5rem; margin-bottom: 1rem; }
.hero p { font-size: 1.1rem; margin-bottom: 2rem; opacity: 0.9; }
.btn-primary {
    background-color: var(--accent);
    color: var(--bg-white);
    padding: 0.75rem 2rem;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 500;
    transition: background 0.3s;
}
.btn-primary:hover { background-color: var(--accent-hover); }

/* Category Nav */
.categories-nav {
    position: sticky;
    top: 70px;
    background: var(--bg-white);
    z-index: 90;
    box-shadow: 0 2px 4px var(--shadow);
}
.cat-list {
    display: flex;
    list-style: none;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 1rem 0;
    gap: 0.5rem;
}
.cat-list::-webkit-scrollbar { display: none; }
.cat-link {
    white-space: nowrap;
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s;
}
.cat-link.active, .cat-link:hover {
    background: var(--accent);
    color: var(--bg-white);
}

/* Main Content */
.main-content {
    padding: 2rem 1rem;
    min-height: 50vh;
}
.category-section {
    margin-bottom: 3rem;
    scroll-margin-top: 140px;
}
.category-header { margin-bottom: 1.5rem; }
.category-header h2 { font-size: 1.5rem; display: flex; align-items: center; gap: 0.5rem; }
.badge {
    background: var(--accent-light);
    color: var(--accent);
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
}
.product-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
}
.product-card:hover {
    box-shadow: 0 6px 16px var(--shadow-hover);
    transform: translateY(-2px);
}
.card-image {
    position: relative;
    width: 100%;
    padding-top: 90%;
    background: #fff;
}
.card-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0.5rem;
}
.card-content {
    padding: 0.5rem 0.6rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.product-name {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}
.product-brand {
    font-size: 0.75rem;
    color: var(--text-light);
}
.card-actions {
    padding: 0.4rem 0.6rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.45rem 0.5rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.78rem;
    transition: background 0.2s;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}
.btn-call { background: var(--text-primary); color: var(--bg-white); }
.btn-call:hover { background: #111a2f; }
.btn-whatsapp { background: var(--whatsapp); color: var(--bg-white); }
.btn-whatsapp:hover { background: var(--whatsapp-hover); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}
.btn-outline:hover { background: var(--accent); color: var(--bg-white); }

.load-more-container {
    text-align: center;
    margin-top: 2rem;
}

/* Footer */
.main-footer {
    background: var(--text-primary);
    color: var(--bg-white);
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}
.footer-col h3 { margin-bottom: 1rem; font-size: 1.2rem; }
.footer-col p { margin-bottom: 0.5rem; color: var(--text-light); }
.footer-col a { color: var(--text-light); transition: color 0.2s; }
.footer-col a:hover { color: var(--accent); }
.social-links { display: flex; flex-direction: column; gap: 0.5rem; }
.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ============ MODAL ============ */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal.active { display: flex; }
.modal-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
}
.modal-content {
    position: relative;
    background: var(--bg-white);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow-y: auto;
    z-index: 1001;
}
.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 1.5rem;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    cursor: pointer;
}
.modal-close:hover { background: var(--border); }
.modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

/* Modal Gallery */
.modal-gallery {
    padding: 1.5rem;
    background: #FAFBFC;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.modal-main-image {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
}
.modal-thumbs {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}
.modal-thumb {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
    background: #fff;
    transition: border-color 0.2s;
}
.modal-thumb:hover, .modal-thumb.active {
    border-color: var(--accent);
}

/* Modal Info */
.modal-info {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}
.modal-category {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}
.modal-info h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}
.modal-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.modal-code {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.modal-code strong {
    color: var(--text-primary);
}
.modal-price-area {
    margin-bottom: 1.25rem;
    padding: 0.75rem;
    background: var(--accent-light);
    border-radius: var(--radius);
}
.modal-price-area .price-val {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.modal-price-area .price-unit {
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.modal-price-area .price-hidden {
    font-size: 1rem;
    font-style: italic;
    color: var(--text-secondary);
}

/* Modal Description & Specs */
.modal-description {
    margin-bottom: 1.25rem;
}
.modal-description h3,
.modal-specs-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}
.modal-description p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-line;
}
.modal-specs-section {
    margin-bottom: 1.25rem;
}
.modal-specs {
    width: 100%;
    border-collapse: collapse;
}
.modal-specs tr:nth-child(even) {
    background: var(--bg-primary);
}
.modal-specs th, .modal-specs td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}
.modal-specs th {
    font-weight: 600;
    color: var(--text-primary);
    width: 40%;
}
.modal-specs td {
    color: var(--text-secondary);
}

/* Modal Actions */
.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
}

/* Modal Spinner */
.modal-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 992px) {
    .product-grid { gap: 0.6rem; }
    .card-content { padding: 0.4rem 0.5rem; }
    .product-name { font-size: 0.8rem; }
    .product-brand { font-size: 0.7rem; }
    .card-actions { padding: 0.3rem 0.5rem 0.5rem; gap: 0.25rem; }
    .btn { font-size: 0.7rem; padding: 0.4rem 0.3rem; }
    .modal-body { grid-template-columns: 1fr; }
    .modal-gallery { padding: 1rem; }
}

@media (max-width: 768px) {
    .main-header { height: auto; min-height: 70px; padding: 10px 0; }
    .header-inner { flex-wrap: wrap; }
    .logo img { max-width: 130px; }
    .header-actions { flex-shrink: 0; display: flex; }
    .header-actions .btn-fav-filter, .header-actions .btn-pdf, .header-actions .btn-phone, .header-actions .btn-whatsapp, .header-actions .btn-search-mobile { display: none !important; }
    .btn-search-mobile { display: none; }
    .header-search { 
        display: block; 
        flex: 0 0 100%;
        order: 3; 
        width: 100%; 
        max-width: 100%; 
        margin: 15px 0 5px 0; 
    }
    .hero { margin-top: 130px; padding: 2rem 1rem; }
    .product-grid { grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
    .hero h1 { font-size: 1.4rem; }
    .hero p { font-size: 0.85rem; margin-bottom: 1rem; }
    .product-grid { gap: 0.4rem; }
    .card-image { padding-top: 80%; }
    .card-image img { padding: 0.3rem; }
    .card-content { padding: 0.3rem 0.4rem; }
    .product-name { font-size: 0.7rem; -webkit-line-clamp: 2; }
    .product-brand { font-size: 0.6rem; }
    .card-actions { padding: 0.2rem 0.4rem 0.4rem; gap: 0.2rem; }
    .btn { font-size: 0.6rem; padding: 0.3rem 0.2rem; min-height: 28px; border-radius: 4px; }
    .category-header h2 { font-size: 1.1rem; }
    .category-section { margin-bottom: 1.5rem; }
    .container { padding: 0 0.4rem; }
    .main-content { padding: 1rem 0.4rem; }
    .modal-content { width: 95%; max-height: 95vh; border-radius: 8px; }
    .modal-info { padding: 1rem; }
    .modal-info h2 { font-size: 1.1rem; }
    .modal-actions .btn { font-size: 0.9rem; padding: 0.6rem; }
    .cart-modal-content { width: 95%; max-height: 90vh; }
    .footer-grid { grid-template-columns: 1fr; gap: 1rem; }
}

@media (max-width: 480px) {
    .logo h2 { font-size: 1.1rem; }
    .hero h1 { font-size: 1.1rem; }
    .hero p { font-size: 0.8rem; }
    .btn-primary { font-size: 0.9rem; padding: 0.6rem 1.2rem; }
    .product-grid { gap: 0.3rem; }
    .card-image { padding-top: 75%; }
    .card-content { padding: 0.2rem 0.3rem; }
    .product-name { font-size: 0.65rem; -webkit-line-clamp: 1; line-height: 1.2; margin-bottom: 0.1rem; }
    .product-brand { font-size: 0.55rem; }
    .card-actions { padding: 0.15rem 0.3rem 0.3rem; gap: 0.15rem; flex-direction: column; }
    .btn { font-size: 0.55rem; padding: 0.25rem 0.15rem; min-height: 24px; }
    .cat-link { font-size: 0.75rem; padding: 0.3rem 0.6rem; }
    .modal-info h2 { font-size: 1rem; }
    .modal-specs th, .modal-specs td { font-size: 0.8rem; padding: 0.4rem; }
}


/* ============ CART UI ============ */
.floating-cart {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--accent);
    color: var(--bg-white);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 99;
    transition: transform 0.3s;
}
.floating-cart:hover { transform: scale(1.05); }
.floating-cart svg { width: 28px; height: 28px; }
.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    border: 2px solid var(--bg-light);
}

.cart-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: flex-end;
    align-items: stretch;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}
.cart-modal.active {
    opacity: 1;
    visibility: visible;
}
.cart-content {
    background: var(--bg-white);
    width: 100%;
    max-width: 450px;
    height: 100%;
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
    display: flex;
    flex-direction: column;
}
.cart-modal.active .cart-content {
    transform: translateX(0);
}
.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.cart-header h2 { font-size: 1.3rem; margin: 0; }
.cart-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}
.cart-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: #f8f9fa;
}
.cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
}
.cart-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.cart-item-info { flex: 1; margin-right: 1rem; }
.cart-item-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.2rem; }
.cart-item-code { font-size: 0.8rem; color: var(--text-light); margin-bottom: 0.5rem; }
.cart-item-price { font-weight: 600; color: var(--accent); font-size: 0.9rem; }
.cart-qty-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f1f2f6;
    padding: 0.2rem;
    border-radius: 6px;
}
.btn-icon {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}
.btn-search-mobile {
    display: none;
}
.qty-btn {
    background: var(--bg-white);
    border: 1px solid #ddd;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    color: var(--text-primary);
}
.qty-val {
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    font-size: 0.9rem;
}
.btn-remove-item {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    margin-left: 0.5rem;
    padding: 0.2rem;
}
.cart-empty-msg {
    text-align: center;
    color: var(--text-light);
    padding: 3rem 1rem;
}
.cart-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

/* ============ FAVORITES UI ============ */
.btn-fav {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    color: #999;
    transition: all 0.2s;
    z-index: 2;
    padding: 0;
}
.btn-fav svg {
    width: 14px;
    height: 14px;
}
.btn-fav:hover {
    transform: scale(1.1);
}
.btn-fav.active {
    color: #e74c3c;
}
.btn-fav.active svg {
    fill: #e74c3c;
}
.btn-fav-filter.active {
    color: #e74c3c;
}
.btn-fav-filter.active svg {
    fill: #e74c3c;
}
.product-card.hidden-by-fav {
    display: none !important;
}
.category-section.hidden-by-fav {
    display: none !important;
}

/* ============ MOBILE MENU (SIDEBAR) ============ */
.btn-hamburger { display: none; }

.menu-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}
.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu {
    position: fixed;
    top: 0; right: -100%;
    width: 280px;
    height: 100vh;
    background: var(--bg-white);
    z-index: 2000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
}
.mobile-menu.active {
    right: 0;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}
.mobile-menu-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.mobile-menu-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.m-link {
    font-size: 1.1rem;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.mobile-menu-footer {
    padding: 20px;
    background: #f9f9f9;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.m-btn {
    display: block;
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    color: white;
}
.m-catalog { background: var(--text-primary); }
.m-phone { background: var(--accent); }
.m-whatsapp { background: var(--whatsapp); }

.m-social {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}
.m-social a {
    color: var(--text-light);
    transition: color 0.2s;
}
.m-social a:hover { color: var(--accent); }
.m-social svg { width: 24px; height: 24px; }

@media (max-width: 768px) {
    .btn-hamburger { display: flex; order: 1; margin-left: auto; }
}

.btn-cart-header {
    position: relative;
    color: var(--text-main);
}
.cart-badge-header {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.product-price {
    margin-top: 8px;
    font-size: 1.05rem;
    color: var(--primary);
    font-weight: 600;
}
.product-price .price-unit {
    font-size: 0.85rem;
    color: #666;
    font-weight: normal;
}
.product-price .price-hidden {
    font-weight: normal;
    font-style: italic;
}
