/************************************************************
 * OTF-PRO — PORTAL DE RECIBOS + SELECTOR
 * Archivo: assets/css/portal-recibos.css
 ************************************************************/

/* ==========================
 * CONTENEDOR PRINCIPAL
 * ========================== */

#otf-portal-recibos {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 15px 40px;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#otf-portal-recibos h2,
#otf-portal-recibos h1 {
  margin-bottom: 10px;
}

#otf-recibos-estado {
  margin: 10px 0 15px;
  font-size: 0.95rem;
  color: #555;
}

/* ==========================
 * FILTROS
 * ========================== */

.otf-recibos-filtros {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 15px;
}

.otf-recibos-filtros label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 2px;
  display: block;
}

.otf-recibos-filtros input[type="text"],
.otf-recibos-filtros input[type="date"] {
  width: 100%;
  padding: 7px 9px;
  border-radius: 4px;
  border: 1px solid #cfcfcf;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.otf-recibos-filtros .otf-recibos-acciones {
  grid-column: span 4;
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  margin-top: 5px;
}

#otf-btn-filtrar,
#otf-btn-limpiar {
  padding: 7px 16px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#otf-btn-filtrar {
  background: #0073aa;
  color: #fff;
}

#otf-btn-filtrar:hover {
  background: #005f8a;
}

#otf-btn-limpiar {
  background: #f3f3f3;
  color: #333;
}

#otf-btn-limpiar:hover {
  background: #e2e2e2;
}

/* ==========================
 * GRID DE RECIBOS (PORTAL)
 * ========================== */

#otf-recibos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

/* Card principal */
.otf-recibo-card {
  position: relative;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  border: 1px solid #e7e7e7;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.otf-recibo-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  border-color: #c3dff5;
}

/* Miniatura */
.otf-recibo-thumb {
  background: #f5f5f5;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.otf-recibo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* PDF */
.otf-recibo-pdf-icon {
  width: 64px;
  height: 80px;
  border-radius: 6px;
  border: 2px solid #d9534f;
  color: #d9534f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  background: #fff;
}

/* Meta */
.otf-recibo-meta {
  padding: 8px 10px 10px;
  font-size: 0.8rem;
}

.otf-recibo-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #222;
  margin-bottom: 4px;
  line-height: 1.2;
}

.otf-recibo-line {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 2px;
  color: #555;
}

.otf-recibo-line strong {
  font-size: 0.9rem;
}

/* ==========================
 * BOTÓN BORRAR EN CARD
 * ========================== */

.otf-recibo-card .otf-del-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.8rem;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  z-index: 2;
}

.otf-recibo-card:hover .otf-del-btn {
  opacity: 1;
}

.otf-recibo-card .otf-del-btn:hover {
  background: rgba(217, 83, 79, 0.9);
}

/* ==========================
 * PAGINACIÓN
 * ========================== */

#otf-recibos-paginacion {
  margin-top: 16px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.otf-page-btn {
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  background: #fff;
  font-size: 0.8rem;
  min-width: 28px;
  padding: 4px 8px;
  cursor: pointer;
}

.otf-page-btn.active {
  background: #0073aa;
  color: #fff;
  border-color: #0073aa;
}

/* ==========================
 * MODAL SELECTOR RECIBOS
 * (coincide con presupuesto-app.php)
 * ========================== */

.otf-sel-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none; /* se muestra desde JS */
  align-items: center;
  justify-content: center;
  font-family: inherit;
  background: rgba(0, 0, 0, 0.55);
}

.otf-sel-inner {
  position: relative;
  background: #ffffff;
  border-radius: 10px;
  max-width: 900px;
  width: 96%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  box-sizing: border-box;
}

/* Header (Cancelar / Título / Añadir) */
.otf-sel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.otf-sel-header span {
  font-weight: 600;
}

/* Barra de acciones (Cámara / Archivos) */
.otf-sel-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

/* Botones genéricos */
.otf-btn-primary,
.otf-btn-secondary {
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 7px 14px;
}

.otf-btn-primary {
  background: #7b5cff;
  color: #fff;
}

.otf-btn-primary:hover {
  background: #6540ff;
}

.otf-btn-secondary {
  background: #f3f3f3;
  color: #333;
}

.otf-btn-secondary:hover {
  background: #e2e2e2;
}

/* GRID del selector */
.otf-sel-grid {
  flex: 1;
  margin-top: 4px;
  padding: 8px 4px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  border-radius: 8px;
  background: #fafafa;
}

/* Item del selector */
.otf-sel-item {
  position: relative;
  background: #fff;
  border-radius: 6px;
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.otf-sel-item img,
.otf-sel-item .otf-sel-pdf {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}

.otf-sel-item .otf-sel-pdf {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border-radius: 6px;
  background: #fff5f5;
  color: #d9534f;
}

.otf-sel-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.otf-sel-item.selected {
  border-color: #1e90ff;
  box-shadow: 0 0 0 2px rgba(30, 144, 255, 0.25);
}

/* ==========================
 * ZOOM (SweetAlert popup)
 * ========================== */

.swal2-popup.otf-zoom-popup {
  background: #000 !important;
  box-shadow: none !important;
}

/* ==========================
 * RESPONSIVE
 * ========================== */

@media (max-width: 768px) {
  .otf-recibos-filtros {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .otf-recibos-filtros .otf-recibos-acciones {
    grid-column: span 2;
    flex-wrap: wrap;
  }

  .otf-sel-inner {
    width: 98%;
    padding: 10px 10px 8px;
  }

  .otf-sel-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }

  .otf-recibo-thumb {
    height: 120px;
  }
}

@media (max-width: 480px) {
  #otf-portal-recibos {
    padding: 15px 10px 30px;
  }

  #otf-recibos-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .otf-recibos-filtros {
    grid-template-columns: 1fr;
  }

  .otf-recibos-filtros .otf-recibos-acciones {
    grid-column: span 1;
  }
}
