/* ================= GLOBAL (ESTILO VERDE) ================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', sans-serif;
    background: #007a5a; 
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}
.hidden { display: none !important; }

/* ================= TOP BAR ================= */
.topBar {
    background: #007a5a;
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 22px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    position: sticky; top: 0; z-index: 1000;
}
.logo { height: 35px; width: auto; }

/* ================= TARJETAS ================= */
.card {
    max-width: 420px;
    margin: 60px auto;
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    text-align: center;
}
.card-wide {
    max-width: 1200px;
    margin: 20px auto;
    background: white; 
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* ================= BANNER SALDO (RESPONSIVO) ================= */
.saldo-banner {
    background: linear-gradient(135deg, #008f6a 0%, #005a44 100%);
    color: white;
    padding: 25px;
    border-radius: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap; /* Permite que los botones bajen en pantallas muy pequeñas */
    gap: 20px;
}

.banner-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ================= INPUTS Y BOTONES ================= */
input, select, .select-moderno {
    width: 100%;
    padding: 14px;
    margin-bottom: 15px;
    border-radius: 10px;
    border: 1px solid #ddd;
    font-size: 16px;
    background-color: #fcfcfc;
    outline: none;
}
button {
    width: 100%;
    padding: 14px;
    background: #007a5a;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}
button:hover { background: #004d39; transform: scale(1.02); }

.btn-logout { background: #e74c3c !important; width: auto !important; padding: 10px 20px !important; }
.btn-banner { 
    background: rgba(255,255,255,0.2) !important; 
    border: 1px solid white !important; 
    width: auto !important; 
    min-width: 120px;
}

/* ================= LAYOUT PRINCIPAL (MAGIA RESPONSIVA) ================= */
.main-layout { 
    display: flex; 
    gap: 20px; 
    flex-direction: row; /* Por defecto uno al lado del otro */
}

.col-main { flex: 2; width: 100%; }

.col-side { 
    flex: 1; 
    background: #f9f9f9; 
    padding: 20px; 
    border-radius: 15px; 
    border: 1px solid #eee;
    position: sticky;
    top: 90px;
    height: fit-content;
}

/* ================= TIENDA Y TARJETAS ================= */
.tienda-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); 
    gap: 15px; 
}

.tarjeta { 
    background: white; 
    border: 1px solid #eee; 
    padding: 15px; 
    border-radius: 12px; 
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.tarjeta img { width: 100%; height: 120px; object-fit: contain; margin-bottom: 10px; }

/* ================= LOADER ================= */
.loader-overlay { position: fixed; inset: 0; background: rgba(0,122,90,0.9); display: none; flex-direction: column; align-items: center; justify-content: center; z-index: 5000; color: white; }
.loader-overlay.active { display: flex; }
.spinner { width: 50px; height: 50px; border: 5px solid rgba(255,255,255,0.3); border-top: 5px solid #fff; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 10px; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ================= MODALES ================= */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 3000; }
.modal-content { background: white; padding: 30px; border-radius: 20px; width: 90%; max-width: 500px; color: #333; text-align: center; }

/* ================= MEDIA QUERIES (PARA CELULARES) ================= */
@media (max-width: 850px) {
    .main-layout {
        flex-direction: column; /* Apila los elementos */
    }

    .col-side {
        order: -1; /* MUEVE EL CARRITO ARRIBA de la tienda en celular */
        position: static; /* Quita el sticky para que fluya con el scroll */
        width: 100%;
        margin-bottom: 10px;
    }

    .saldo-banner {
        flex-direction: column;
        text-align: center;
    }

    .banner-actions {
        width: 100%;
    }

    .btn-banner, .btn-logout {
        flex: 1; /* Los botones crecen igual para llenar el ancho */
        font-size: 14px;
        padding: 10px 5px !important;
    }

    .tienda-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 productos por fila en móvil */
        gap: 10px;
    }

    .card-wide {
        margin: 10px;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .tienda-grid {
        grid-template-columns: 1fr; /* 1 producto por fila en pantallas muy pequeñas si prefieres */
    }
    
    /* O mantén 2 columnas ajustando fuentes */
    .tienda-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .tarjeta h4 { font-size: 13px; }
}