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

body {
    font-family: 'Inter', sans-serif;
    background: #f0f2f5;
    color: #1a1a1a;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-text-size-adjust: 100%;
}

/* Top Bar */
.top-bar {
    background: #0d1b4a;
    color: rgba(255,255,255,0.85);
    font-size: 0.78rem;
    padding: 0.4rem 2rem;
}

.top-bar-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-left { display: flex; gap: 1.5rem; }
.top-right { display: flex; gap: 1.5rem; }
.top-right a { color: rgba(255,255,255,0.85); text-decoration: none; }
.top-right a:hover { color: white; }

/* Header */
header {
    background: #1a237e;
    color: white;
    padding: 0.8rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: white;
    flex-shrink: 0;
    touch-action: manipulation;
}

.logo-icon { font-size: 2rem; }
.logo-text { display: flex; flex-direction: column; }
.logo-name { font-size: 1.6rem; font-weight: 700; letter-spacing: 1px; }
.logo-sub { font-size: 0.65rem; font-weight: 300; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.5px; }

.search-bar {
    flex: 1;
    display: flex;
    max-width: 650px;
    border-radius: 6px;
    overflow: hidden;
}

.search-bar input {
    flex: 1;
    padding: 0.75rem 1.2rem;
    border: none;
    font-size: 1rem; /* ≥16px evita zoom en iOS */
    outline: none;
}

.search-bar button {
    padding: 0.75rem 1.4rem;
    background: #ff6d00;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s;
    touch-action: manipulation;
    white-space: nowrap;
}

.search-bar button:hover { background: #e65100; }

.header-actions { display: flex; gap: 1rem; align-items: center; }

.cart-button {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.4);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.cart-button:hover { background: rgba(255,255,255,0.2); border-color: white; }

#cart-count {
    background: #ff6d00;
    border-radius: 50%;
    padding: 0.15rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Category Nav */
.cat-nav {
    background: #283593;
    padding: 0;
}

.cat-nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
}

