/* ==========================================================================
   Estilos Principales - Catálogo PWA Mercado Libre Style
   ========================================================================== */

:root {
    --primary-color: #fff159;
    --secondary-color: #2d3277;
    --accent-blue: #3483fa;
    --text-dark: #333333;
    --text-muted: #666666;
    --bg-light: #f5f5f5;
    --card-bg: #ffffff;
    --border-color: #e6e6e6;
    --danger-color: #ff7733;
    --success-color: #00a650;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.app-header {
    background-color: var(--primary-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    padding: 10px 16px;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand-logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.app-logo-fallback {
    font-size: 28px;
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--secondary-color);
    white-space: nowrap;
}

.header-search-bar {
    flex: 1;
    max-width: 600px;
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 4px;
    padding: 2px 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.header-search-bar input {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 12px;
    font-size: 0.95rem;
}

.header-search-bar .btn-search {
    background: none;
    border: none;
    padding: 8px 12px;
    font-size: 1.1rem;
    color: #666;
}

.header-search-mobile {
    display: none;
    margin-top: 10px;
    background: #fff;
    border-radius: 4px;
    padding: 2px 4px;
}

.header-search-mobile input {
    width: 85%;
    border: none;
    padding: 8px;
    font-size: 0.9rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-install-pwa {
    background-color: var(--secondary-color);
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.cart-trigger {
    position: relative;
    cursor: pointer;
    font-size: 1.6rem;
    padding: 4px 8px;
}

.cart-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    background-color: #e74c3c;
    color: #fff;
    font-size: 0.75rem;
    font-weight: bold;
    border-radius: 10px;
    padding: 2px 6px;
    min-width: 18px;
    text-align: center;
}

/* --------------------------------------------------------------------------
   Layout & Sections
   -------------------------------------------------------------------------- */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

.offline-banner {
    background-color: #f39c12;
    color: #fff;
    text-align: center;
    padding: 8px 16px;
    font-weight: 600;
    border-radius: 4px;
    margin-bottom: 16px;
}

/* --------------------------------------------------------------------------
   Horizontal Carousel Slider (Featured Products)
   -------------------------------------------------------------------------- */
.carousel-section {
    background-color: #fff;
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 1.2rem;
    color: var(--secondary-color);
}

.carousel-controls {
    display: flex;
    gap: 8px;
}

.carousel-arrow {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.carousel-arrow:hover {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

.carousel-wrapper {
    overflow: hidden;
    position: relative;
    width: 100%;
}

.carousel-track {
    display: flex;
    gap: 16px;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: transform;
}

.carousel-card {
    min-width: 220px;
    max-width: 220px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.carousel-card-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background-color: #fafafa;
}

.carousel-card-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.carousel-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    height: 2.6em;
    overflow: hidden;
    margin-bottom: 8px;
}

.carousel-card-price {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-top: auto;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ccc;
    cursor: pointer;
}

.dot.active {
    background-color: var(--accent-blue);
    width: 16px;
    border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Categories Bar
   -------------------------------------------------------------------------- */
.categories-section {
    margin-bottom: 24px;
}

.categories-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
}

.categories-bar::-webkit-scrollbar {
    display: none;
}

.cat-pill {
    background-color: #fff;
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    white-space: nowrap;
    font-size: 0.9rem;
    color: var(--text-dark);
    transition: all 0.2s ease;
}

.cat-pill:hover,
.cat-pill.active {
    background-color: var(--secondary-color);
    color: #fff;
    border-color: var(--secondary-color);
}

/* --------------------------------------------------------------------------
   Product Grid
   -------------------------------------------------------------------------- */
.catalog-section {
    margin-bottom: 32px;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.product-count-badge {
    background-color: #e9ecef;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 12px;
}

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

.product-card {
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    cursor: pointer;
    position: relative;
}

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

.card-img-wrapper {
    width: 100%;
    height: 180px;
    position: relative;
    background-color: #fafafa;
    overflow: hidden;
}

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

.badge-featured {
    position: absolute;
    top: 8px;
    left: 8px;
    background-color: var(--primary-color);
    color: var(--secondary-color);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}

.product-card-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-category-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.product-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    height: 2.6em;
    overflow: hidden;
    margin-bottom: 8px;
}

.product-price {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 12px;
}

.btn-add-cart-sm {
    background-color: rgba(52, 131, 250, 0.1);
    color: var(--accent-blue);
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    width: 100%;
    margin-top: auto;
    transition: background-color 0.2s ease;
}

.btn-add-cart-sm:hover {
    background-color: var(--accent-blue);
    color: #fff;
}

/* --------------------------------------------------------------------------
   Modals & Overlays
   -------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 16px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.modal-detail-card {
    max-width: 800px;
}

.modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #eee;
    border: none;
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}

/* Detail Modal Inner */
.modal-body-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 12px;
}

.detail-gallery {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gallery-main-container {
    width: 100%;
    height: 280px;
    background-color: #fafafa;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.gallery-main-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.gallery-thumbnails {
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.thumb-mini {
    width: 60px;
    height: 60px;
    border: 2px solid transparent;
    border-radius: 4px;
    object-fit: cover;
    cursor: pointer;
}

.thumb-mini.active {
    border-color: var(--accent-blue);
}

.detail-info {
    display: flex;
    flex-direction: column;
}

.detail-category-badge {
    font-size: 0.8rem;
    color: var(--accent-blue);
    font-weight: 600;
    text-transform: uppercase;
}

.detail-title {
    font-size: 1.4rem;
    margin: 6px 0;
}

.detail-price {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.detail-stock {
    font-size: 0.85rem;
    color: var(--success-color);
    font-weight: 600;
    margin-bottom: 16px;
}

.detail-description h4 {
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.detail-description p {
    font-size: 0.9rem;
    color: var(--text-muted);
    max-height: 120px;
    overflow-y: auto;
}

.detail-actions {
    margin-top: auto;
    display: flex;
    gap: 12px;
    align-items: center;
    padding-top: 16px;
}

.quantity-selector {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.quantity-selector button {
    background: #f5f5f5;
    border: none;
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
}

.quantity-selector input {
    width: 40px;
    text-align: center;
    border: none;
    font-size: 1rem;
}

.btn-add-cart-lg {
    flex: 1;
    background-color: var(--accent-blue);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   Shopping Cart Drawer
   -------------------------------------------------------------------------- */
.cart-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.cart-drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.cart-drawer {
    position: fixed;
    top: 0;
    right: -400px;
    width: 100%;
    max-width: 380px;
    height: 100%;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
    transition: right 0.3s ease;
}

.cart-drawer-overlay.active .cart-drawer {
    right: 0;
}

.cart-header {
    background-color: var(--bg-light);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.close-cart-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
}

.cart-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.cart-item {
    display: flex;
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.cart-item-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}

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

.cart-item-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.cart-item-price {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark);
}

.cart-item-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}

.cart-footer {
    padding: 16px;
    background-color: var(--bg-light);
    border-top: 1px solid var(--border-color);
}

.cart-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.btn-checkout {
    width: 100%;
    background-color: var(--success-color);
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 700;
}

/* Form Controls & Buttons */
.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.form-control {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
}

.btn-confirm-order,
.btn-primary-lg {
    width: 100%;
    background-color: var(--accent-blue);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1rem;
}

.success-icon {
    font-size: 3.5rem;
    margin-bottom: 8px;
}

.order-receipt-card {
    background-color: #f8f9fa;
    border: 1px dashed var(--border-color);
    padding: 16px;
    border-radius: 6px;
    margin-top: 16px;
    text-align: left;
    font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.app-footer {
    background-color: #333;
    color: #ccc;
    padding: 32px 16px 16px;
    margin-top: 40px;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;

}

.footer-col h4 {
    color: #fff;
    margin-bottom: 12px;
}

.link-admin {
    color: var(--primary-color);
    font-weight: 600;
}

.footer-bottom {
    max-width: 1200px;
    margin: 24px auto 0;
    padding-top: 16px;
    border-top: 1px solid #444;
    text-align: center;
    font-size: 0.85rem;
}

/* Responsive Rules */
@media (max-width: 768px) {
    .header-search-bar {
        display: none;
    }
    .header-search-mobile {
        display: flex;
    }
    .modal-body-detail {
        grid-template-columns: 1fr;
    }
}
