/* ═══════════════════════════════════════════════════
   FORMULARIO DE CAMPO — PUST
   Mobile-first dark theme 
   ═══════════════════════════════════════════════════ */

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-alt: #222633;
  --bg-input: #272b3a;
  --border: #2e3345;
  --border-focus: #4f8cff;
  --text: #e8eaf0;
  --text-dim: #8b90a0;
  --text-hint: #6b7085;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.12);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.1);
  --orange: #fb923c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 100px;
  min-height: 100dvh;
}

/* ── HEADER ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.save-indicator {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--green);
  background: var(--green-soft);
  padding: 4px 12px;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.3s;
}

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

/* ── FORM CONTAINER ── */
.form-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── META SECTION ── */
.meta-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── INPUT STYLES ── */
.input-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 100px;
}

.input-group.full {
  flex-basis: 100%;
  margin-bottom: 4px;
}

.input-group label,
.field-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 12px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

::placeholder {
  color: var(--text-hint);
  opacity: 0.7;
}

/* ── ACCORDION ── */
.accordion-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.accordion-section.open {
  box-shadow: var(--shadow);
}

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.accordion-header:active {
  background: var(--accent-soft);
}

.accordion-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.accordion-title {
  flex: 1;
}

.accordion-arrow {
  font-size: 0.7rem;
  color: var(--text-dim);
  transition: transform 0.25s ease;
}

.accordion-section.open .accordion-arrow {
  transform: rotate(180deg);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
  padding: 0 20px;
}

.accordion-section.open .accordion-body {
  max-height: 8000px;
  padding: 0 20px 24px;
}

.section-hint {
  font-size: 0.78rem;
  color: var(--text-hint);
  font-style: italic;
  margin-bottom: 12px;
}

/* ── CHECKBOXES & RADIOS ── */
.checkbox-grid,
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.check-item,
.radio-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.check-item:active,
.radio-item:active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.check-item input,
.radio-item input {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.check-item span,
.radio-item span {
  font-size: 0.88rem;
  line-height: 1.3;
}

/* ── FIELD GROUP TITLES ── */
.field-group-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 16px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.sub-section-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--orange);
  margin-top: 24px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(251, 146, 60, 0.08);
  border-left: 3px solid var(--orange);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.field-label {
  margin-top: 8px;
  margin-bottom: 6px;
  font-weight: 500;
}

/* ── CASE BLOCKS ── */
.case-block {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.case-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.case-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}

.btn-remove-case {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--red-soft);
  color: var(--red);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.btn-remove-case:active {
  background: rgba(248, 113, 113, 0.25);
}

/* ── ADD CASE BUTTON ── */
.btn-add-case {
  width: 100%;
  padding: 14px;
  background: var(--accent-soft);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-add-case:active {
  background: rgba(79, 140, 255, 0.2);
}

/* ── FLOATING ACTIONS ── */
.floating-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(15, 17, 23, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  justify-content: center;
  max-width: 600px;
  margin: 0 auto;
}

.btn-action {
  flex: 1;
  max-width: 200px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn-action:active {
  transform: scale(0.96);
}

.btn-export {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  box-shadow: 0 4px 16px rgba(79, 140, 255, 0.3);
}

.btn-new {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

/* ── CONFIRM MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

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

.modal-box h3 {
  margin-bottom: 8px;
}

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

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

.modal-actions button {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.modal-cancel {
  background: var(--bg-input);
  color: var(--text-dim);
}

.modal-confirm {
  background: var(--red);
  color: white;
}

/* ── RESPONSIVE ── */
@media (max-width: 400px) {
  .input-row {
    flex-direction: column;
  }
  .form-container {
    padding: 10px;
  }
  .accordion-header {
    padding: 14px 16px;
  }
}
