/* ============================================================
   PCP OIL SERVICES — FIELD OPERATIONS
   Estilos principales — Etapa 1
   ============================================================ */

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-card-hover: #1c1c1c;
  --bg-input: #1a1a1a;
  --gold: #e8a00a;
  --gold-dim: #b87d05;
  --gold-bright: #ffb820;
  --text: #f0f0f0;
  --text-dim: #888888;
  --text-muted: #555555;
  --border: #2a2a2a;
  --border-gold: #3a2e0a;
  --success: #2ecc71;
  --error: #e74c3c;
  --warning: #f39c12;
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 80px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
textarea,
select {
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

/* ---------- App Layout ---------- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Header ---------- */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding: calc(8px + var(--safe-top)) 16px 8px;
  border-bottom: 2px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--header-h);
}

#app-logo {
  max-width: 100%;
  max-height: 64px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* ---------- Main ---------- */
#app-main {
  flex: 1;
  padding: 20px 16px;
  padding-bottom: calc(var(--nav-h) + 24px + var(--safe-bottom));
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Bottom Navigation ---------- */
#app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  background: #0d0d0d;
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  max-width: 600px;
  margin: 0 auto;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 4px;
  min-height: var(--nav-h);
  color: var(--text-dim);
  transition: color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-item:active {
  background: #1a1a1a;
}

.nav-item.active {
  color: var(--gold);
}

.nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.nav-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ---------- Screen ---------- */
.screen {
  display: none;
  animation: fadeIn 0.25s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Typography ---------- */
.screen-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.screen-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 12px;
  padding-left: 4px;
}

/* ---------- Home Hero ---------- */
.home-hero {
  text-align: center;
  padding: 20px 0 28px;
}

.home-hero h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.02em;
}

.home-hero .tagline {
  font-size: 0.85rem;
  color: var(--gold);
  font-style: italic;
  margin-top: 6px;
}

/* ---------- Online Indicator ---------- */
.online-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 auto 24px;
  width: fit-content;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all 0.3s;
}

.online-indicator.online {
  border-color: var(--success);
  color: var(--success);
}

.online-indicator.offline {
  border-color: var(--error);
  color: var(--error);
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---------- Cards Grid ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 10px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.stat-card:active {
  background: var(--bg-card-hover);
  border-color: var(--gold-dim);
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.62rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 8px;
  line-height: 1.2;
}

/* ---------- Big Button ---------- */
.btn-big {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--gold);
  color: #0a0a0a;
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn-big:active {
  background: var(--gold-bright);
  transform: scale(0.98);
}

/* ---------- GPS Module ---------- */
.gps-section {
  margin-top: 28px;
}

.gps-coords {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.gps-coord-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.gps-coord-row:last-child {
  border-bottom: none;
}

.gps-coord-row .coord-key {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gps-coord-row .coord-val {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.gps-coord-row .coord-val.touchable {
  color: var(--gold);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.gps-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.gps-timestamp {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 10px;
}

.btn-gps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn-gps:active {
  background: var(--border-gold);
  transform: scale(0.98);
}

.btn-gps.secondary {
  border-color: var(--border);
  color: var(--text);
  margin-top: 8px;
}

.btn-gps.secondary:active {
  background: var(--bg-card-hover);
}

.gps-error {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid var(--error);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 0.82rem;
  color: var(--error);
  text-align: center;
}

.gps-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  color: var(--gold);
  font-size: 0.82rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Placeholder Screen ---------- */
.placeholder {
  text-align: center;
  padding: 60px 20px;
}

.placeholder .placeholder-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.placeholder h2 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 8px;
}

.placeholder p {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ---------- Sync Screen ---------- */
.sync-info {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 16px;
  margin-bottom: 16px;
}

.sync-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.sync-row:last-child {
  border-bottom: none;
}

.sync-row .sync-key {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.sync-row .sync-val {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.sync-row .sync-val.online { color: var(--success); }
.sync-row .sync-val.offline { color: var(--error); }

/* ---------- Settings ---------- */
.settings-section {
  margin-bottom: 28px;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row .row-label {
  font-size: 0.88rem;
  color: var(--text);
  flex: 1;
}

.settings-row .row-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.settings-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.85rem;
  width: 100%;
  margin-top: 4px;
}

.settings-input:focus {
  outline: none;
  border-color: var(--gold-dim);
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #333;
  border-radius: 14px;
  transition: background 0.3s;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #777;
  top: 3px;
  left: 3px;
  transition: transform 0.3s, background 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: var(--gold-dim);
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(20px);
  background: var(--gold);
}

/* Logo upload */
.logo-upload-area {
  padding: 16px;
  text-align: center;
}

.logo-preview {
  max-width: 100%;
  max-height: 80px;
  object-fit: contain;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
}

.logo-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.2s;
}

.logo-upload-btn:active {
  background: var(--border-gold);
}

.logo-upload-btn input {
  display: none;
}

/* Info section */
.info-row {
  text-align: center;
  padding: 20px 16px;
}

.info-row .app-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
}

.info-row .app-version {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Danger zone */
.btn-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--error);
  color: var(--error);
  background: rgba(231, 76, 60, 0.05);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: background 0.2s, transform 0.1s;
}

.btn-danger:active {
  background: rgba(231, 76, 60, 0.15);
  transform: scale(0.98);
}

/* ---------- Confirm Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.modal h3 {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 8px;
}

.modal p {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
}

.modal-buttons button {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  transition: background 0.2s;
}

.btn-cancel {
  background: #2a2a2a;
  color: var(--text);
}

.btn-cancel:active {
  background: #333;
}

.btn-confirm {
  background: var(--error);
  color: #fff;
}

.btn-confirm:active {
  background: #c0392b;
}

/* ---------- Responsive ---------- */
@media (min-width: 768px) {
  #app-main {
    padding-top: 28px;
  }
  .home-hero h1 {
    font-size: 1.7rem;
  }
  .nav-label {
    font-size: 0.68rem;
  }
}

@media (min-width: 1024px) {
  #app-nav {
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius) var(--radius) 0 0;
  }
}

/* ---------- Report Form ---------- */
.report-form {
  padding-bottom: 20px;
}

.report-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.report-number-badge {
  background: var(--border-gold);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.report-status-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
}

/* Unit toggle */
.unit-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}

