/* =========================================
   ESTILO GENERAL
========================================= */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    font-family: Arial, sans-serif;
}

body {
    overflow-x: hidden;
}

/* =========================================
   LOGO FIJO
========================================= */

.logo-fijo {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: white;
    padding: 5px;
    border-radius: 5px;
}


.logo-fijo a {
    display: inline-block;
    cursor: pointer;
}


.logo-fijo img {
    height: 50px;
    width: auto;
    object-fit: contain;
}

/* =========================================
   PRODUCTOS - COMPUTADORA
========================================= */

#productos,
.grid-productos {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    padding: 12px;
    width: 100%;
}

.tarjeta-producto {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    box-shadow: 1px 1px 6px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
    min-width: 0;
}

.tarjeta-producto:hover {
    transform: scale(1.02);
}

/* IMAGENES */

.imagen-producto {
    width: 100%;
    height: 280px;
    object-fit: contain;
    display: block;
    margin: 0 auto 10px;
}

/* NOMBRE */

.tarjeta-producto h3 {
    font-size: 17px;
    margin: 8px 0;
}

/* PRECIO */

.precio {
    font-weight: bold;
    color: #2a8a00;
    font-size: 18px;
    margin: 8px 0;
}

/* =========================================
   BOTONES DE PRODUCTOS
========================================= */

#productos button {
    cursor: pointer;
    border: none;
    border-radius: 5px;
    padding: 9px;
}

/* =========================================
   ADMINISTRADOR
========================================= */

a.editar-link {
    display: inline-block;
    margin-top: 5px;
    color: #007bff;
    text-decoration: none;
}

a.editar-link:hover {
    text-decoration: underline;
}

.editar-link {
    background: none;
    border: none;
    padding: 4px 6px;
    font-size: 14px;
    cursor: pointer;
    color: #007bff;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.admin-actions {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.btn-eliminar-prod {
    background: #e53935;
    color: white;
    border: none;
    padding: 5px 10px;
    font-size: 0.9em;
    border-radius: 4px;
    cursor: pointer;
}

.btn-eliminar-prod:hover {
    background: #c62828;
}

/* =========================================
   CARRITO - LISTA
========================================= */

#lista-carrito {
    list-style: none;
    padding-left: 0;
}

#lista-carrito button {
    margin-left: 5px;
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    color: white;
}

#lista-carrito button:nth-child(2) {
    background: green;
}

#lista-carrito button:nth-child(3) {
    background: orange;
}

#lista-carrito button:nth-child(4) {
    background: red;
}

/* =========================================
   TABLA DEL CARRITO
========================================= */

#tabla-carrito {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 11px;
    margin-top: 10px;
}

#tabla-carrito th,
#tabla-carrito td {
    padding: 4px 2px;
    text-align: left;
    border: none;
    overflow: hidden;
    overflow-wrap: anywhere;
}

#tabla-carrito th {
    font-weight: bold;
    color: #333;
}

#tabla-carrito th:nth-child(1),
#tabla-carrito td:nth-child(1) {
    width: 32%;
}

#tabla-carrito th:nth-child(2),
#tabla-carrito td:nth-child(2) {
    width: 13%;
}

#tabla-carrito th:nth-child(3),
#tabla-carrito td:nth-child(3) {
    width: 18%;
}

#tabla-carrito th:nth-child(4),
#tabla-carrito td:nth-child(4) {
    width: 20%;
}

#tabla-carrito th:nth-child(5),
#tabla-carrito td:nth-child(5) {
    width: 17%;
}

/* =========================================
   INPUTS DE CANTIDAD Y PRECIO
========================================= */

.input-cantidad::-webkit-outer-spin-button,
.input-cantidad::-webkit-inner-spin-button,
.input-precio::-webkit-outer-spin-button,
.input-precio::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-cantidad,
.input-precio {
    -moz-appearance: textfield;
    appearance: textfield;
    padding: 2px;
    font-size: 12px;
    text-align: right;
}

.input-cantidad {
    width: 38px;
}

.input-precio {
    width: 55px;
}