.cat-nav-toggle {
    display: none;
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 600;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.cat-nav-links {
    display: flex;
    gap: 0;
}

.cat-nav-links a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 0.75rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
    display: block;
    min-height: 44px;
    display: flex;
    align-items: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.cat-nav-links a:hover { background: rgba(255,255,255,0.1); }

/* Filters */
.filters {
    background: white;
    padding: 0.7rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.filters-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 0.8rem;
    align-items: center;
    flex-wrap: wrap;
}

.filters select {
    padding: 0.6rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem; /* ≥16px evita zoom en iOS */
    background: white;
    min-height: 44px;
    touch-action: manipulation;
}

.stock-filter {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.stock-filter input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #1a237e;
}

.results-count {
    margin-left: auto;
    font-size: 0.8rem;
    color: #666;
}

/* Main */
main {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    width: 100%;
}

/* Product Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.2rem;
}

.product-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    border: 1px solid #eee;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    border-color: #1a237e;
}

.product-card img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: white;
    padding: 1rem;
}

.product-card .info {
    padding: 0.8rem 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card .brand {
    font-size: 0.7rem;
    color: #1a237e;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.product-card .title {
    font-size: 0.82rem;
    font-weight: 400;
    margin: 0.3rem 0;
    line-height: 1.3;
    height: 2.6em;
    overflow: hidden;
    color: #333;
}

.product-card .price-old {
    font-size: 0.78rem;
    color: #999;
    text-decoration: line-through;
    margin-top: auto;
}

.product-card .price {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a237e;
}

.discount-badge {
    font-size: 0.65rem;
    background: #c62828;
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 700;
    margin-left: 0.3rem;
}

.product-card .price-iva {
    font-size: 0.68rem;
    color: #666;
    margin-top: 0.1rem;
}

.product-card .stock-badge {
    display: inline-block;
    font-size: 0.68rem;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    margin-top: 0.3rem;
}

.stock-badge.in-stock { background: #e8f5e9; color: #2e7d32; }
.stock-badge.out-stock { background: #fbe9e7; color: #c62828; }

.free-shipping {
    font-size: 0.7rem;
    color: #2e7d32;
    font-weight: 500;
    margin-top: 0.2rem;
}

.product-card .btn-add {
    width: 100%;
    padding: 0.75rem;
    min-height: 44px;
    background: #1a237e;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.product-card .btn-add:hover { background: #ff6d00; }
.product-card .btn-add:disabled { background: #ccc; cursor: not-allowed; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.pagination button {
    padding: 0.6rem 1rem;
    min-height: 44px;
    min-width: 44px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.pagination button.active {
    background: #1a237e;
    color: white;
    border-color: #1a237e;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: env(safe-area-inset-top, 1rem) env(safe-area-inset-right, 1rem) env(safe-area-inset-bottom, 1rem) env(safe-area-inset-left, 1rem);
    padding: 1rem;
    overflow-y: auto;
}

.modal.hidden { display: none; }

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    max-width: 850px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    margin: auto;
    -webkit-overflow-scrolling: touch;
}

.cart-modal-content { max-width: 500px; }
.checkout-modal-content { max-width: 600px; }

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.modal-close:hover { background: #f0f0f0; }

/* Product Detail */
.product-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.product-detail-grid img {
    width: 100%;
    border-radius: 8px;
    object-fit: contain;
    background: #f9f9f9;
}

.detail-info h2 { font-size: 1.2rem; margin-bottom: 0.5rem; line-height: 1.4; }
.detail-info .brand { color: #1a237e; font-size: 0.85rem; font-weight: 600; }
.detail-info .price-old { font-size: 1rem; color: #999; text-decoration: line-through; margin-top: 1rem; }
.detail-info .price { font-size: 1.8rem; font-weight: 700; color: #1a237e; }
.detail-info .price-iva { font-size: 0.8rem; color: #666; margin-bottom: 0.5rem; }
.detail-info .desc { color: #555; line-height: 1.6; margin: 1rem 0; font-size: 0.85rem; max-height: 200px; overflow-y: auto; }

.btn-primary {
    padding: 0.85rem 2rem;
    min-height: 48px;
    background: #1a237e;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: background 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover { background: #ff6d00; }

.btn-datasheet {
    display: inline-flex;
    align-items: center;
    margin-top: 0.8rem;
    padding: 0.6rem 1rem;
    min-height: 44px;
    background: #f5f5f5;
    color: #1a237e;
    border: 1px solid #1a237e;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
    touch-action: manipulation;
}

.btn-datasheet:hover { background: #e8eaf6; }

/* Cart */
.cart-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid #eee;
}

.cart-item img { width: 50px; height: 50px; object-fit: contain; flex-shrink: 0; }
.cart-item .cart-item-info { flex: 1; min-width: 0; }
.cart-item .cart-item-title { font-size: 0.82rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-item .cart-item-price { font-weight: 700; color: #1a237e; font-size: 0.9rem; }

.cart-item .cart-item-qty {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.cart-item .cart-item-qty button {
    width: 36px;
    height: 36px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.cart-item .remove-btn {
    color: #c62828;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.5rem;
    min-width: 36px;
    min-height: 36px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.cart-total {
    font-size: 1.3rem;
    font-weight: 700;
    text-align: right;
    padding: 1rem 0;
    border-top: 2px solid #1a237e;
    margin-top: 1rem;
}

.btn-checkout { width: 100%; margin-top: 1rem; }

/* Checkout Form */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin: 1rem 0;
}

.form-grid input {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem; /* ≥16px evita zoom en iOS */
    min-height: 48px;
}

.form-grid input:first-child,
.form-grid input:nth-child(4) {
    grid-column: 1 / -1;
}

.shipping-note {
    color: #2e7d32;
    font-size: 0.85rem;
    margin: 1rem 0;
    font-weight: 500;
    background: #e8f5e9;
    padding: 0.6rem 1rem;
    border-radius: 6px;
}

.payment-methods {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}

.payment-option {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
    min-height: 52px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.payment-option:has(input:checked) {
    border-color: #1a237e;
    background: #e8eaf6;
}

.payment-option input {
    accent-color: #1a237e;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.success-icon {
    width: 60px;
    height: 60px;
    background: #2e7d32;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 1rem auto;
}

#order-success { text-align: center; padding: 2rem; }
#order-success h3 { margin: 1rem 0; color: #2e7d32; }

.checkout-summary { margin: 1rem 0; }

/* Trust Section */
.trust-section {
    background: white;
    padding: 2rem 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.trust-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
}

.trust-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.trust-icon { font-size: 2rem; }
.trust-item strong { font-size: 0.9rem; }
.trust-item p { font-size: 0.75rem; color: #666; }

/* Footer */
footer {
    background: #0d1b4a;
    color: rgba(255,255,255,0.85);
    padding: 2.5rem 1.5rem 1rem;
    font-size: 0.85rem;
}

.footer-grid {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
}

.footer-col h4 {
    color: white;
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
}

.footer-col ul { list-style: none; }
.footer-col ul li { margin-bottom: 0.4rem; }

.footer-col ul a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: color 0.2s;
    display: inline-block;
    padding: 0.2rem 0;
}

.footer-col ul a:hover { color: white; }

.footer-social {
    display: flex;
    gap: 0.8rem;
    margin-top: 1rem;
}

.footer-social a {
    color: white;
    background: rgba(255,255,255,0.15);
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.8rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    touch-action: manipulation;
}

.footer-social a:hover { background: rgba(255,255,255,0.25); }

.footer-payments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.8rem;
    font-size: 0.75rem;
}

.footer-bottom {
    max-width: 1400px;
    margin: 2rem auto 0;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.15);
    text-align: center;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.6);
}

.footer-bottom p + p { margin-top: 0.3rem; }

/* WhatsApp Float */
.whatsapp-float {
    position: fixed;
    bottom: 2rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    background: #25d366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 150;
    text-decoration: none;
    transition: transform 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.whatsapp-float:hover { transform: scale(1.1); }

/* ─── Responsive ─── */

@media (max-width: 1024px) {
    .trust-inner { grid-template-columns: repeat(2, 1fr); }
    .footer-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    /* Top bar oculto en móvil */
    .top-bar { display: none; }

    /* Header */
    .header-inner { flex-wrap: wrap; gap: 0.6rem; padding: 0; }
    .logo { flex: 1; }
    .logo-name { font-size: 1.3rem; }
    .logo-sub { display: none; }
    .search-bar { order: 3; width: 100%; max-width: 100%; flex-basis: 100%; }
    .search-bar input { font-size: 1rem; }

    /* Category nav */
    .cat-nav-toggle { display: flex; align-items: center; }
    .cat-nav-links { display: none; flex-direction: column; width: 100%; background: #283593; }
    .cat-nav-links.open { display: flex; }
    .cat-nav-inner { flex-wrap: wrap; }
    .cat-nav-links a { padding: 0.85rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.08); }

    /* Filters */
    .filters { padding: 0.6rem 1rem; }
    .filters-inner { gap: 0.5rem; }
    .filters select { flex: 1; min-width: 0; font-size: 1rem; }
    .results-count { width: 100%; text-align: center; margin-left: 0; }

    /* Grid */
    main { padding: 0.8rem 1rem; }
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }

    /* Product card mobile */
    .product-card img { height: 140px; padding: 0.6rem; }
    .product-card .info { padding: 0.6rem 0.7rem; }
    .product-card .title { font-size: 0.78rem; }
    .product-card .price { font-size: 1rem; }
    .product-card .btn-add { font-size: 0.8rem; padding: 0.7rem; }

    /* Modal */
    .modal { padding: 0; align-items: flex-end; }
    .modal-content {
        border-radius: 16px 16px 0 0;
        max-height: 92vh;
        padding: 1.5rem 1rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }
    .cart-modal-content, .checkout-modal-content { max-width: 100%; }

    /* Product detail in modal */
    .product-detail-grid { grid-template-columns: 1fr; gap: 1rem; }
    .detail-info .price { font-size: 1.4rem; }

    /* Form */
    .form-grid { grid-template-columns: 1fr; }
    .form-grid input:first-child,
    .form-grid input:nth-child(4) { grid-column: auto; }
    .form-grid input { font-size: 1rem; }

    /* Payment */
    .payment-methods { flex-direction: column; gap: 0.6rem; }

    /* Trust */
    .trust-inner { grid-template-columns: 1fr 1fr; gap: 1rem; }
    .trust-icon { font-size: 1.5rem; }
    .trust-item strong { font-size: 0.82rem; }

    /* WhatsApp más grande en móvil */
    .whatsapp-float { bottom: 1rem; right: 1rem; width: 52px; height: 52px; }
}

@media (max-width: 480px) {
    .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .trust-inner { grid-template-columns: 1fr 1fr; gap: 0.8rem; }
    .trust-item p { display: none; }

    /* En móviles muy pequeños, 1 columna de productos */
    .products-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .product-card img { height: 120px; }
}

/* breadcrumb (páginas de producto SSR) */
.breadcrumb {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 1.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.breadcrumb a { color: #1a237e; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