.unit-toggle-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 600;
}

.unit-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.unit-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  transition: background 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.unit-btn.active {
  background: var(--gold);
  color: #0a0a0a;
}

/* Autosave indicator */
.autosave-indicator {
  font-size: 0.72rem;
  color: var(--success);
  text-align: right;
  min-height: 1em;
  opacity: 0;
  transition: opacity 0.3s;
  margin-bottom: 4px;
}

.autosave-indicator.visible {
  opacity: 1;
}

/* Form sections */
.form-section {
  margin-bottom: 24px;
}

.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* Form fields */
.form-field {
  margin-bottom: 16px;
}

.form-field:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 14px 12px;
  font-size: 1rem;
  min-height: 48px;
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--gold-dim);
}

.form-input.readonly {
  color: var(--gold);
  font-weight: 700;
  background: #111;
  cursor: default;
}

.form-input::placeholder {
  color: var(--text-muted);
}

/* Input with unit suffix */
.input-with-unit {
  display: flex;
  align-items: stretch;
}

.input-with-unit .form-input {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  flex: 1;
}

.unit-suffix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--border-gold);
  border: 1px solid var(--gold-dim);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  min-height: 48px;
}

/* Form errors */
.form-field.has-error .form-input {
  border-color: var(--error);
}

.form-error {
  font-size: 0.75rem;
  color: var(--error);
  margin-top: 4px;
  min-height: 1em;
}

/* Slider */
.slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-slider {
  flex: 1;
  height: 48px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  outline: none;
}

.form-slider::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
}

.form-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  margin-top: -11px;
  cursor: pointer;
}

.form-slider::-moz-range-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
}

.form-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
}

.slider-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gold);
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Status selector */
.status-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-btn {
  flex: 1;
  min-height: 48px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.status-btn.status-normal.active {
  border-color: var(--success);
  background: rgba(46, 204, 113, 0.15);
  color: var(--success);
}

.status-btn.status-alerta.active {
  border-color: var(--warning);
  background: rgba(243, 156, 18, 0.15);
  color: var(--warning);
}

.status-btn.status-critico.active {
  border-color: var(--error);
  background: rgba(231, 76, 60, 0.15);
  color: var(--error);
}

/* GPS in form */
.gps-form-card .gps-coords {
  margin-bottom: 12px;
}

/* Form actions */
.form-actions {
  margin-top: 24px;
}

/* Draft recovery */
.draft-recovery {
  text-align: center;
  padding: 60px 20px;
}

.draft-recovery .draft-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.draft-recovery h2 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 8px;
}

.draft-recovery .draft-info {
  font-size: 0.9rem;
  color: var(--gold);
  margin-bottom: 28px;
}

.draft-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Intervention placeholder */
.intervention-placeholder .intervention-report-ref {
  font-size: 0.85rem;
  color: var(--gold);
  margin-top: 12px;
}

/* Form toast */
.form-toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  max-width: 90%;
  text-align: center;
}

.form-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
