:root {
    --bg-dark: #121417;
    --bg-header: #1a1d21;
    --accent-green: #2ecc71;
    --text-white: #ffffff;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-white);
    font-family: 'Arial', sans-serif;
    margin: 0;
    overflow-x: hidden;
}

/* Header & Search */
.main-header { background-color: var(--bg-header); padding: 0px; position: sticky; top: 0; z-index: 100; }
.header-top { display: flex; justify-content: space-between; align-items: center; padding: 0 5%; gap: 20px; }
.header-top img { width: 60px; height: auto; }
.header-top .logo { font-size: 24px; font-weight: bold; color: white; }
.header-top .logo span { font-weight: 300; }

.search-bar { display: flex; flex-grow: 1; max-width: 500px; }
.search-bar input { width: 100%; padding: 10px; border: none; border-radius: 5px 0 0 5px; }
.search-bar button { background: var(--accent-green); border: none; padding: 10px 15px; color: white; border-radius: 0 5px 5px 0; cursor: pointer; }

.user-actions { display: flex; gap: 20px; align-items: center; }
.cart-icon-container { position: relative; cursor: pointer; font-size: 22px; }
#cart-count { position: absolute; top: -10px; right: -10px; background: #e74c3c; font-size: 12px; padding: 2px 6px; border-radius: 50%; }