/* =========================================
   BOTONES DEL CARRITO
========================================= */

#tabla-carrito button {
    margin-left: 3px;
    padding: 4px 6px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: white;
}

#carrito-flotante button {
    margin-top: 10px;
    padding: 8px 12px;
    background: #007bff;
    border: none;
    color: white;
    border-radius: 5px;
    cursor: pointer;
}

/* =========================================
   BOTON ELIMINAR
========================================= */

.btn-eliminar {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    font-size: 18px;
    color: #888;
    line-height: 1;
    transition: color 0.2s ease, transform 0.2s ease;
}

.btn-eliminar:hover {
    color: red;
    transform: scale(1.2);
}

#tabla-carrito .btn-eliminar {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
    background: red !important;
    color: white !important;
    font-size: 16px !important;
    padding: 4px 6px !important;
}

/* =========================================
   CARRITO FLOTANTE
========================================= */

#carrito-flotante {
    position: fixed !important;

    top: 150px;
    right: 10px;
    left: auto;

    width: 240px !important;
    min-width: 240px !important;
    max-width: 240px !important;

    padding: 10px;

    box-sizing: border-box !important;

    max-height: 75vh;

    overflow-x: hidden !important;
    overflow-y: auto !important;

    background: rgba(255,255,255,0.96);
    border: 1px solid #ccc;
    border-radius: 8px;

    box-shadow: 0 0 8px rgba(0,0,0,0.2);

    font-family: Arial, sans-serif;

    z-index: 99999;

    contain: inline-size;
}

/* ELEMENTOS INTERNOS */

#carrito-flotante * {
    box-sizing: border-box !important;
    min-width: 0;
}

/* TITULO */

#carrito-flotante h2 {
    font-size: 18px;
    margin: 8px 0;
}

/* CLIENTE */

#carrito-flotante #cliente {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 12px;
    padding: 6px;
}

/* TABLA */

#carrito-flotante #tabla-carrito {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed !important;
    font-size: 11px;
}

#carrito-flotante #tabla-carrito th,
#carrito-flotante #tabla-carrito td {
    padding: 3px 2px !important;
    font-size: 10px;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* INPUTS */

#carrito-flotante .input-cantidad {
    width: 100% !important;
    max-width: 38px;
}

#carrito-flotante .input-precio {
    width: 100% !important;
    max-width: 55px;
}

/* BARRA MOVIBLE */

#mover-carrito {
    background: #333;
    color: white;
    padding: 9px;
    margin: -10px -10px 10px -10px;
    text-align: center;
    font-weight: bold;
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    border-radius: 8px 8px 0 0;
}

#mover-carrito.moviendo {
    background: #087bce;
}

/* =========================================
   CARRITO MINIMIZADO
========================================= */

#carrito-minimizado {
    display: none;
    position: fixed;
    right: 20px;
    bottom: 20px;

    width: 65px;
    height: 65px;

    background: #198754;
    color: white;

    border-radius: 50%;
    cursor: pointer;

    z-index: 99999;

    align-items: center;
    justify-content: center;
    flex-direction: column;

    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

#carrito-minimizado i {
    font-size: 25px;
}

#carrito-minimizado span {
    font-size: 10px;
}

#carrito-flotante.minimizado {
    display: none !important;
}

/* =========================================
   CELULARES
========================================= */

