/* General Design System & Tokens */
:root {
  --primary: #1e3a8a;       /* Deep Navy */
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --accent: #2563eb;        /* Royal Blue */
  --success: #10b981;       /* Emerald */
  --success-hover: #059669;
  --danger: #ef4444;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --bg-main: #0f172a;       /* Sleek dark background for modern contrast */
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-input: #1e293b;
  --border-color: #334155;
  --font-sans: 'Inter', 'Noto Sans KR', sans-serif;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: #f8fafc;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  padding: 40px 20px;
  line-height: 1.6;
}

/* Background Decorative Glows */
.bg-glow-1 {
  position: absolute;
  top: -10%;
  left: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.15) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}

.bg-glow-2 {
  position: absolute;
  bottom: -10%;
  right: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.1) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}

/* App Container */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Header */
.app-header {
  text-align: center;
  margin-bottom: 40px;
}

.logo-area {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 16px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
  backdrop-filter: blur(10px);
}

.logo-icon {
  font-size: 1.2rem;
  color: var(--accent);
}

.logo-text {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #94a3b8;
}

.main-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: #94a3b8;
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* Main Grid Layout */
.main-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 30px;
  align-items: start;
}

/* Cards & Containers */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 35px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 20px;
  margin-bottom: 25px;
}

.card-header h2 {
  font-size: 1.4rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f1f5f9;
}

.card-header h2 i {
  color: var(--accent);
}

.required-notice {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-group-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 30px;
  margin-bottom: 15px;
  color: #f1f5f9;
  border-left: 4px solid var(--accent);
  padding-left: 10px;
}

/* Form Styling */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-field.full-width {
  grid-column: 1 / -1;
  margin-top: 5px;
}

label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #cbd5e1;
}

label .required {
  color: var(--danger);
  margin-left: 2px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
  transition: var(--transition);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"] {
  width: 100%;
  padding: 14px 16px 14px 44px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #f8fafc;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: var(--transition);
}

/* Date Input Specifics */
input[type="date"] {
  position: relative;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  background: transparent;
  bottom: 0;
  color: transparent;
  cursor: pointer;
  height: auto;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  width: auto;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
  background-color: rgba(30, 41, 59, 0.9);
}

input:focus + .input-icon {
  color: var(--accent);
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Signature Pad Design */
.signature-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.signature-pad-container {
  position: relative;
  width: 100%;
  height: 200px;
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: var(--transition);
}

.signature-pad-container:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

#signature-canvas {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#btn-clear-sig {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 10;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-primary {
  background-color: var(--accent);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.15);
  color: white;
}

.btn-block {
  width: 100%;
  padding: 16px;
  font-size: 1.05rem;
}

/* Privacy Policy Box */
.card-sub {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.pledge-summary p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #cbd5e1;
  margin-bottom: 12px;
  word-break: keep-all;
}

.pledge-summary p:last-child {
  margin-bottom: 0;
}

.privacy-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 15px;
  font-size: 0.85rem;
}

.privacy-table th,
.privacy-table td {
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.privacy-table th {
  background: rgba(255, 255, 255, 0.03);
  color: #cbd5e1;
  font-weight: 600;
  width: 120px;
}

.privacy-table td {
  color: #94a3b8;
}

.privacy-info-text {
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.5;
}

/* Consent Selection Box */
.consent-box {
  margin-bottom: 30px;
  padding: 15px;
  background: rgba(37, 99, 235, 0.05);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: var(--radius-sm);
}

.consent-question {
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: #f1f5f9;
}

.radio-group {
  display: flex;
  gap: 25px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  color: #cbd5e1;
  user-select: none;
}

.radio-label input[type="radio"] {
  display: none;
}

.radio-custom {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  position: relative;
  transition: var(--transition);
}

.radio-label input[type="radio"]:checked + .radio-custom {
  border-color: var(--accent);
}

.radio-custom::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
  transform: translate(-50%, -50%) scale(1);
}

