/* ZIVO · Aprobaciones de pagos · responsive móvil
   Cargado solo hasta 768 px desde index.html. No altera escritorio. */

@media (max-width: 768px) {
  app-aprobaciones-pagos {
    display: block;
    width: 100%;
    min-width: 0;
    --mobile-card-radius: 16px;
    --mobile-control-h: 44px;
    --mobile-gap: 10px;
  }

  app-aprobaciones-pagos .contenedor-principal {
    width: 100%;
    min-width: 0;
    min-height: 100dvh;
    padding: 10px 10px max(24px, env(safe-area-inset-bottom));
    overflow-x: hidden;
    background: #f4f7fb;
  }

  app-aprobaciones-pagos h1 {
    margin: 4px 0 10px;
    padding: 8px 4px 12px;
    border-bottom: 0;
    text-align: left;
    color: #0f172a;
    font-size: clamp(1.02rem, 5vw, 1.25rem);
    line-height: 1.2;
    letter-spacing: -0.015em;
  }

  app-aprobaciones-pagos h1::after {
    content: "Gestión y revisión de solicitudes";
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 0.69rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
  }

  /* Cabecera del departamento */
  app-aprobaciones-pagos .header-top {
    display: block;
    margin: 0 0 8px;
  }

  app-aprobaciones-pagos .department {
    display: flex;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 8px 11px;
    border: 1px solid #dbe4ef;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  }

  app-aprobaciones-pagos .department p {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0;
    color: #334155;
    font-size: 0.78rem;
  }

  app-aprobaciones-pagos .department span {
    flex: 0 0 auto;
  }

  app-aprobaciones-pagos .flex-space-between {
    justify-content: flex-end;
    margin: 0 0 8px;
  }

  app-aprobaciones-pagos .config-tabla {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: #fff;
  }

  app-aprobaciones-pagos .config-tabla svg {
    width: 22px;
    height: 22px;
  }

  app-aprobaciones-pagos .modal-config-tabla {
    position: fixed;
    z-index: 3200;
    top: 68px;
    right: 10px;
    left: 10px;
    width: auto;
    min-width: 0;
    max-height: calc(100dvh - 88px);
    padding: 14px;
    overflow-y: auto;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  }

  app-aprobaciones-pagos .modal-config-tabla label {
    min-height: 38px;
    margin: 0;
    padding: 5px 4px;
    border-bottom: 1px solid #eef2f7;
    font-size: 0.8rem;
  }

  app-aprobaciones-pagos .modal-config-tabla input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }

  /* Filtros: grilla táctil de dos columnas */
  app-aprobaciones-pagos .busqueda-container {
    gap: 8px;
    margin-bottom: 8px;
  }

  app-aprobaciones-pagos .busqueda-box {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    padding: 11px;
    border: 1px solid #dbe4ef;
    border-radius: var(--mobile-card-radius);
    background: #fff;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.05);
  }

  app-aprobaciones-pagos .busqueda-input,
  app-aprobaciones-pagos .busqueda-select {
    width: 100%;
    min-width: 0;
  }

  app-aprobaciones-pagos .busqueda-input input,
  app-aprobaciones-pagos .busqueda-input select,
  app-aprobaciones-pagos .busqueda-select select,
  app-aprobaciones-pagos .fecha input {
    width: 100%;
    max-width: none;
    min-width: 0;
    height: var(--mobile-control-h);
    padding: 0 11px;
    border: 1px solid #cbd5e1;
    border-radius: 11px;
    background: #fff;
    color: #172033;
    font-size: 16px;
  }

  app-aprobaciones-pagos .busqueda-input select,
  app-aprobaciones-pagos .busqueda-select select {
    padding-right: 28px;
    text-overflow: ellipsis;
  }

  app-aprobaciones-pagos .input-group label {
    display: none;
  }

  app-aprobaciones-pagos .fecha {
    display: flex !important;
    flex-direction: column !important;
  }

  app-aprobaciones-pagos .fecha label {
    position: static;
    display: block;
    order: -1;
    margin: 0 0 4px 3px;
    padding: 0;
    transform: none;
    opacity: 1;
    background: transparent;
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    pointer-events: none;
  }

  /* Estados como chips desplazables */
  app-aprobaciones-pagos .busqueda-estados {
    justify-content: flex-start;
    gap: 7px;
    margin: 0;
    padding: 3px 1px 6px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  app-aprobaciones-pagos .busqueda-estados::-webkit-scrollbar {
    display: none;
  }

  app-aprobaciones-pagos .busqueda-estados label {
    min-height: 38px;
    flex: 0 0 auto;
    padding: 0 12px;
    border: 1px solid #d7e0ea;
    border-radius: 999px;
    background: #fff;
    color: #526174;
    font-size: 0.75rem;
    font-weight: 700;
    scroll-snap-align: start;
    -webkit-tap-highlight-color: transparent;
  }

  app-aprobaciones-pagos .busqueda-estados label:has(input:checked) {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
  }

  app-aprobaciones-pagos .busqueda-estados input[type="radio"] {
    width: 15px;
    height: 15px;
    margin: 0;
  }

  /* Rangos rápidos */
  app-aprobaciones-pagos .filtros-rapidos {
    flex-wrap: nowrap;
    gap: 7px;
    margin: 0 -1px 8px;
    padding: 1px 1px 5px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  app-aprobaciones-pagos .filtros-rapidos::-webkit-scrollbar {
    display: none;
  }

  app-aprobaciones-pagos .filtros-rapidos button,
  app-aprobaciones-pagos .suma-total {
    min-height: 36px;
    height: 36px;
    flex: 0 0 auto;
    padding: 0 12px;
    border-radius: 999px;
    white-space: nowrap;
    font-size: 0.72rem;
  }

  app-aprobaciones-pagos .suma-total {
    margin-left: auto;
  }

  /* Paginación */
  app-aprobaciones-pagos .pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 7px;
    margin: 7px 0 10px;
  }

  app-aprobaciones-pagos .pagination button {
    min-width: 0;
    min-height: 40px;
    padding: 0 10px;
    border-radius: 11px;
    font-size: 0.74rem;
  }

  app-aprobaciones-pagos .pagination span {
    display: grid;
    place-items: center;
    white-space: nowrap;
    font-size: 0.7rem;
  }

  /* Tabla -> tarjetas móviles */
  app-aprobaciones-pagos .contenedor,
  app-aprobaciones-pagos .borde-tabla {
    width: 100%;
    min-width: 0;
  }

  app-aprobaciones-pagos .borde-tabla {
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  app-aprobaciones-pagos table,
  app-aprobaciones-pagos tbody {
    display: block;
    width: 100%;
  }

  app-aprobaciones-pagos thead {
    display: none;
  }

  app-aprobaciones-pagos tbody {
    display: grid;
    gap: 11px;
  }

  app-aprobaciones-pagos tbody > tr {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
    border: 1px solid #dbe4ef;
    border-left: 4px solid #2f6fca;
    border-radius: var(--mobile-card-radius);
    background: #fff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.07);
  }

  app-aprobaciones-pagos tbody > tr.actualizar {
    border-left-color: #f59e0b;
  }

  app-aprobaciones-pagos tbody > tr.estado-subido {
    border-left-color: #16a34a;
  }

  app-aprobaciones-pagos tbody > tr.estado-esperando {
    border-left-color: #d97706;
  }

  app-aprobaciones-pagos tbody > tr.estado-observaciones {
    border-left-color: #dc2626;
  }

  app-aprobaciones-pagos tbody > tr:hover td {
    background: transparent;
  }

  app-aprobaciones-pagos tbody td {
    position: relative;
    display: grid;
    grid-template-columns: minmax(92px, 30%) minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #edf2f7;
    background: transparent;
    color: #243244;
    text-align: left !important;
    font-size: 0.78rem;
    line-height: 1.42;
    overflow-wrap: anywhere;
  }

  app-aprobaciones-pagos tbody td:last-child {
    border-bottom: 0;
  }

  app-aprobaciones-pagos tbody td::before {
    content: attr(data-label);
    align-self: start;
    color: #738196;
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 1.35;
    letter-spacing: 0.035em;
    text-transform: uppercase;
  }

  app-aprobaciones-pagos tbody td > * {
    min-width: 0;
  }

  app-aprobaciones-pagos tbody td[data-label="Cod. Local / Factura"] {
    padding-top: 13px;
    background: linear-gradient(180deg, #f8fbff 0%, #fff 100%);
  }

  app-aprobaciones-pagos tbody td[data-label="Cod. Local / Factura"] strong {
    color: #1e3a5f;
  }

  app-aprobaciones-pagos tbody td[data-label="Valor a pagar"] > div {
    align-items: flex-start;
    text-align: left !important;
  }

  app-aprobaciones-pagos tbody td[data-label="Valor a pagar"] > div > span:first-child {
    color: #0f5132;
    font-size: 1rem;
    font-weight: 800;
  }

  app-aprobaciones-pagos .col-forma-pago .forma-pago-container,
  app-aprobaciones-pagos .forma-pago-container {
    gap: 5px;
    align-items: flex-start;
    min-width: 0;
  }

  app-aprobaciones-pagos .col-forma-pago .account-info,
  app-aprobaciones-pagos .account-info {
    width: fit-content;
    max-width: 100%;
    white-space: normal;
  }

  app-aprobaciones-pagos .obs-cell {
    width: 100%;
    min-width: 0;
  }

  app-aprobaciones-pagos textarea {
    width: 100% !important;
    min-height: 94px;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 16px;
    resize: vertical;
  }

  /* Acciones: zona táctil clara */
  app-aprobaciones-pagos tbody td[data-label="Acciones"] {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 7px;
    padding: 11px 12px 13px;
    background: #f8fafc;
  }

  app-aprobaciones-pagos tbody td[data-label="Acciones"]::before {
    flex: 0 0 100%;
    margin-bottom: 1px;
  }

  app-aprobaciones-pagos tbody td[data-label="Acciones"] > div {
    display: contents;
  }

  app-aprobaciones-pagos tbody td[data-label="Acciones"] .btn-table,
  app-aprobaciones-pagos tbody td[data-label="Acciones"] .btn,
  app-aprobaciones-pagos tbody td[data-label="Acciones"] button {
    min-height: 40px;
    flex: 1 1 calc(50% - 4px);
    min-width: 112px;
    margin: 0;
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    touch-action: manipulation;
  }

  app-aprobaciones-pagos tbody td[data-label="Acciones"] .file-input-table {
    width: 100%;
    min-height: 42px;
    flex: 0 0 100%;
    padding: 7px;
    border: 1px dashed #b7c4d3;
    border-radius: 10px;
    background: #fff;
    font-size: 0.72rem;
  }

  app-aprobaciones-pagos tbody td[colspan] {
    display: block;
    padding: 24px 14px;
    text-align: center !important;
    color: #64748b;
  }

  app-aprobaciones-pagos tbody td[colspan]::before {
    display: block;
    content: attr(data-label);
    color: #64748b;
    font-size: 0.78rem;
    text-transform: none;
  }

  /* Modales -> bottom sheet profesional */
  app-aprobaciones-pagos .modal,
  app-aprobaciones-pagos .modal-overlay,
  app-aprobaciones-pagos .pdf-modal-backdrop {
    padding: 58px 0 0;
    align-items: flex-end;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }

  app-aprobaciones-pagos .contenedor-modal,
  app-aprobaciones-pagos .modal-content,
  app-aprobaciones-pagos .pdf-modal-container {
    width: 100% !important;
    max-width: none !important;
    max-height: calc(100dvh - 58px) !important;
    margin: 0 !important;
    padding: 16px 14px max(16px, env(safe-area-inset-bottom));
    overflow-y: auto;
    border: 0;
    border-top: 3px solid #2563eb;
    border-radius: 20px 20px 0 0;
    background: #fff;
    box-shadow: 0 -20px 50px rgba(15, 23, 42, 0.18);
  }

  app-aprobaciones-pagos .contenedor-modal h2 {
    margin: 0 0 14px;
    padding-right: 4px;
    color: #172033;
    font-size: 1rem;
    line-height: 1.3;
    text-align: left;
  }

  app-aprobaciones-pagos .contenedor-areas-asignadas {
    display: grid;
    gap: 8px;
  }

  app-aprobaciones-pagos .area-card {
    min-height: 54px;
    border-radius: 12px;
  }

  app-aprobaciones-pagos .card-content,
  app-aprobaciones-pagos .card-contents {
    min-width: 0;
  }

  app-aprobaciones-pagos .card-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
  }

  app-aprobaciones-pagos .card-content input,
  app-aprobaciones-pagos .contenedor-modal input,
  app-aprobaciones-pagos .contenedor-modal select {
    max-width: 100%;
    font-size: 16px;
  }

  app-aprobaciones-pagos .btn-right {
    display: flex;
    flex-wrap: wrap;
    gap: 8px !important;
    justify-content: stretch;
    width: 100%;
  }

  app-aprobaciones-pagos .btn-right button,
  app-aprobaciones-pagos .bVerde,
  app-aprobaciones-pagos .bRojo {
    min-height: 42px;
    flex: 1 1 130px;
    margin: 0 !important;
    border-radius: 10px;
  }

  app-aprobaciones-pagos .pdf-modal-header {
    gap: 8px;
    padding: 0 0 10px;
  }

  app-aprobaciones-pagos .pdf-modal-body {
    height: calc(100dvh - 150px);
  }

  app-aprobaciones-pagos .pdf-modal-body iframe {
    width: 100%;
    height: 100%;
  }

  /* Visor de comprobantes/documentos */
  app-aprobaciones-pagos .iframe-container.maximizar {
    position: fixed;
    z-index: 4000;
    inset: 58px 0 0;
    width: 100%;
    height: calc(100dvh - 58px);
    padding: 0 0 max(62px, env(safe-area-inset-bottom));
    background: #0f172a;
  }

  app-aprobaciones-pagos .iframe-container.maximizar iframe {
    width: 100%;
    height: 100%;
    border: 0;
  }

  app-aprobaciones-pagos .iframe-container.maximizar > .btn-right {
    right: 0 !important;
    bottom: 0 !important;
    left: 0;
    display: flex;
    width: 100%;
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
    background: rgba(15, 23, 42, 0.96);
  }

  app-aprobaciones-pagos .iframe-container.maximizar > .btn-right button {
    min-width: 0;
    min-height: 40px;
    flex: 1 1 120px;
    font-size: 0.7rem;
  }

  /* Seguimiento */
  app-aprobaciones-pagos .grupo-container {
    padding: 10px;
    border-radius: 11px;
  }

  app-aprobaciones-pagos .estado-item {
    min-width: 0;
  }

  app-aprobaciones-pagos .estado-item > * {
    overflow-wrap: anywhere;
  }

  app-aprobaciones-pagos .modal-observaciones {
    width: 100% !important;
  }

  app-aprobaciones-pagos .obs-modal-info,
  app-aprobaciones-pagos .obs-section {
    padding: 11px;
    border-radius: 10px;
  }
}

@media (max-width: 480px) {
  app-aprobaciones-pagos .contenedor-principal {
    padding-right: 8px;
    padding-left: 8px;
  }

  app-aprobaciones-pagos .busqueda-box {
    grid-template-columns: 1fr;
  }

  app-aprobaciones-pagos .filtros-rapidos {
    margin-right: -8px;
  }

  app-aprobaciones-pagos .suma-total {
    margin-left: 0;
  }

  app-aprobaciones-pagos tbody td {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 8px;
    padding: 9px 10px;
  }

  app-aprobaciones-pagos tbody td[data-label="Acciones"] .btn-table,
  app-aprobaciones-pagos tbody td[data-label="Acciones"] .btn,
  app-aprobaciones-pagos tbody td[data-label="Acciones"] button {
    flex-basis: 100%;
    min-width: 0;
  }

  app-aprobaciones-pagos .pagination {
    grid-template-columns: 1fr 1fr;
  }

  app-aprobaciones-pagos .pagination span {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 26px;
  }

  app-aprobaciones-pagos .pagination button:first-child {
    grid-column: 1;
  }

  app-aprobaciones-pagos .pagination button:last-child {
    grid-column: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  app-aprobaciones-pagos *,
  app-aprobaciones-pagos *::before,
  app-aprobaciones-pagos *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
