/* ==========================================================================
   PezControl — captura.css
   Estilos específicos para la vista móvil de Captura de Avance de Obra (PWA).
   Todas las clases prefijadas con 'captura-' para prevenir colisiones.
   ========================================================================== */

/* Contenedor principal móvil */
.captura-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;          /* el contenedor principal oculta el desbordamiento: esta vista hace su propio scroll */
  -webkit-overflow-scrolling: touch;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-md) var(--space-md) 0 var(--space-md);
  box-sizing: border-box;
  background: var(--bg-app);
}

/* Cabecera Técnica */
.captura-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.captura-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm6);
}

.captura-project-name {
  font-size: var(--font-title);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.captura-network-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xxs) var(--space-sm);
  border-radius: var(--radius-pill);
  font-size: var(--font-label);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

.captura-network-online {
  background: var(--color-success-bg);
  color: var(--color-success-dark);
  border: 1px solid var(--color-success);
}

.captura-network-offline {
  background: var(--color-warning-bg);
  color: #92400E;
  border: 1px solid var(--color-warning);
}

/* Barra de fecha y controles de día */
.captura-date-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-top: var(--space-sm);
}

.captura-date-btn {
  min-height: 44px;
  padding: 0 var(--space-md);
  font-size: var(--font-body);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.captura-date-btn:active,
.captura-date-btn:hover {
  background: var(--bg-hover);
  border-color: var(--color-brand);
}

.captura-date-input {
  flex: 1;
  min-height: 44px;
  min-width: 140px;
  padding: 0 var(--space-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--font-body);
  font-family: inherit;
  box-sizing: border-box;
}

.captura-date-input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px rgba(243, 115, 41, 0.2);
}

/* Badge de cola pendiente en header */
.captura-queue-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 36px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-pill);
  font-size: var(--font-label);
  font-weight: var(--font-weight-bold);
  background: var(--color-brand-soft);
  color: var(--color-brand-dark);
  border: 1px solid var(--color-brand-300);
  cursor: pointer;
}

.captura-queue-badge:hover {
  background: var(--color-brand-softer);
}

/* Banner de parte cerrado */
.captura-closed-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  background: #FEF3C7;
  border: 1px solid #F59E0B;
  color: #92400E;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  font-size: var(--font-body);
  font-weight: var(--font-weight-medium);
}

.captura-closed-link {
  color: var(--color-brand-dark);
  font-weight: var(--font-weight-bold);
  text-decoration: underline;
  cursor: pointer;
}

/* Barra de búsqueda y filtros */
.captura-filters-bar {
  margin-bottom: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.captura-search-input {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--font-body);
  box-sizing: border-box;
}

.captura-search-input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px rgba(243, 115, 41, 0.2);
}

.captura-chips-scroll {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  padding-bottom: var(--space-xxs);
  scrollbar-width: thin;
}

.captura-chip-btn {
  min-height: 38px;
  padding: 0 var(--space-md);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: var(--font-label);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.captura-chip-btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.captura-chip-btn.captura-chip-active {
  background: var(--color-brand);
  color: #FFFFFF;
  border-color: var(--color-brand);
}

/* Tarjetas de Partida (Mobile-first, alto contraste al sol) */
.captura-partidas-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.captura-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.captura-card.captura-card-active {
  border-color: var(--color-brand);
  box-shadow: 0 2px 8px rgba(243, 115, 41, 0.18);
}

.captura-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.captura-item-code {
  font-family: var(--font-mono);
  font-size: var(--font-subt);
  font-weight: var(--font-weight-bold);
  color: var(--color-brand);
  background: var(--color-brand-soft);
  padding: var(--space-xxs) var(--space-xs);
  border-radius: var(--radius-sm);
}

.captura-unit-badge {
  font-size: var(--font-label);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  background: var(--bg-surface-subtle);
  padding: var(--space-xxs) var(--space-sm);
  border-radius: var(--radius-pill);
}

.captura-item-desc {
  font-size: var(--font-subt);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: var(--space-sm);
}

/* Métricas contractuales y acumuladas */
.captura-metrics-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-label);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.captura-progress-track {
  width: 100%;
  height: 8px;
  background: var(--border-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: var(--space-md);
  display: flex;
}

.captura-progress-bar-prev {
  height: 100%;
  background: var(--color-info);
  transition: width 0.2s ease;
}

.captura-progress-bar-today {
  height: 100%;
  background: var(--color-brand);
  transition: width 0.2s ease;
}

/* Stepper numérico táctil (≥48px) */
.captura-stepper-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.captura-stepper-label {
  font-size: var(--font-body);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

.captura-stepper-controls {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.captura-btn-stepper {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  font-size: 22px;
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: all 0.15s ease;
}

.captura-btn-stepper:active {
  background: var(--color-brand);
  color: #FFFFFF;
  border-color: var(--color-brand);
  transform: scale(0.96);
}

.captura-input-hoy {
  width: 110px;
  height: 48px;
  font-size: 18px;
  font-weight: var(--font-weight-bold);
  text-align: right;
  padding: 0 var(--space-sm);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}

.captura-input-hoy:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px rgba(243, 115, 41, 0.2);
}

/* Píldoras de incremento rápido */
.captura-quick-adds {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-bottom: var(--space-xs);
}

.captura-quick-btn {
  min-height: 32px;
  padding: 0 var(--space-sm);
  font-size: var(--font-meta);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  cursor: pointer;
}

.captura-quick-btn:hover,
.captura-quick-btn:active {
  border-color: var(--color-brand);
  color: var(--color-brand);
  background: var(--color-brand-soft);
}

/* Aviso de exceso de metrado */
.captura-overbudget-warn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: #FEF9C3;
  border: 1px solid #FDE047;
  color: #854D0E;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-label);
  font-weight: var(--font-weight-medium);
  margin-top: var(--space-xs);
}

/* Botón de foto específica de partida */
.captura-card-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-sm6);
  padding-top: var(--space-xs);
  border-top: 1px dashed var(--border-subtle);
}