/* Form Validation Errors styling */
.input-field.error input {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.input-field.error label {
  color: var(--danger);
}

.error-message {
  color: #f87171;
  font-size: 0.8rem;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Right Column - A4 Sheet Live Preview */
.preview-section {
  display: flex;
  flex-direction: column;
}

.preview-sticky-wrapper {
  position: sticky;
  top: 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.preview-header {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 20px;
  border-radius: var(--radius-sm);
}

.preview-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.preview-header h3 i {
  color: #f87171; /* PDF red */
}

.preview-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* A4 Sheet Container & Responsive Scaling Wrapper */
.a4-sheet-container {
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}

/* Real A4 Paper dimensions at 96 DPI: 794px x 1123px */
.a4-sheet {
  width: 794px;
  height: 1120px;
  min-width: 794px;
  min-height: 1120px;
  background: #ffffff;
  color: #1a1a1a;
  padding: 40px 50px 30px 50px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  transform-origin: top left;
  font-family: 'Noto Sans KR', sans-serif;
  line-height: 1.5;
}

/* PDF Document Header */
.doc-header {
  text-align: center;
  margin-bottom: 20px;
  border-bottom: 2px solid #111;
  padding-bottom: 8px;
}

.doc-subtitle {
  font-size: 13px;
  font-weight: 500;
  color: #444;
  margin-bottom: 4px;
}

.doc-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 6px;
  margin-bottom: 4px;
  color: #000;
}

.doc-subtext {
  font-size: 12px;
  font-weight: 500;
  color: #444;
}

/* PDF Sections */
.doc-section-title {
  font-size: 12px;
  font-weight: 700;
  background: #1e3a8a;
  color: #ffffff;
  padding: 3px 8px;
  margin-top: 12px;
  margin-bottom: 8px;
  border-radius: 2px;
  width: 100%;
}

/* Document Tables */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}

.doc-table td {
  border: 1px solid #111;
  padding: 6px 10px;
  font-size: 13px;
}

.doc-label {
  background-color: #f1f5f9;
  font-weight: 700;
  width: 180px;
  text-align: center;
}

.doc-value {
  color: #000;
  background-color: #fff;
  font-weight: 500;
}

/* Pledge text block */
.doc-pledge-text {
  font-size: 12px;
  line-height: 1.6;
  color: #222;
  margin-bottom: 10px;
  text-align: justify;
  word-break: keep-all;
}

/* Privacy document sub table */
.privacy-doc-table .doc-label {
  background-color: #fee2e2; /* Reddish tone for notice */
  color: #991b1b;
}

.doc-fineprint {
  font-size: 11px;
  color: #333;
  line-height: 1.5;
  margin-bottom: 10px;
}

.doc-consent-display {
  font-size: 12px;
  font-weight: 700;
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.checkbox-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.box-indicator {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid #111;
  position: relative;
  background-color: #fff;
}

.box-indicator.checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  font-size: 12px;
  font-weight: bold;
  color: #1e3a8a;
}

/* Signature block */
.doc-signature-area {
  margin-top: auto;
  border-top: 1px solid #111;
  padding-top: 15px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.doc-date {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  align-self: center;
  letter-spacing: 1px;
}

.doc-signee-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  align-items: center;
  padding: 0 40px;
}

.doc-signee-label {
  font-size: 14px;
  font-weight: 700;
}

.doc-signee-label span {
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.doc-signature-box {
  width: 200px;
  height: 70px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sig-label {
  font-size: 13px;
  color: #888;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1;
}

#preview-signature-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
}

.doc-footer {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  margin-top: 20px;
  letter-spacing: 2px;
  color: #1e3a8a;
}

/* Loading & Success Overlays */
.loading-overlay,
.success-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.loading-overlay.active,
.success-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loader-content {
  text-align: center;
  max-width: 450px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 5px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 25px;
  animation: spin 1s linear infinite;
}

.loader-content h3 {
  font-size: 1.5rem;
  margin-bottom: 12px;
  color: white;
}

.loader-content p {
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 25px;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #10b981 100%);
  transition: width 0.4s ease;
}

/* Success Card Overlay styling */
.success-content {
  max-width: 550px;
  width: 100%;
  text-align: center;
  background: var(--bg-card);
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.success-icon {
  font-size: 4rem;
  color: var(--success);
  margin-bottom: 20px;
}

.success-content h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 15px;
  color: white;
}

.success-message {
  color: #cbd5e1;
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 30px;
}

.highlight-email {
  color: var(--accent);
  text-decoration: underline;
  background: rgba(37, 99, 235, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

.success-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 25px;
}

.success-notice {
  font-size: 0.8rem;
  color: #94a3b8;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

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

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

.animate-bounce {
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(-10px);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

/* Responsive Layout */
@media (max-width: 1200px) {
  .main-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }
  
  .preview-sticky-wrapper {
    position: static;
  }
  
  .a4-sheet-container {
    justify-content: center; /* Center A4 preview on tablet/mobile */
  }
}

@media (max-width: 768px) {
  body {
    padding: 20px 10px;
  }
  
  .card {
    padding: 20px;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .main-title {
    font-size: 2rem;
  }
  
  .success-actions {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
  }
}
