/* Grupo Imar — Formulario operario (mobile-first).
   Sin frameworks, target táctil ≥ 44×44 px (P9). */

* { box-sizing: border-box; }

:root {
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-text: #1a1d24;
  --color-text-soft: #5b6371;
  --color-border: #d4d7dd;
  --color-primary: #1565c0;
  --color-primary-dark: #0d47a1;
  --color-success: #2e7d32;
  --color-danger: #c62828;
  --color-warning: #ef6c00;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

header h1 {
  font-size: 1.4rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

header .subtitle {
  font-size: 0.85rem;
  color: var(--color-text-soft);
}

/* === Card === */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* === Form === */
.field {
  margin-bottom: 1.25rem;
}

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

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

label .required {
  color: var(--color-danger);
  margin-left: 0.15rem;
}

label .hint {
  display: block;
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--color-text-soft);
  margin-top: 0.15rem;
}

select,
textarea,
input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 17px;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path fill='%23555' d='M0 0h10L5 6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 0.7rem;
  padding-right: 2.2rem;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

select:focus,
textarea:focus,
input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
  border-color: var(--color-primary);
}

/* === Toggle Sí/No (botón grande) === */
.toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.toggle button {
  appearance: none;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  padding: 0.85rem 1rem;
  min-height: 56px;
  cursor: pointer;
  color: var(--color-text);
  transition: all 0.12s ease;
}

.toggle button:hover {
  border-color: var(--color-primary);
}

.toggle button[aria-pressed="true"] {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary-dark);
  box-shadow: var(--shadow);
}

.toggle button[data-value="Sí"][aria-pressed="true"] {
  background: var(--color-warning);
  border-color: #b34c00;
}

/* === Botón principal === */
button.primary {
  appearance: none;
  width: 100%;
  background: var(--color-primary);
  color: #fff;
  border: 0;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
  padding: 1rem 1.25rem;
  min-height: 56px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.12s ease;
}

button.primary:hover { background: var(--color-primary-dark); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled {
  background: var(--color-border);
  color: var(--color-text-soft);
  cursor: not-allowed;
  box-shadow: none;
}

button.secondary {
  appearance: none;
  width: 100%;
  background: #fff;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.8rem 1.1rem;
  min-height: 48px;
  cursor: pointer;
  font-family: inherit;
  margin-top: 0.6rem;
}

button.secondary:hover { background: #e3f2fd; }

/* === Estado: cargando, error, éxito === */
.status {
  text-align: center;
  padding: 2rem 1rem;
}

.status .icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.status h2 {
  margin: 0 0 0.5rem;
  font-size: 1.3rem;
  font-weight: 700;
}

.status p {
  margin: 0.25rem 0;
  color: var(--color-text-soft);
}

.status .codigo {
  display: inline-block;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--color-bg);
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  margin: 0.6rem 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
}

.status.success .icon { color: var(--color-success); }
.status.error .icon { color: var(--color-danger); }

.status .actions { margin-top: 1.5rem; }

/* === Banner de error inline === */
.error-banner {
  background: #ffebee;
  color: #b71c1c;
  border-left: 4px solid var(--color-danger);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

/* === Skeleton loader (mientras carga catálogos) === */
.skeleton {
  display: block;
  background: linear-gradient(90deg, #e8eaee, #f4f5f7, #e8eaee);
  background-size: 200% 100%;
  animation: pulse 1.4s ease-in-out infinite;
  border-radius: 6px;
  height: 1.1rem;
  margin: 0.6rem 0;
}
.skeleton.lg { height: 2.5rem; }

@keyframes pulse {
  0% { background-position: 0% 50%; }
  100% { background-position: -200% 50%; }
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}

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

/* Footer pequeño */
footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--color-text-soft);
  margin-top: 2rem;
}

/* Hidden helper */
.hidden { display: none !important; }