/* Carrusel de Rubros */
.categories-container { display: flex; align-items: center; padding: 0fcpx; border-top: 1px solid #2a2d31; }
.categories-wrapper {
    text-align: center;
    display: flex; gap: 30px; overflow-x: auto; scroll-behavior: smooth;
    scrollbar-width: none; -ms-overflow-style: none; padding: 15px 20px;
}
.categories-wrapper::-webkit-scrollbar { display: none; }

.cat-item {
     display: flex; flex-direction: column; align-items: center; gap: 5px;
      text-align: center;
       cursor: pointer;
        transition: 0.3s;
         opacity: 0.7;
     }
.cat-item:hover, .cat-item.active { opacity: 1; transform: translateY(-3px); }
.circle { width: 45px; height: 45px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 5px; font-size: 22px; color: white; }
.cat-item span { font-size: 13px; display: block; }

.scroll-btn { background: none; border: none; color: white; font-size: 20px; cursor: pointer; padding: 10px; }

/* Grid de Productos */
.container { padding: 30px 5%; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 25px; }

.product-card { background: white; border-radius: 12px; overflow: hidden; color: #333; transition: 0.3s; position: relative; }
.product-card img { width: 100%; height: 200px; object-fit: contain; padding: 15px; box-sizing: border-box; }
.info { padding: 15px; text-align: center; }
.price { font-size: 24px; font-weight: bold; margin: 10px 0; color: #111; }
.buy-btn { width: 100%; background: var(--accent-green); color: white; border: none; padding: 12px; border-radius: 8px; font-weight: bold; cursor: pointer; }

/* Carrito Sidebar */
.cart-sidebar { position: fixed; top: 0; right: -400px; width: 380px; height: 100%; background: white; z-index: 1001; transition: 0.4s; display: flex; flex-direction: column; color: #333; }
.cart-sidebar.open { right: 0; }
.cart-header { padding: 20px; background: var(--bg-header); color: white; display: flex; justify-content: space-between; align-items: center; }
#cart-items-container { flex-grow: 1; padding: 20px; overflow-y: auto; }
.cart-footer { padding: 20px; border-top: 1px solid #eee; }
.total-row { display: flex; justify-content: space-between; font-size: 20px; font-weight: bold; margin-bottom: 15px; }
#overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: none; z-index: 1000; }
#overlay.active { display: block; }

/* Animación de Carga (Skeleton) */
.skeleton {
    background-color: #e0e0e0;
    background-image: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

.loader-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    width: 100%;
    gap: 10px;
    font-weight: bold;
    color: #666;
}

/* Contenedor de fondo (oscuro) */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    backdrop-filter: blur(5px);
}
.modal-overlay.active { display: flex; }

/* Caja del Modal */
.modal-content {
    background: #1e1e1e;
    color: #ffffff;
    width: 90%;
    max-width: 420px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    border: 1px solid #333;
}

/* Cabecera */
.modal-header {
    padding: 20px;
    background: #252525;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}
.modal-header h3 { margin: 0; font-size: 1.2rem; color: #f39c12; }

/* Botón de Cierre (X) */
.close-x {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}
.close-x:hover {
    background: #e74c3c;
    transform: rotate(90deg);
    color: white;
}

/* Cuerpo del modal con scroll */
.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-green) #2d2d2d;
}
.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-track { background: #2d2d2d; border-radius: 10px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--accent-green); border-radius: 10px; }

.cuotas-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#pago-producto-nombre { margin-bottom: 10px; color: #ddd; font-weight: 400; }

.precio-principal {
    background: #2d2d2d;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
}
.precio-principal small { display: block; color: #aaa; margin-bottom: 5px; }
.precio-principal span { font-size: 1.8rem; font-weight: bold; color: #2ecc71; }

/* Filas de Cuotas */
.cuota-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #333;
}
.cuota-row span:first-child { color: #ccc; }
.cuota-row span:nth-child(2) { font-weight: bold; color: #fff; }
.cuota-row small { display: block; width: 100%; color: #777; font-size: 0.75rem; }

.cuota-row.efectivo_ {
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid #2ecc71;
    border-radius: 10px;
    margin-bottom: 15px;
}

/* Botón de Acción */
.modal-footer { padding: 10px; text-align: center; }

.btn-primary-ws {
    background: #25d366;
    color: white;
    border: none;
    padding: 10px 10px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    transition: 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
.btn-primary-ws:hover { background: #1ebd5b; transform: translateY(-2px); }

.nota-pie { font-size: 0.8rem; color: #555; margin-top: 15px; }

/* Sidebar del Carrito */
.cart-sidebar {
    position: fixed;
    top: 0; right: -400px; width: 350px; height: 100%;
    background: #1a1a1a; color: white;
    box-shadow: -5px 0 15px rgba(0,0,0,0.5);
    transition: 0.4s; z-index: 4000;
    display: flex; flex-direction: column;
}
.cart-sidebar.open { right: 0; }

.cart-header { padding: 20px; background: #252525; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #333; }
.cart-body { flex: 1; overflow-y: auto; padding: 15px; }

/* Item del Carrito */
.cart-item {
    display: flex; gap: 10px; align-items: center;
    background: #2d2d2d; padding: 10px; border-radius: 10px; margin-bottom: 10px;
}
.cart-item img { width: 50px; height: 50px; border-radius: 5px; object-fit: cover; }
.cart-item-info { flex: 1; }
.cart-item-info h4 { font-size: 0.9rem; margin: 0; }
.cart-item-info p { color: #2ecc71; font-weight: bold; margin: 2px 0; }
.btn-remove-item { background: none; border: none; color: #e74c3c; cursor: pointer; font-size: 1.1rem; }

/* Ficha de Producto */
.ficha-content {
    background: #1e1e1e;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: 24px;
    position: relative;
    overflow-y: auto;
    border: 1px solid #333;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    padding-top: 20px;
}
.ficha-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 30px; }
.ficha-img img { width: 100%; border-radius: 15px; background: white; }
.ficha-info { display: flex; flex-direction: column; justify-content: center; }
.ficha-precio { font-size: 2rem; color: #2ecc71; font-weight: bold; margin: 15px 0; }
.ficha-detalle { color: #bbb; line-height: 1.6; margin-bottom: 20px; }
.ficha-galeria-thumbs { display: flex; gap: 10px; margin-top: 15px; overflow-x: auto; }
.thumb-img { width: 60px; height: 60px; object-fit: cover; border-radius: 5px; cursor: pointer; border: 2px solid #333; }
.thumb-img:hover { border-color: #2ecc71; }
.ficha-specs { display: flex; flex-direction: column; gap: 10px; margin-top: 15px; }
.spec-item { display: flex; align-items: center; gap: 10px; color: #aaa; font-size: 0.9rem; }
.spec-item i { color: #2ecc71; }

/* Botones */
.btn-checkout { width: 100%; padding: 15px; background: #25d366; border: none; color: white; border-radius: 10px; font-weight: bold; cursor: pointer; margin-top: 10px; }
.btn-clear-cart { width: 100%; padding: 8px; background: #c0392b; border: none; color: white; border-radius: 5px; cursor: pointer; font-size: 0.8rem; }
.btn-add-large { padding: 15px; background: #3498db; border: none; color: white; border-radius: 10px; font-weight: bold; cursor: pointer; }

@media (max-width: 600px) { .ficha-grid { grid-template-columns: 1fr; } }

@media (max-width: 768px) {
    .cuota-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 5px;
        border-bottom: 1px solid #333;
    }
    .cuota-row span{
        font-size: 0.8rem;
    }
    .cuota-row small { display: block; width: 80%; color: #777; font-size: 0.75rem; }

    .ficha-content {
        width: 95%;
        max-width: none;
        max-height: 95vh;
        padding: 5px;
    }
    .close-x {
        background: rgba(225, 25, 49, 0.8);
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
    }
    .ficha-img-section {
        border-radius: 15px;
        padding-top: 50px !important;
    }
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================================================== */
/* FICHA TÉCNICA DEL PRODUCTO - ESTILOS COMPLETOS */
/* ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 3500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}
.modal-overlay.active { display: flex; }

.ficha-content {
    background: #1e1e1e;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: 24px;
    position: relative;
    overflow-y: auto;
    border: 1px solid #333;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.ficha-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 0;
}

/* Imagen */
.ficha-img-section {
    background: #fff;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}
#ficha-imagen {
    max-width: 100%;
    max-height: 350px;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

/* Thumbs */
.ficha-galeria-thumbs {
    display: flex;
    gap: 12px;
    margin-top: 25px;
    padding: 10px;
    overflow-x: auto;
    width: 100%;
    justify-content: center;
}
.thumb-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 10px;
    cursor: pointer;
    border: 2px solid #eee;
    background: #fff;
    transition: all 0.2s;
}
.thumb-img:hover {
    border-color: #2ecc71;
    transform: scale(1.1);
}

/* Info ficha */
.ficha-info {
    padding: 40px;
    display: flex;
    flex-direction: column;
}
#ficha-nombre {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: #fff;
    line-height: 1.2;
}
.ficha-codigo {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 20px;
    letter-spacing: 1px;
}
.ficha-precio {
    font-size: 2.5rem;
    font-weight: 800;
    color: #2ecc71;
    margin-bottom: 25px;
}
.ficha-detalle {
    border-top: 1px solid #333;
    padding-top: 20px;
    margin-bottom: 30px;
}
.ficha-specs { display: flex; flex-direction: column; gap: 12px; }
.spec-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
    color: #ccc;
}
.spec-item i { color: #2ecc71; font-size: 1.1rem; }

.btn-add-large {
    width: 100%;
    padding: 18px;
    background: #2ecc71;
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: background 0.3s, transform 0.2s;
}
.btn-add-large:hover {
    background: #27ae60;
    transform: translateY(-2px);
}
.btn-add-large:active { transform: scale(0.98); }

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-width: none;
        max-height: 95vh;
    }
    .ficha-content {
        padding: 0px;
        margin: 0px;
        background: #1e1e1e;
    }
    .modal-overlay {
        background-color: #202020;
        margin: 0px;
        padding: 0px;
    }

    .ficha-grid { grid-template-columns: 1fr; }
    .ficha-img-section { padding: 20px; min-height: auto; }
    .ficha-info { padding: 30px 20px; }
    #ficha-nombre { font-size: 1.0rem; }
    .ficha-precio { font-size: 2rem; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Skeleton card */
.skeleton-card {
    background: white;
    height: 350px;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.skeleton-img { height: 180px; width: 100%; }
.skeleton-text { height: 20px; width: 80%; margin: 0 auto; }
.skeleton-price { height: 30px; width: 60%; margin: 10px auto; }

/* Resaltar rubro seleccionado */
.cat-item.active .circle {
    text-align: center;
    outline: 3px solid var(--accent-green);
    outline-offset: 3px;
    transform: scale(1.1);
}
.cat-item.active span {
    color: var(--accent-green);
    font-weight: bold;
}

/* Estilo para la barra de búsqueda enfocada */
.search-bar input:focus {
    outline: 2px solid var(--accent-green);
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.3);
}

/* Badge de Stock */
.stock-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 20px;
    z-index: 5;
}
.codigo-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 20px;
    z-index: 5;
    background: black;
    color:white;
}
.in-stock { background: #d4edda; color: #155724; }
.no-stock { background: #f8d7da; color: #721c24; }

/* Descripción */
.product-description {
    font-size: 13px;
    color: #666;
    margin: 5px 0 10px;
    line-height: 1.4;
    height: 36px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Botón WhatsApp */
.whatsapp-btn {
    width: 100%;
    background-color: #25d366;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
    transition: background 0.3s;
}
.whatsapp-btn:hover { background-color: #1ebe57; }

/* Botones Circulares */
.extra-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    border-top: 1px solid #eee;
    padding-top: 15px;
}
.circle-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: white;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.circle-btn:hover {
    background: #f8f9fa;
    border-color: #333;
    color: #000;
}
.circle-btn.add-cart:hover {
    background: var(--bg-dark);
    color: white;
    border-color: var(--bg-dark);
}

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        padding: 10px 5%;
        gap: 10px;
    }
    .search-bar {
        width: 100%;
        order: 3;
    }
    .user-actions {
        width: 100%;
        justify-content: space-around;
        padding: 5px 0;
    }
    .circle { width: 40px; height: 40px; font-size: 18px; }
    .cat-item span { font-size: 11px; }

    .product-grid { grid-template-columns: 1fr; gap: 20px; }

    .product-card {
        border-radius: 20px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    }
    .product-card img { height: 250px; }
    .info h3 { font-size: 1.2rem; }
    .price { font-size: 28px; color: #1a1d21; }
    .product-description { height: auto; -webkit-line-clamp: 3; margin-bottom: 15px; }
    .whatsapp-icon img { width: 50px; height: auto; }
    .whatsapp-btn {
        padding: 15px;
        font-size: 16px;
        border-radius: 12px;
    }
    .extra-actions { gap: 20px; }
    .circle-btn { width: 45px; height: 45px; font-size: 20px; }

    .cart-sidebar { width: 100%; right: -100%; }
}
@media (max-width: 400px) {
    .categories-wrapper { gap: 15px; }
    .circle { width: 40px; height: 40px; }
}

/* ================================
   FIX PRO: SIMULADOR ALINEADO + SELECCIONABLE
================================ */
#modal-pagos .modal-content { position: relative; }

#lista-cuotas .cuota-row{
  display: grid;
  grid-template-columns: 1fr 60px auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #333;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}

#lista-cuotas .cuota-row:hover{
  background: rgba(255,255,255,0.04);
  transform: translateY(-1px);
}

#lista-cuotas .cuota-row.selected{
  border: 1px solid var(--accent-green);
  background: rgba(46, 204, 113, 0.12);
  box-shadow: 0 0 0 2px rgba(46,204,113,0.15) inset;
}

#lista-cuotas .info-cuota{
  display:flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

#lista-cuotas .titulo-cuota{
  font-weight: 700;
  color: #eee;
  line-height: 1.1;
}

#lista-cuotas .sub-cuota{
  font-size: .78rem;
  color: #9a9a9a;
  line-height: 1.2;
}

#lista-cuotas .cuota-logo{
  width: 58px;
  height: 34px;
  object-fit: contain;
  display:block;
  margin:0;
}

#lista-cuotas .precio-cuota{
  font-weight: 800;
  color: #fff;
  text-align: right;
  white-space: nowrap;
}

#lista-cuotas .cuota-row.efectivo_{
  border: 1px solid #2ecc71;
}

@media (max-width: 768px){
  #lista-cuotas .cuota-row{
    grid-template-columns: 1fr 52px auto;
    padding: 10px 12px;
    gap: 10px;
    font-size: 0.8rem;
  }
  #lista-cuotas .precio-cuota{ font-size: .92rem; }
  #lista-cuotas .cuota-logo{ width: 50px; height: 30px; }
}