@media only screen and (max-width: 768px) {

    html, body {
        width: 100%;
        overflow-x: hidden;
    }

    /* PRODUCTOS */

    #productos,
    .grid-productos {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        padding: 5px !important;
        width: 100% !important;
    }

    /* TARJETAS */

    #productos .tarjeta-producto {
        display: flex;
        flex-direction: column;

        width: 100% !important;
        min-width: 0 !important;

        padding: 5px !important;
        margin: 0 !important;

        border: 1px solid #eee;
        border-radius: 7px;

        background: white;
        box-shadow: none;
    }

    /* IMAGENES GRANDES */

    #productos .imagen-producto {
        width: 100% !important;
        height: 230px !important;
        object-fit: contain !important;
        display: block;
        margin: 0 auto 5px !important;
    }

    /* NOMBRES */

    #productos h3 {
        font-size: 12px !important;
        line-height: 1.3;
        margin: 3px 0 !important;
        text-align: left;
    }

    /* DESCRIPCIONES */

    #productos p {
        font-size: 11px !important;
        line-height: 1.3;
        margin: 3px 0 !important;
        text-align: left;
    }

    /* PRECIOS */

    #productos .precio {
        font-size: 16px !important;
        font-weight: bold;
        color: #e53935 !important;
        margin: 5px 0 !important;
    }

    /* BOTONES */

    #productos button {
        font-size: 11px !important;
        padding: 7px 3px !important;
        width: 100% !important;
    }

    /* ADMINISTRADOR */

    #productos .admin-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        font-size: 11px;
    }

    #productos .editar-link {
        font-size: 11px;
    }

    /* CARRITO ESTRECHO */

    #carrito-flotante {
        width: 220px !important;
        min-width: 220px !important;
        max-width: 220px !important;

        right: 5px !important;
        padding: 8px !important;

        max-height: 75vh;
    }

    /* BARRA MOVIBLE */

    #mover-carrito {
        margin: -8px -8px 10px -8px;
        padding: 9px;
    }

    /* TABLA */

    #tabla-carrito th,
    #tabla-carrito td {
        font-size: 10px;
        padding: 3px 2px;
    }

    /* LOGO */

    .logo-fijo img {
        height: 42px;
    }
}

/* =========================================
   PANTALLAS GRANDES
========================================= */

@media (min-width: 1200px) {

    #productos,
    .grid-productos {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 25px;
    }

    .imagen-producto {
        height: 300px;
    }
}






/* =====================================
   AJUSTE FINAL DE LA TABLA DEL CARRITO
===================================== */

#carrito-flotante #tabla-carrito {
    display: table !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;

    table-layout: fixed !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;

    margin: 8px 0 !important;
    padding: 0 !important;
}

#carrito-flotante #tabla-carrito th,
#carrito-flotante #tabla-carrito td {
    padding: 3px 1px !important;
    font-size: 10px !important;
    text-align: left !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

/* COLUMNAS */

#carrito-flotante #tabla-carrito th:nth-child(1),
#carrito-flotante #tabla-carrito td:nth-child(1) {
    width: 34% !important;
}

#carrito-flotante #tabla-carrito th:nth-child(2),
#carrito-flotante #tabla-carrito td:nth-child(2) {
    width: 13% !important;
}

#carrito-flotante #tabla-carrito th:nth-child(3),
#carrito-flotante #tabla-carrito td:nth-child(3) {
    width: 17% !important;
}

#carrito-flotante #tabla-carrito th:nth-child(4),
#carrito-flotante #tabla-carrito td:nth-child(4) {
    width: 22% !important;
}

#carrito-flotante #tabla-carrito th:nth-child(5),
#carrito-flotante #tabla-carrito td:nth-child(5) {
    width: 14% !important;
}

/* AJUSTE DEL CONTENEDOR */

#carrito-flotante {
    overflow-x: hidden !important;
}

#carrito-flotante #tabla-carrito input {
    max-width: 100% !important;
}

/* CLIENTE */

#carrito-flotante #cliente {
    width: 100% !important;
}

/* BOTON TICKET */

#carrito-flotante > button {
    width: 100% !important;
}



/* BOTÓN AGREGAR AL CARRITO */
#productos .btn-agregar-carrito {
    display: block;
    width: 100%;
    background-color: #000 !important;
    color: #fff !important;
    border: none;
    border-radius: 6px;
    padding: 11px 5px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

#productos .btn-agregar-carrito:hover {
    background-color: #333 !important;
}

/* CELULARES */
@media (max-width: 768px) {
    #productos .btn-agregar-carrito {
        font-size: 12px;
        padding: 10px 3px;
    }
}



/* ALINEAR TOTAL DEL CARRITO A LA DERECHA */

#carrito-flotante p {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin: 10px 0;
}



#carrito-flotante #total {
    text-align: right;
    margin-left: auto;
    font-weight: bold;
}