.captura-btn-partida-foto {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-label);
  font-weight: var(--font-weight-medium);
  color: var(--color-brand);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: var(--space-xxs) var(--space-xs);
  border-radius: var(--radius-sm);
}

.captura-btn-partida-foto:hover {
  background: var(--color-brand-soft);
}

/* Sección de Fotografías de Obra */
.captura-photos-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.captura-section-title {
  font-size: var(--font-kpi);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.captura-btn-camera {
  width: 100%;
  min-height: 52px;
  background: var(--color-brand);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-subt);
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  cursor: pointer;
  touch-action: manipulation;
  margin-bottom: var(--space-md);
  box-shadow: 0 2px 6px rgba(243, 115, 41, 0.25);
  transition: background 0.15s ease, transform 0.1s ease;
}

.captura-btn-camera:hover {
  background: var(--color-brand-hover);
}

.captura-btn-camera:active {
  transform: scale(0.98);
}

/* Galería de miniaturas */
.captura-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.captura-photo-item {
  position: relative;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface-alt);
  display: flex;
  flex-direction: column;
}

.captura-photo-thumb {
  width: 100%;
  height: 110px;
  object-fit: cover;
  background: #1A2535;
  cursor: pointer;
}

.captura-photo-meta {
  padding: var(--space-xs);
  font-size: var(--font-tiny);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.captura-photo-partida-tag {
  font-weight: var(--font-weight-bold);
  color: var(--color-brand);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.captura-photo-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-round);
  background: rgba(0, 0, 0, 0.65);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.captura-photo-delete-btn:hover {
  background: var(--color-error);
}

/* Sección de Observaciones */
.captura-obs-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.captura-obs-textarea {
  width: 100%;
  min-height: 90px;
  padding: var(--space-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--font-body);
  font-family: inherit;
  box-sizing: border-box;
  resize: vertical;
}

.captura-obs-textarea:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px rgba(243, 115, 41, 0.2);
}

/* Barra inferior fija (Sticky Bottom Bar) */
.captura-sticky-bottom {
  position: sticky;          /* dentro del scroll de la vista: no tapa el menú lateral en escritorio */
  bottom: 0;
  margin: var(--space-md) calc(-1 * var(--space-md)) 0;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: var(--space-sm) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  z-index: var(--z-avance-drawer);
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.08);
}

.captura-sticky-inner {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.captura-btn-save {
  width: 100%;
  min-height: 52px;
  background: var(--color-brand);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-kpi);
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, transform 0.1s ease;
}

.captura-btn-save:hover {
  background: var(--color-brand-hover);
}

.captura-btn-save:active {
  transform: scale(0.98);
}

.captura-btn-save:disabled {
  background: var(--color-silver-500);
  cursor: not-allowed;
  opacity: 0.7;
}

.captura-sync-status-text {
  font-size: var(--font-tiny);
  color: var(--text-secondary);
  text-align: center;
}

/* Modal de captura de foto */
.captura-modal-photo-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.captura-modal-photo-preview {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: #000000;
}

.captura-modal-gps-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-label);
  color: var(--color-info);
  background: var(--color-info-bg);
  padding: var(--space-xxs) var(--space-sm);
  border-radius: var(--radius-sm);
}

/* Modal de cola offline */
.captura-queue-modal-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 340px;
  overflow-y: auto;
}

.captura-queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface-alt);
}

.captura-queue-item-failed {
  border-color: var(--color-error);
  background: var(--color-error-bg);
}

/* Interruptor demo offline */
.captura-demo-offline-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-label);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
