/* ==========================================================================
   TJS Forms - Common Stylesheet (Mobile-First)
   ========================================================================== */

/* --- Design Tokens --- */
:root {
  --color-primary: #2C3E50;
  --color-accent: #3498DB;
  --color-accent-hover: #2980B9;
  --color-bg: #F8F9FA;
  --color-error: #E74C3C;
  --color-success: #27AE60;
  --color-white: #FFFFFF;
  --color-text: #333333;
  --color-text-light: #6C757D;
  --color-border: #DEE2E6;
  --color-border-focus: #3498DB;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --radius: 8px;
  --transition: 0.2s ease;
}

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

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

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Form Container --- */
.form-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 20px 40px;
  width: 100%;
}

/* --- Form Header --- */
.form-header {
  background-color: var(--color-primary);
  color: var(--color-white);
  padding: 24px 20px;
  text-align: center;
  width: 100%;
  margin-bottom: 24px;
}

.form-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.form-header p {
  font-size: 0.875rem;
  opacity: 0.85;
  margin-top: 4px;
}

/* --- Step Indicators --- */
.form-steps {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  padding: 0 16px;
}

.form-steps .step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--color-text-light);
}

.form-steps .step .step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-light);
  background-color: var(--color-white);
  transition: all var(--transition);
}

.form-steps .step.active .step-number {
  border-color: var(--color-accent);
  background-color: var(--color-accent);
  color: var(--color-white);
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.form-steps .step.completed .step-number {
  border-color: var(--color-success);
  background-color: var(--color-success);
  color: var(--color-white);
}

.form-steps .step .step-label {
  display: none;
}

.form-steps .step-connector {
  flex: 0 0 20px;
  height: 2px;
  background-color: var(--color-border);
}

.form-steps .step.completed + .step-connector,
.form-steps .step-connector.completed {
  background-color: var(--color-success);
}

/* --- Step Content --- */
.step-content {
  display: none;
}

.step-content.active {
  display: block;
}

/* --- Step Navigation --- */
.step-navigation {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.btn-next,
.btn-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 32px;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--transition), transform var(--transition);
}

.btn-next {
  background-color: var(--color-accent);
  color: var(--color-white);
  margin-left: auto;
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.25);
}

.btn-next:hover {
  background-color: var(--color-accent-hover);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-back {
  background-color: #E9ECEF;
  color: var(--color-text);
}

.btn-back:hover {
  background-color: #DEE2E6;
}

.btn-next:active,
.btn-back:active {
  transform: scale(0.98);
}

/* --- Field Group --- */
.field-group {
  margin-bottom: 20px;
}

.field-group label:not(.radio-label):not(.checkbox-label) {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 6px;
}

/* Required asterisk */
label.required::after {
  content: " *";
  color: var(--color-error);
}

/* --- Input / Select / Textarea --- */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-family: var(--font-family);
  font-size: 1rem;
  color: var(--color-text);
  background-color: var(--color-white);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

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

/* Select arrow */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236C757D' d='M6 8.825L0.375 3.2h11.25L6 8.825z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

::placeholder {
  color: var(--color-text-light);
  opacity: 1;
}

/* --- Radio & Checkbox Groups --- */
.radio-group,
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-label,
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  font-size: 0.9375rem;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background-color var(--transition), border-color var(--transition);
  user-select: none;
}

.radio-label:hover,
.checkbox-label:hover {
  background-color: rgba(52, 152, 219, 0.08);
  border-color: rgba(52, 152, 219, 0.15);
}

/* Hide native inputs */
.radio-label input[type="radio"],
.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Custom radio */
.radio-custom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  transition: border-color var(--transition), background-color var(--transition);
}

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

.radio-label input[type="radio"]:checked + .radio-custom::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--color-accent);
}

.radio-label input[type="radio"]:focus-visible + .radio-custom {
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.25);
}

/* Custom checkbox */
.checkbox-custom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  transition: border-color var(--transition), background-color var(--transition);
}

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

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
  content: "";
  width: 6px;
  height: 10px;
  border: solid var(--color-white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}

