/* ==========================================================================
   Semillero Aeronáutico de Formación Inicial (SAFI) - Design System & Styles
   Aero Futuristic Theme with Responsive Glassmorphism & High Contrast Controls
   ========================================================================== */

:root {
  /* Color Palette - Premium Gold, Crimson & Obsidian Theme */
  --primary-glow: #f5d77f;
  --primary-gold: #d4af37;
  --primary-accent: #e5c158;
  --primary-red: #8b0000;
  --primary-red-glow: #a81a24;
  --bg-dark: #0a0608;
  --bg-card: rgba(18, 11, 14, 0.93);
  --bg-card-hover: rgba(26, 16, 20, 0.98);
  --border-color: rgba(212, 175, 55, 0.35);
  --border-focus: rgba(245, 215, 127, 0.85);
  
  --text-main: #f8fafc;
  --text-muted: #a3a3a3;
  --text-label: #e2e8f0;

  --input-bg: rgba(22, 14, 16, 0.88);
  --input-border: rgba(212, 175, 55, 0.25);
  --input-border-hover: rgba(245, 215, 127, 0.55);

  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;

  /* Typography */
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Radii & Shadows */
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-glow: 0 0 35px rgba(212, 175, 55, 0.18);
  --shadow-card: 0 20px 50px rgba(0, 0, 0, 0.8);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow-x: hidden;
  padding: 2rem 1rem;
}

/* Background Animated Graphics */
.bg-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(139, 0, 0, 0.22) 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(212, 175, 55, 0.18) 0%, transparent 45%),
    linear-gradient(to right, rgba(212, 175, 55, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(212, 175, 55, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
  z-index: -2;
}

.bg-orbs {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.45;
  animation: floatOrb 12s infinite alternate ease-in-out;
}

.orb-1 {
  width: 350px;
  height: 350px;
  background: var(--primary-red);
  top: -50px;
  right: -50px;
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: var(--primary-gold);
  bottom: -100px;
  left: -100px;
  animation-delay: -6s;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, 40px) scale(1.1); }
}

/* Main Container */
.container {
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  z-index: 1;
}

/* Card Styling */
.safi-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  padding: 2.5rem 2.25rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  width: 100%;
}

.safi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background: linear-gradient(90deg, var(--primary-red), var(--primary-gold), var(--primary-glow), var(--primary-red));
}

/* Header & Logo */
.header-section {
  text-align: center;
  margin-bottom: 2rem;
}

.logo-wrapper {
  margin: 0 auto 1.25rem;
  max-width: 240px;
  display: flex;
  justify-content: center;
  align-items: center;
  filter: drop-shadow(0 0 20px rgba(212, 175, 55, 0.4));
  transition: var(--transition);
}

.logo-wrapper:hover {
  transform: scale(1.03);
  filter: drop-shadow(0 0 30px rgba(245, 215, 127, 0.65));
}

.logo-img {
  width: 100%;
  height: auto;
  object-fit: contain;
  max-height: 110px;
}

.header-title {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-main);
  margin-bottom: 0.4rem;
  background: linear-gradient(135deg, #ffffff 30%, #f5d77f 70%, #d4af37 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--primary-glow);
  background: rgba(139, 0, 0, 0.25);
  border: 1px solid rgba(212, 175, 55, 0.35);
  padding: 0.3rem 0.8rem;
  border-radius: 50px;
  margin-top: 0.25rem;
}

.header-description {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.75rem;
  line-height: 1.5;
}

/* Form Grid & Inputs */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  width: 100%;
}

.form-group {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-label);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

label i {
  color: var(--primary-glow);
  font-size: 0.9rem;
}

/* Inputs, Selects Styling */
.input-wrapper {
  position: relative;
  width: 100%;
}

input, select {
  width: 100%;
  padding: 0.85rem 1rem;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

/* 3-Dropdown Date Selector Grid */
.date-picker-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1.2fr;
  gap: 0.6rem;
  width: 100%;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.field-hint i {
  color: var(--primary-glow);
}

select {
  cursor: pointer;
  padding-right: 2.2rem;
}

.select-arrow {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary-glow);
  pointer-events: none;
  font-size: 0.8rem;
}

