/*
 * Functional-neutral PWA fixes.
 *
 * This layer intentionally does not own global typography, cards, navigation,
 * page spacing or theme tokens. Those belong to pwa-base-v153.css and the
 * approved v1.5.3 page modules loaded before this file.
 */

/* iOS can apply dark native paint to controls inside a light PWA. Keep entered
 * text, dates, times and placeholders readable without changing page layout. */
body .auth-view .field input:not([type="checkbox"]):not([type="radio"]),
body .auth-view .field select,
body .auth-view .field textarea,
body .app-view .field input:not([type="checkbox"]):not([type="radio"]),
body .app-view .field select,
body .app-view .field textarea,
body .app-view .coord-grid input,
body .app-view .search-field input,
body .app-view .filter-grid input,
body .app-view .filter-grid select,
body .app-view .work-field textarea,
body .app-view #work-content,
.v15-modal-card .v15-field input,
.v15-modal-card .v15-field select,
.v15-modal-card .v15-field textarea,
.pwa-secondary-layer input,
.pwa-secondary-layer select,
.pwa-secondary-layer textarea {
  border-color: #7d8c9c !important;
  background-color: #fffdf9 !important;
  color: #0d315c !important;
  -webkit-text-fill-color: #0d315c !important;
  caret-color: #0d315c;
  color-scheme: light !important;
  opacity: 1;
}

body .auth-view input::placeholder,
body .auth-view textarea::placeholder,
body .app-view input::placeholder,
body .app-view textarea::placeholder,
.v15-modal-card input::placeholder,
.v15-modal-card textarea::placeholder,
.pwa-secondary-layer input::placeholder,
.pwa-secondary-layer textarea::placeholder {
  color: #607286 !important;
  -webkit-text-fill-color: #607286 !important;
  opacity: 1 !important;
}

body .app-view input[type="date"],
body .app-view input[type="month"],
body .app-view input[type="time"],
.v15-modal-card input[type="date"],
.v15-modal-card input[type="month"],
.v15-modal-card input[type="time"],
.pwa-secondary-layer input[type="date"],
.pwa-secondary-layer input[type="month"],
.pwa-secondary-layer input[type="time"] {
  color-scheme: light !important;
  font-variant-numeric: tabular-nums;
}

body .app-view input[type="date"]::-webkit-date-and-time-value,
body .app-view input[type="month"]::-webkit-date-and-time-value,
body .app-view input[type="time"]::-webkit-date-and-time-value,
.v15-modal-card input[type="date"]::-webkit-date-and-time-value,
.v15-modal-card input[type="month"]::-webkit-date-and-time-value,
.v15-modal-card input[type="time"]::-webkit-date-and-time-value {
  color: #0d315c !important;
  -webkit-text-fill-color: #0d315c !important;
  opacity: 1;
}

body .app-view .field input:disabled,
body .app-view .field select:disabled,
body .app-view .field textarea:disabled {
  background-color: #f2efe9 !important;
  color: #53677c !important;
  -webkit-text-fill-color: #53677c !important;
  opacity: 1;
}

/* Work-content and holiday confirmations must be fully opaque. This prevents
 * the punch screen from bleeding through during iOS sheet composition. */
.app-view .sheet:not([hidden]) {
  z-index: 1200;
  padding-bottom: max(16px, calc(env(safe-area-inset-bottom) + 12px));
}

.pwa-secondary-layer:not([hidden]) { z-index: 1100; }
.pwa-confirm-layer:not([hidden]),
.v15-modal:not([hidden]) { z-index: 1300; }

.app-view .work-sheet-card,
.app-view .work-sheet-card .sheet-actions,
.app-view #holiday-punch-sheet .holiday-punch-card {
  background-color: #fffdf9;
  background-image: none;
  color: #0d315c;
  opacity: 1;
  animation: none;
  color-scheme: light;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.app-view #holiday-punch-sheet {
  background: rgb(17 35 49 / 66%);
  isolation: isolate;
}

.app-view #holiday-punch-sheet .holiday-punch-summary,
.app-view .work-preview {
  background-color: #f5f1e9;
  background-image: none;
  color: #0d315c;
  opacity: 1;
}

/* Foreman site edit/delete controls are operational UI injected at runtime. */
.site-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.site-card-actions button {
  min-height: 44px;
  border: 1px solid var(--pwa-border, #dedbd5);
  border-radius: 11px;
  background: #f5f1e9;
  color: var(--pwa-navy, #0d315c);
  font-weight: 800;
}

.site-card-actions button[data-site-delete] {
  border-color: #e4bdb7;
  background: #fff5f2;
  color: #9e3e37;
}

/* Large runtime lists remain cheap to paint without altering their content. */
.app-view .stack-list > .list-card,
.app-view .history-content > .timeline-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 110px;
}

/* Hidden panels never remain as transparent hit targets. */
.app-view .tab-panel[hidden],
.pwa-confirm-layer[hidden],
.app-view .sheet[hidden],
.v15-modal[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .app-view *,
  .app-view *::before,
  .app-view *::after,
  .pwa-secondary-layer *,
  .pwa-secondary-layer *::before,
  .pwa-secondary-layer *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
