
/* =========================================
   📱 RESPONSIVE.CSS - BLOQUE 1 (UNIFICADO)
   ========================================= */


/* =========================
   GENERAL TABLET/MÓVIL
========================= */

@media (max-width: 768px) {

    .container {
        padding: var(--space-md);
    }

    .layout {
        flex-direction: column;
    }
}


/* =========================
   TABLAS RESPONSIVE GENERALES
========================= */

@media (max-width: 768px) {

    .table-wrapper {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        width: 100%;
        border-collapse: collapse;
    }

    th, td {
        white-space: nowrap;
        padding: 10px;
        font-size: 14px;
    }

    .table-wrapper::-webkit-scrollbar {
        height: 6px;
    }

    .table-wrapper::-webkit-scrollbar-thumb {
        background: var(--color-border);
        border-radius: 10px;
    }
}


/* =========================
   MÓVIL PEQUEÑO
========================= */

@media (max-width: 480px) {

    h1 { font-size: 22px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }
}


/* ==================================================================
   📱 LISTADOS UNIFICADOS - TARJETAS DESPLEGABLES EN MÓVIL
================================================================== */

@media (max-width: 768px) {

    .table-wrapper:has(#tablaProductos),
    .table-wrapper:has(#tablaAlbaranes),
    .table-wrapper:has(#tablaClientes),
    .table-wrapper:has(#tablaFacturas),
    .table-wrapper:has(#tablaver_facturas),
    .table-wrapper:has(#tablaProveedores),
    .table-wrapper:has(#tablaResumenProveedor) {
        overflow-x: visible;
        width: 100%;
    }

    #tablaProductos thead,
    #tablaAlbaranes thead,
    #tablaClientes thead,
    #tablaFacturas thead,
    #tablaver_facturas thead,
    #tablaProveedores thead,
    #tablaResumenProveedor thead {
        display: none;
    }

    #tablaProductos, #tablaProductos tbody,
    #tablaAlbaranes, #tablaAlbaranes tbody,
    #tablaClientes, #tablaClientes tbody,
    #tablaFacturas, #tablaFacturas tbody,
    #tablaver_facturas, #tablaver_facturas tbody,
    #tablaProveedores, #tablaProveedores tbody,
    #tablaResumenProveedor, #tablaResumenProveedor tbody {
        display: block;
        width: 100%;
    }

    /* =========================
       TARJETA CERRADA
    ========================= */

    #tablaProductos tbody tr.producto-row,
    #tablaAlbaranes tbody tr.producto-row,
    #tablaClientes tbody tr.producto-row,
    #tablaFacturas tbody tr.producto-row,
    #tablaver_facturas tbody tr.producto-row,
    #tablaProveedores tbody tr.producto-row,
    #tablaResumenProveedor tbody tr.producto-row {
        display: block;
        width: 100%;
        margin-bottom: 10px;
        padding: 0;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        overflow: hidden;
        cursor: pointer;
    }

    #tablaProductos tbody tr.producto-row td,
    #tablaAlbaranes tbody tr.producto-row td,
    #tablaClientes tbody tr.producto-row td,
    #tablaFacturas tbody tr.producto-row td,
    #tablaver_facturas tbody tr.producto-row td,
    #tablaProveedores tbody tr.producto-row td,
    #tablaResumenProveedor tbody tr.producto-row td {
        display: none;
    }

    /* =========================
       TÍTULO SIEMPRE VISIBLE
    ========================= */

    #tablaProductos tbody tr.producto-row td[data-label="Nombre"],
    #tablaAlbaranes tbody tr.producto-row td[data-label="Cliente"], 
    #tablaAlbaranes tbody tr.producto-row td[data-label="Fecha"],
    #tablaClientes tbody tr.producto-row td[data-label="Nombre"],
    #tablaFacturas tbody tr.producto-row td[data-label="Nº Factura"],
    #tablaFacturas tbody tr.producto-row td[data-label="Fecha"],
    #tablaver_facturas tbody tr.producto-row td[data-label="Producto"],
    #tablaProveedores tbody tr.producto-row td[data-label="Nombre"],
    #tablaResumenProveedor tbody tr.producto-row td[data-label="Nº Factura"],
    #tablaResumenProveedor tbody tr.producto-row td[data-label="Fecha"] {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        min-height: 52px;
        padding: 13px 14px;
        border: none;
        font-size: 16px;
        font-weight: 700;
    }

    #tablaProductos tbody tr.producto-row td[data-label="Nombre"]::before,
    #tablaAlbaranes tbody tr.producto-row td[data-label="Cliente"]::before,
    #tablaAlbaranes tbody tr.producto-row td[data-label="Fecha"]::before,
    #tablaClientes tbody tr.producto-row td[data-label="Nombre"]::before,
    #tablaver_facturas tbody tr.producto-row td[data-label="Producto"]::before,
    #tablaFacturas tbody tr.producto-row td[data-label="Nº Factura"]::before,
    #tablaProveedores tbody tr.producto-row td[data-label="Nombre"]::before,
    #tablaResumenProveedor tbody tr.producto-row td[data-label="Nº Factura"]::before {
        display: none;
    }

    #tablaProductos tbody tr.producto-row td[data-label="Nombre"]::after,
    #tablaAlbaranes tbody tr.producto-row td[data-label="Cliente"]::after,
    #tablaClientes tbody tr.producto-row td[data-label="Nombre"]::after,
    #tablaFacturas tbody tr.producto-row td[data-label="Nº Factura"]::after,
    #tablaver_facturas tbody tr.producto-row td[data-label="Producto"]::after,
    #tablaProveedores tbody tr.producto-row td[data-label="Nombre"]::after,
    #tablaResumenProveedor tbody tr.producto-row td[data-label="Nº Factura"]::after {
        content: "▶";
        font-size: 13px;
        margin-left: 10px;
        flex-shrink: 0;
        transition: transform 0.2s ease;
    }

    /* =========================
       TARJETA ABIERTA (DESPLEGADA)
    ========================= */

    #tablaProductos tbody tr.producto-row.producto-abierto td,
    #tablaAlbaranes tbody tr.producto-row.producto-abierto td,
    #tablaClientes tbody tr.producto-row.producto-abierto td,
    #tablaFacturas tbody tr.producto-row.producto-abierto td,
    #tablaver_facturas tbody tr.producto-row.producto-abierto td,
    #tablaProveedores tbody tr.producto-row.producto-abierto td,
    #tablaResumenProveedor tbody tr.producto-row.producto-abierto td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 8px 14px;
        border-bottom: 1px solid var(--color-border);
        white-space: normal;
        font-size: 14px;
    }

    #tablaProductos tbody tr.producto-row.producto-abierto td[data-label="Nombre"],
    #tablaAlbaranes tbody tr.producto-row.producto-abierto td[data-label="Cliente"],
    #tablaClientes tbody tr.producto-row.producto-abierto td[data-label="Nombre"],
    #tablaFacturas tbody tr.producto-row.producto-abierto td[data-label="Nº Factura"],
    #tablaver_facturas tbody tr.producto-row.producto-abierto td[data-label="Producto"],
    #tablaProveedores tbody tr.producto-row.producto-abierto td[data-label="Nombre"],
    #tablaResumenProveedor tbody tr.producto-row.producto-abierto td[data-label="Nº Factura"] {
        display: flex;
        min-height: 52px;
        padding: 13px 14px;
        font-size: 16px;
        font-weight: 700;
        border-bottom: 1px solid var(--color-border);
    }

    #tablaProductos tbody tr.producto-row.producto-abierto td[data-label="Nombre"]::after,
    #tablaAlbaranes tbody tr.producto-row.producto-abierto td[data-label="Cliente"]::after,
    #tablaClientes tbody tr.producto-row.producto-abierto td[data-label="Nombre"]::after,
    #tablaFacturas tbody tr.producto-row.producto-abierto td[data-label="Nº Factura"]::after,
    #tablaver_facturas tbody tr.producto-row.producto-abierto td[data-label="Producto"]::after,
    #tablaProveedores tbody tr.producto-row.producto-abierto td[data-label="Nombre"]::after,
    #tablaResumenProveedor tbody tr.producto-row.producto-abierto td[data-label="Nº Factura"]::after {
        transform: rotate(90deg);
    }

    #tablaProductos tbody tr.producto-row.producto-abierto td:not([data-label="Nombre"])::before,
    #tablaAlbaranes tbody tr.producto-row.producto-abierto td:not([data-label="Cliente"]):not([data-label="Fecha"])::before,
    #tablaClientes tbody tr.producto-row.producto-abierto td:not([data-label="Nombre"])::before,
    #tablaFacturas tbody tr.producto-row.producto-abierto td:not([data-label="Nº Factura"])::before,
    #tablaver_facturas tbody tr.producto-row.producto-abierto td:not([data-label="Producto"])::before,
    #tablaProveedores tbody tr.producto-row.producto-abierto td:not([data-label="Nombre"])::before,
    #tablaResumenProveedor tbody tr.producto-row.producto-abierto td:not([data-label="Nº Factura"])::before {
        content: attr(data-label);
        font-weight: 700;
        flex-shrink: 0;
    }

    /* =========================
       ACCIONES (BOTONES ABAJO)
    ========================= */

    #tablaProductos tbody tr.producto-row.producto-abierto td[data-label="Acciones"],
    #tablaAlbaranes tbody tr.producto-row.producto-abierto td[data-label="Acciones"],
    #tablaClientes tbody tr.producto-row.producto-abierto td[data-label="Acciones"],
    #tablaFacturas tbody tr.producto-row.producto-abierto td[data-label="Acciones"],
    #tablaProveedores tbody tr.producto-row.producto-abierto td[data-label="Acciones"],
    #tablaResumenProveedor tbody tr.producto-row.producto-abierto td[data-label="Acciones"] {
        display: flex;
        justify-content: flex-end;
        gap: 8px;
        flex-wrap: wrap;
        padding: 12px 14px;
        border-bottom: none;
    }

    #tablaProductos tbody tr.producto-row.producto-abierto td[data-label="Acciones"]::before,
    #tablaAlbaranes tbody tr.producto-row.producto-abierto td[data-label="Acciones"]::before,
    #tablaClientes tbody tr.producto-row.producto-abierto td[data-label="Acciones"]::before,
    #tablaFacturas tbody tr.producto-row.producto-abierto td[data-label="Acciones"]::before,
    #tablaProveedores tbody tr.producto-row.producto-abierto td[data-label="Acciones"]::before,
    #tablaResumenProveedor tbody tr.producto-row.producto-abierto td[data-label="Acciones"]::before {
        display: none;
    }

    #tablaProductos tbody tr.producto-row.producto-abierto td.actions,
    #tablaAlbaranes tbody tr.producto-row.producto-abierto td.actions,
    #tablaClientes tbody tr.producto-row.producto-abierto td.actions,
    #tablaFacturas tbody tr.producto-row.producto-abierto td.actions,
    #tablaProveedores tbody tr.producto-row.producto-abierto td.actions,
    #tablaResumenProveedor tbody tr.producto-row.producto-abierto td.actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }

    #tablaProductos tbody tr.producto-row.producto-abierto td.actions .btn,
    #tablaAlbaranes tbody tr.producto-row.producto-abierto td.actions .btn,
    #tablaClientes tbody tr.producto-row.producto-abierto td.actions .btn,
    #tablaFacturas tbody tr.producto-row.producto-abierto td.actions .btn,
    #tablaProveedores tbody tr.producto-row.producto-abierto td.actions .btn,
    #tablaResumenProveedor tbody tr.producto-row.producto-abierto td.actions .btn {
        margin: 0;
    }
}