input:hover, select:hover {
  border-color: var(--input-border-hover);
  background-color: rgba(28, 18, 22, 0.95);
}

input:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.25);
  background-color: rgba(20, 12, 15, 0.98);
}

input::placeholder {
  color: rgba(163, 163, 163, 0.5);
}

option {
  background-color: #120b0e;
  color: var(--text-main);
  padding: 10px;
}

/* Age Badge */
.age-badge {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  width: fit-content;
}

.age-badge.adult {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.age-badge.minor {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.age-badge.invalid {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Section Dividers */
.section-divider {
  margin: 1.5rem 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
}

.section-divider i {
  font-size: 1.25rem;
  color: var(--primary-accent);
}

.section-divider h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary-glow);
  letter-spacing: -0.2px;
}

/* Acudiente Container */
.acudiente-section {
  background: rgba(139, 0, 0, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1.25rem;
  width: 100%;
  box-sizing: border-box;
}

/* Phone Group Custom styling */
.phone-group {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.phone-code {
  width: 35%;
  min-width: 110px;
}

.phone-number {
  width: 65%;
  flex-grow: 1;
}

/* ==========================================================================
   TERMS & CONDITIONS (TyC) COMPREHENSIVE PREVIEW BOX
   ========================================================================== */

.tyc-section {
  margin-top: 1.75rem;
  width: 100%;
  box-sizing: border-box;
}

.tyc-preview-box {
  background: #080406;
  border: 1.5px solid rgba(212, 175, 55, 0.35);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #cbd5e1;
  margin-bottom: 0.85rem;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.8);
  width: 100%;
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-x: hidden;
}

.tyc-preview-box::-webkit-scrollbar {
  width: 7px;
}
.tyc-preview-box::-webkit-scrollbar-track {
  background: rgba(18, 11, 14, 0.8);
  border-radius: 10px;
}
.tyc-preview-box::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--primary-red), var(--primary-gold));
  border-radius: 10px;
}

.tyc-header {
  color: var(--primary-glow);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-bottom: 0.8rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.25);
  padding-bottom: 0.5rem;
  text-align: center;
}

.tyc-preview-box p {
  margin-bottom: 0.75rem;
}

.tyc-preview-box strong {
  color: var(--primary-glow);
}

.tyc-external-link {
  margin-bottom: 1.5rem;
  width: 100%;
}

.tyc-external-link a {
  color: var(--primary-glow) !important;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(139, 0, 0, 0.25);
  border: 1.5px solid rgba(212, 175, 55, 0.4);
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  transition: var(--transition);
  width: 100%;
  box-sizing: border-box;
}

.tyc-external-link a:hover {
  color: #ffffff !important;
  background: rgba(168, 26, 36, 0.45);
  border-color: var(--primary-glow);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.35);
}

/* ==========================================================================
   SIGNATURE CANVAS PAD STYLING (Responsive Canvas)
   ========================================================================== */

.signature-container {
  margin-bottom: 1.5rem;
  width: 100%;
  box-sizing: border-box;
}

.signature-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.canvas-wrapper {
  position: relative;
  background-color: #060304;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.85);
  width: 100%;
  height: 160px;
  box-sizing: border-box;
}

.canvas-wrapper:hover, .canvas-wrapper.is-drawing {
  border-color: var(--primary-glow);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.3), inset 0 0 15px rgba(0, 0, 0, 0.85);
}

canvas#signature-pad {
  width: 100% !important;
  height: 160px !important;
  display: block;
  background-color: #060304;
  border-radius: var(--radius-md);
  cursor: crosshair;
  touch-action: none; /* Prevents mobile scrolling */
  box-sizing: border-box;
}

.canvas-placeholder-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(163, 163, 163, 0.5);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: opacity 0.2s ease;
  white-space: nowrap;
}

.canvas-placeholder-hint.hidden {
  opacity: 0;
}

.signature-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.clear-sig-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1.5px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 0.82rem;
  font-family: var(--font-family);
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition);
}

.clear-sig-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ffffff;
  border-color: var(--error-color);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