.checkbox-label input[type="checkbox"]:focus-visible + .checkbox-custom {
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.25);
}

/* --- Error State --- */
.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--color-error);
}

.has-error input:focus,
.has-error select:focus,
.has-error textarea:focus {
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15);
}

.error-message {
  display: none;
  font-size: 0.8125rem;
  color: var(--color-error);
  margin-top: 4px;
  line-height: 1.4;
}

.error-message.visible {
  display: block;
}

/* --- Schedule Rows --- */
.schedule-section {
  margin-top: 16px;
  margin-bottom: 20px;
}

.schedule-section > label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 8px;
}

.schedule-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.schedule-row select {
  min-height: 44px;
  padding: 8px 10px;
  font-size: 0.875rem;
  flex: 1;
}

.schedule-day { max-width: 80px; }
.schedule-start { max-width: 90px; }
.schedule-end { max-width: 90px; }

.schedule-separator {
  color: var(--color-text-light);
  font-size: 0.875rem;
  flex-shrink: 0;
}

.btn-remove-schedule {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background-color: var(--color-white);
  color: var(--color-error);
  font-size: 1.125rem;
  cursor: pointer;
  transition: background-color var(--transition);
  flex-shrink: 0;
}

.btn-remove-schedule:hover {
  background-color: rgba(231, 76, 60, 0.08);
}

.btn-add-schedule {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-accent);
  background: none;
  border: 1px dashed var(--color-accent);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--transition);
}

.btn-add-schedule:hover {
  background-color: rgba(52, 152, 219, 0.06);
}

/* --- Submit Button --- */
.btn-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 14px 24px;
  font-family: var(--font-family);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--color-white);
  background-color: var(--color-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.25);
  transition: background-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn-submit:hover {
  background-color: var(--color-accent-hover);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-submit:active {
  transform: scale(0.98);
}

.btn-submit:disabled,
.btn-submit[disabled] {
  background-color: var(--color-text-light);
  cursor: not-allowed;
  transform: none;
}

/* --- Confirmation Table --- */
.confirmation-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 16px;
  background-color: var(--color-white);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.confirmation-table th,
.confirmation-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9375rem;
}

.confirmation-table tr:last-child th,
.confirmation-table tr:last-child td {
  border-bottom: none;
}

.confirmation-table th {
  font-weight: 600;
  color: var(--color-primary);
  width: 35%;
  vertical-align: top;
  background-color: #F1F3F5;
}

.confirmation-table td {
  color: var(--color-text);
}

/* --- Thank You --- */
#thank-you {
  text-align: center;
  padding: 48px 24px;
}

#thank-you::before {
  content: "";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
  border-radius: 50%;
  background-color: rgba(39, 174, 96, 0.1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24' fill='none' stroke='%2327AE60' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

#thank-you h2 {
  font-size: 1.75rem;
  color: var(--color-primary);
  margin-bottom: 16px;
}

#thank-you p {
  color: var(--color-text-light);
  line-height: 1.7;
  margin-bottom: 8px;
}

/* Mobile responsive for schedule rows */
@media (max-width: 480px) {
  .schedule-row {
    flex-wrap: wrap;
  }
  .schedule-day,
  .schedule-start,
  .schedule-end {
    max-width: none;
    flex: 1 1 calc(33% - 8px);
  }
  .btn-remove-schedule {
    margin-left: auto;
  }
}

/* ==========================================================================
   Tablet & Desktop (768px+)
   ========================================================================== */

@media (min-width: 768px) {
  .form-header {
    padding: 32px 20px;
  }

  .form-header h1 {
    font-size: 1.375rem;
  }

  .form-container {
    padding: 0 20px 48px;
  }

  .form-steps .step .step-label {
    display: inline;
  }

  .field-group {
    margin-bottom: 24px;
  }

  .radio-group,
  .checkbox-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .radio-label,
  .checkbox-label {
    flex: 0 0 auto;
  }

  .btn-submit {
    max-width: 320px;
    margin: 0 auto;
  }

  .step-navigation {
    margin-top: 32px;
  }

  .btn-next,
  .btn-back {
    min-width: 140px;
  }
}
