/* V192: Catalog page styles - Mobile-first */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #faf9f6;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    color: #1f2937;
}

/* Loading State */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 16px;
    color: #6b7280;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #16a34a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Error State */
.error-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 48px;
    text-align: center;
    max-width: 400px;
    margin: 60px auto;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.error-container h2 {
    font-size: 1.3rem;
    color: #1f2937;
    margin-bottom: 8px;
}

.error-container p {
    color: #6b7280;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

/* Success State */
.success-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 48px;
    text-align: center;
    max-width: 400px;
    margin: 60px auto;
}

.success-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.success-container h2 {
    font-size: 1.3rem;
    color: #1f2937;
    margin-bottom: 12px;
}

.success-container p {
    color: #6b7280;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 20px;
}

.logo {
    max-width: 180px;
    height: auto;
}

@media (min-width: 600px) {
    .logo {
        max-width: 220px;
    }
}

.greeting {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1f2937;
    margin-top: 12px;
}

.subtitle {
    font-size: 0.9rem;
    color: #6b7280;
    margin-top: 4px;
}

/* Search Bar */
.search-bar {
    margin-bottom: 12px;
}

.search-bar input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    font-size: 1rem;
    background: white;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    border-color: #16a34a;
}

/* Category Tabs */
.category-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 16px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    padding: 8px 16px;
    border-radius: 20px;
    background: #f0f0f0;
    border: none;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    color: #374151;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
}

.tab.active {
    background: #16a34a;
    color: white;
}

/* Products Container (flex column for sections) */
.products-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-bottom: 100px;
}

/* Category Section */
.category-section {
    margin-bottom: 50px;
}

.category-banner {
    display: block;
    margin: 20px auto 30px;
    max-width: 400px;
    width: 100%;
    height: 250px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.category-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ddd;
    text-align: center;
    text-transform: uppercase;
}

/* Subcategory Groups */
.subcategory-group {
    margin-bottom: 12px;
}

.subcategory-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: #444;
    margin: 25px 0 15px 0;
}

/* Paired image+card grid: each cell keeps image directly above its card */
.subcategory-paired-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}
.product-cell { display: flex; flex-direction: column; gap: 10px; }
.product-cell-img { width: 100%; height: 180px; border-radius: 8px; object-fit: cover; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

@media (max-width: 500px) {
    body {
        padding: 16px;
    }
    .category-banner {
        height: 150px;
    }
    .category-title {
        font-size: 1.15rem;
    }
    .subcategory-name {
        font-size: 0.95rem;
        margin: 15px 0 10px 0;
    }
    .subcategory-paired-grid { grid-template-columns: 1fr; }
    .product-cell-img { height: 150px; }
}

/* Product Cards Grid (inside each category section) */
.category-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

/* Flat search results grid (no category sections) */
.search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
}

/* Product Card */
.product-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.2s;
    border-left: 3px solid transparent;
}

.product-card.in-cart {
    border-left-color: #16a34a;
}

.product-card.pulse {
    animation: pulse 0.3s ease;
}

/* Product Top Row */
.product-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.product-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1f2937;
}

/* Product Price Row */
.product-price-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.price-current {
    font-weight: 700;
    font-size: 1.1rem;
    color: #16a34a;
}

.price-original {
    font-size: 0.85rem;
    color: #9ca3af;
    text-decoration: line-through;
}

/* Product Badges */
.promo-badge {
    display: inline-block;
    background: #fef3c7;
    color: #d97706;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Product Actions */
.product-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid #d1d5db;
    background: white;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #374151;
    font-family: inherit;
    transition: border-color 0.2s, color 0.2s;
}

.qty-btn:hover {
    border-color: #16a34a;
    color: #16a34a;
}

.qty-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.qty-btn:disabled:hover {
    border-color: #d1d5db;
    color: #374151;
}

.qty-display {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
}

/* Out of Stock - Card overlay */
.product-card.out-of-stock {
    position: relative;
    overflow: hidden;
}

.product-card.out-of-stock .product-name,
.product-card.out-of-stock .price-current,
.product-card.out-of-stock .price-original,
.product-card.out-of-stock .product-actions {
    opacity: 0.35;
}

.esgotado-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-18deg);
    background: rgba(239, 82, 82, 0.82);
    color: white;
    font-size: 1.25rem;
    font-weight: 800;
    padding: 6px 36px;
    border-radius: 4px;
    letter-spacing: 3px;
    text-transform: uppercase;
    pointer-events: none;
    white-space: nowrap;
    z-index: 2;
}

/* Small badge (inline, used alongside price) */
.out-of-stock-badge {
    display: inline-block;
    background: #fee2e2;
    color: #dc2626;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 500;
}

/* Cart FAB */
.cart-fab {
    position: fixed;
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #16a34a;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4);
    z-index: 100;
    cursor: pointer;
}

.cart-fab svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Cart Overlay */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
}

/* Cart Panel */
.cart-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    background: white;
    border-radius: 16px 16px 0 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.cart-panel.open {
    transform: translateY(0);
}

.cart-handle {
    padding: 12px;
    display: flex;
    justify-content: center;
    cursor: pointer;
}

.handle-bar {
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px 12px;
}

.cart-header h3 {
    font-size: 1.1rem;
    color: #1f2937;
}

.cart-clear {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
}

/* Cart Items */
.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: #1f2937;
}

.cart-item-price {
    font-size: 0.85rem;
    color: #6b7280;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Cart Footer */
.cart-footer {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
    border-top: 1px solid #e5e7eb;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #1f2937;
}

/* Buttons */
.btn-submit {
    width: 100%;
    padding: 16px;
    background: #16a34a;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.btn-submit:active {
    background: #15803d;
}

.btn-whatsapp {
    display: inline-block;
    padding: 14px 28px;
    background: #16a34a;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    margin-top: 20px;
    font-family: inherit;
    transition: background 0.2s;
}

.btn-whatsapp:active {
    background: #15803d;
}

/* Submitting Overlay */
.submitting-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 500;
    gap: 16px;
    color: #6b7280;
}

/* Empty Search */
.empty-search {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