/* ==========================================================================
   CHECKBOX ACCEPTANCE TYC STYLING
   ========================================================================== */

.checkbox-wrapper {
  background: rgba(22, 14, 16, 0.88);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  width: 100%;
  box-sizing: border-box;
}

.checkbox-wrapper:hover {
  border-color: var(--border-focus);
  background: rgba(28, 18, 22, 0.95);
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.5;
  margin-bottom: 0;
  width: 100%;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary-gold);
  cursor: pointer;
  margin-top: 2px;
  flex-shrink: 0;
  border-radius: 4px;
}

.checkbox-label strong {
  color: var(--primary-glow);
}

/* Validation Messages */
.error-msg {
  font-size: 0.8rem;
  color: var(--error-color);
  margin-top: 0.35rem;
  display: none;
  font-weight: 500;
}

.form-group.has-error input,
.form-group.has-error select,
.date-picker-grid.has-error select,
.signature-container.has-error .canvas-wrapper,
.checkbox-wrapper.has-error {
  border-color: var(--error-color) !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3) !important;
}

.date-picker-grid.has-error select {
  border-color: var(--error-color) !important;
}

.form-group.has-error .error-msg,
.signature-container.has-error .error-msg,
.checkbox-wrapper.has-error + .error-msg {
  display: block;
}

/* Submit Button */
.submit-btn {
  margin-top: 1.75rem;
  width: 100%;
  padding: 1.05rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #8b0000 0%, #a81a24 40%, #d4af37 100%);
  color: #ffffff;
  font-family: var(--font-family);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(139, 0, 0, 0.5);
  transition: var(--transition);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  position: relative;
  overflow: hidden;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(212, 175, 55, 0.45);
  background: linear-gradient(135deg, #a81a24 0%, #b8860b 50%, #f5d77f 100%);
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Loading Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
  display: none;
}

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

/* Footer note */
.form-footer {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-footer i {
  color: var(--primary-glow);
}

/* ==========================================================================
   POP-UP MODAL STYLING
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(6, 3, 4, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 1rem;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: #120b0e;
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px rgba(212, 175, 55, 0.25);
  max-width: 480px;
  width: 100%;
  padding: 2.25rem;
  text-align: center;
  position: relative;
  transform: scale(0.85) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

.modal-icon-wrapper {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.25rem;
  background: rgba(16, 185, 129, 0.15);
  border: 2px solid var(--success-color);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--success-color);
  font-size: 2.5rem;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
  animation: pulseIcon 2s infinite ease-in-out;
}

@keyframes pulseIcon {
  0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(16, 185, 129, 0.3); }
  50% { transform: scale(1.05); box-shadow: 0 0 35px rgba(16, 185, 129, 0.5); }
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.modal-subtitle {
  color: var(--primary-glow);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.modal-body {
  background: rgba(22, 14, 16, 0.85);
  border-radius: var(--radius-md);
  padding: 1rem;
  border: 1px dashed rgba(212, 175, 55, 0.25);
  margin-bottom: 1.5rem;
  text-align: left;
  font-size: 0.88rem;
  color: var(--text-label);
  line-height: 1.6;
}

.modal-body p {
  margin-bottom: 0.4rem;
}

.modal-body strong {
  color: var(--text-main);
}

.modal-alert {
  background: rgba(139, 0, 0, 0.2);
  border-left: 3px solid var(--primary-gold);
  padding: 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.85rem;
  color: #e2e8f0;
  margin-top: 0.75rem;
}

.modal-close-btn {
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
  transition: var(--transition);
}

.modal-close-btn:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 12px 25px rgba(16, 185, 129, 0.4);
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  body {
    padding: 1rem 0.5rem;
  }

  .safi-card {
    padding: 1.75rem 1.25rem;
    border-radius: 16px;
  }

  .header-title {
    font-size: 1.35rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .date-picker-grid {
    grid-template-columns: 1fr 1.3fr 1.2fr;
  }

  .phone-group {
    flex-direction: row;
  }
  
  .phone-code {
    width: 40%;
    min-width: 95px;
  }

  canvas#signature-pad {
    height: 140px !important;
  }
}