/* ==========================================================
   📦 NUEVO ALBARÁN - LÍNEAS DE PRODUCTOS EN TARJETAS FIJAS
========================================================== */
@media (max-width: 768px) {

    .table-wrapper:has(#tabla_productos) {
        overflow-x: visible;
        width: 100%;
    }

    #tabla_productos thead {
        display: none;
    }

    #tabla_productos,
    #tabla_productos tbody,
    #tabla_productos tbody tr {
        display: block;
        width: 100%;
    }

    #tabla_productos tbody tr {
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        padding: 12px 14px;
        margin-bottom: 15px;
        box-sizing: border-box;
    }

    #tabla_productos tbody tr td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        width: 100%;
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid var(--color-border);
        box-sizing: border-box;
    }

    #tabla_productos tbody tr td select,
    #tabla_productos tbody tr td input {
        width: 55% !important;
        max-width: 100%;
        padding: 6px 8px;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
        background: var(--color-background, #fff);
        font-size: 14px;
        box-sizing: border-box;
    }

    #tabla_productos tbody tr td input[readonly] {
        background: transparent;
        border: none;
        text-align: right;
        font-weight: 700;
        padding-right: 0;
    }

    #tabla_productos tbody tr td:last-child {
        border-bottom: none;
        padding-top: 10px;
        justify-content: flex-end;
    }

    #tabla_productos tbody tr td:nth-child(1)::before { content: "Categoría"; font-weight: 700; font-size: 14px; }
    #tabla_productos tbody tr td:nth-child(2)::before { content: "Lote"; font-weight: 700; font-size: 14px; }
    #tabla_productos tbody tr td:nth-child(3)::before { content: "Producto"; font-weight: 700; font-size: 14px; }
    #tabla_productos tbody tr td:nth-child(4)::before { content: "Unidades"; font-weight: 700; font-size: 14px; }
    #tabla_productos tbody tr td:nth-child(5)::before { content: "Cantidad"; font-weight: 700; font-size: 14px; }
    #tabla_productos tbody tr td:nth-child(6)::before { content: "Precio"; font-weight: 700; font-size: 14px; }
    #tabla_productos tbody tr td:nth-child(7)::before { content: "Importe"; font-weight: 700; font-size: 14px; }
}