/* =========================================
   1. RESETEO Y CONFIGURACIÓN GLOBAL
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #0a0a0a;
    color: #ffffff;
    height: 100dvh; 
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.oculto { display: none !important; }

/* =========================================
   2. PANTALLA DE INICIO
   ========================================= */
#vista-inicio {
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.header { text-align: center; margin-top: 40px; margin-bottom: 50px; }
.header h1 { font-size: 2.5rem; letter-spacing: 2px; text-transform: uppercase; }
.gold-text { color: #d4af37; }
.subtitle { color: #888; font-size: 1rem; margin-top: 5px; }

.menu-principal {
    display: flex;
    flex-direction: column;
    gap: 28px;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.btn-principal {
    background-color: #1a1a1a;
    border: 2px solid #333;
    border-radius: 15px;
    padding: 25px 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #ffffff;
    text-align: left;
}

.btn-principal:active { transform: scale(0.97); border-color: #d4af37; background-color: #222; }

.icon {
    font-size: 2rem;
    margin-right: 20px;
    background-color: #0a0a0a;
    padding: 10px;
    border-radius: 50%;
    border: 1px solid #d4af37;
}

.text { font-size: 1.3rem; font-weight: 600; letter-spacing: 1px; }

/* =========================================
   3. PANTALLA DE VENTAS
   ========================================= */
#vista-venta, #vista-productos, #vista-cierre {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 15px;
    padding-bottom: 0; 
}

.btn-volver {
    background: transparent;
    color: #d4af37;
    border: 1px solid #d4af37;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    align-self: flex-start;
    margin-bottom: 10px;
}

#buscador, #form-producto input {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 2px solid #333;
    background-color: #1a1a1a;
    color: white;
    font-size: 1rem;
    outline: none;
    margin-bottom: 10px;
}

#buscador:focus { border-color: #d4af37; }

.grid-productos {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    overflow-y: auto;
    flex-grow: 1;
    align-content: start;
    padding-bottom: 10px;
}

.tarjeta-producto {
    background-color: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 10px 5px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
}

.tarjeta-producto:active { border-color: #d4af37; background-color: #222; }
.tarjeta-producto h4 { font-size: 0.75rem; margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tarjeta-producto p { color: #d4af37; font-weight: bold; font-size: 0.9rem; }

.carrito-items {
    max-height: 170px;
    overflow-y: auto;
    background-color: #111;
    border-radius: 10px;
    padding: 5px;
    margin-bottom: 10px;
    border: 1px solid #222;
}

.item-carrito {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-bottom: 1px solid #333;
    font-size: 0.85rem;
}

.btn-eliminar {
    background-color: #ff3333;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 4px 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.8rem;
}

.carrito-total {
    background-color: #111;
    border-top: 2px solid #d4af37;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 15px 15px 0 0;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)); 
}

.carrito-total h3 { font-size: 1.2rem; }
#total-pagar { color: #d4af37; }

.btn-cobrar {
    background-color: #d4af37;
    color: #000;
    border: none;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
}

.btn-cobrar:active { transform: scale(0.95); }

/* =========================================
   4. MIS PRODUCTOS Y CIERRE DEL DÍA
   ========================================= */
#form-producto {
    background: #1a1a1a; 
    padding: 12px; 
    border-radius: 10px; 
    border: 1px solid #333; 
    margin-bottom: 15px;
}

#lista-inventario, .lista-historial {
    flex-grow: 1;
    overflow-y: auto; 
    background: #111; 
    border-radius: 10px; 
    padding: 10px;
    margin-bottom: 15px;
}

.tarjeta-totales {
    background: #1a1a1a; 
    border: 2px solid #d4af37; 
    border-radius: 15px; 
    padding: 20px; 
    text-align: center; 
    margin-bottom: 20px;
}

/* =========================================
   5. MODALES
   ========================================= */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-contenido {
    background-color: #1a1a1a;
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #d4af37;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.detalle-recibo {
    background-color: #0a0a0a;
    padding: 10px;
    border-radius: 8px;
    margin: 15px 0;
    font-size: 0.9rem;
}

.metodo-pago-btn {
    flex: 1;
    padding: 10px;
    background: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

.metodo-pago-btn.activo { background: #d4af37; color: black; border-color: #d4af37; }

#pago-recibido {
    width: 100%; 
    padding: 12px; 
    margin-bottom: 10px; 
    border-radius: 8px; 
    border: 2px solid #d4af37; 
    background: #0a0a0a; 
    color: white; 
    font-size: 1.2rem;
    outline: none;
}

/* --- Categorías --- */
.categorias-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 10px;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.categoria-btn {
    background-color: #1a1a1a;
    color: #fff;
    border: 1px solid #333;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.2s;
}

.categoria-btn.activo {
    background-color: #d4af37;
    color: #000;
    border-color: #d4af37;
    font-weight: bold;
}

/* =========================================
   6. IMPRESIÓN
   ========================================= */
@media print {
    body * { visibility: hidden; }
    .modal-contenido, .modal-contenido * { visibility: visible; }
    .modal-contenido {
        position: absolute; left: 0; top: 0; width: 100%;
        border: none; background-color: white; color: black; box-shadow: none;
    }
    .detalle-recibo { background-color: white; color: black; border: none; }
    .detalle-recibo p, .detalle-recibo h3, .detalle-recibo strong { color: black !important; }
    #btn-cerrar-recibo, #btn-imprimir-recibo, h2 { display: none !important; }
}