/* =========================================
   RESET & PAGE SETTINGS
   ========================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}

body {
  min-height: 100vh;
  background: linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)),
              url('images/Track image.jpeg') no-repeat center center / cover;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 25px 15px;
}

/* =========================================
   HEADER CONTAINER
   ========================================= */
.form-header-container {
  width: 100%;
  max-width: 1200px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid #f7b731;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid rgba(247, 183, 49, 0.35);
  padding-bottom: 12px;
}

.logo-box {
  width: 95px;
  height: 95px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #ffffff;
  border-radius: 4px;
  padding: 2px;
}

.logo-box img.circle-bg {
  border-radius: 50%;
}

.header-center-content {
  flex-grow: 1;
  text-align: center;
}

.main-event-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: #f7b731;
  margin-bottom: 3px;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9);
}

.org-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.address-text,
.dept-text,
.contact-email {
  font-size: 0.82rem;
  color: #e0e0e0;
  margin: 1px 0;
}

.dept-text.bold {
  font-weight: bold;
  color: #ffffff;
}

.contact-email a {
  color: #f7b731;
  text-decoration: none;
}

.contact-email a:hover {
  text-decoration: underline;
}

.header-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 10px;
}

.form-badge {
  font-size: 0.95rem;
  font-weight: 700;
}

/* =========================================
   MAIN FORM & LAYOUT
   ========================================= */
.registration-form {
  width: 100%;
  max-width: 1200px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.section-title {
  text-align: center;
  color: #f7b731;
  font-size: 1.1rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  margin: 16px 0 8px 0;
  text-shadow: 1px 1px 3px #000;
}

.form-layout-with-sidebar {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

/* Photo Box */
.photo-upload-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 130px;
  flex-shrink: 0;
}

/* The photo area is exactly 35 mm : 45 mm (7 : 9), like the photo that is saved (photo-fit.js cuts every photo to that
   shape): 126 x 162 px inside the 2px dashed edge, so the box is 130 x 166 px. */
.photo-box {
  width: 130px;
  height: 166px;
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  border: 2px dashed #1d428a;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.photo-preview-img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  position: absolute;
  top: 0;
  left: 0;
  background-color: #ffffff;
}

.photo-label {
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-shadow: 1px 1px 2px #000;
}

/* Fields & General Inputs */
.fields-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.field-row.align-start {
  align-items: flex-start;
}

.flex-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

label {
  color: #ffffff;
  font-size: 0.88rem;
  white-space: nowrap;
  text-shadow: 1px 1px 2px #000;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="password"],
select {
  height: 32px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #cccccc;
  outline: none;
  font-size: 0.88rem;
  background-color: #ffffff;
  color: #333333;
  box-sizing: border-box;
}

input:focus,
select:focus {
  border-color: #f7b731;
  box-shadow: 0 0 5px rgba(247, 183, 49, 0.5);
}

/* Institution Select & Dynamic Other Row */
select.institution-select {
  flex: 1;
  min-width: 0;
  /* its width is the room that is left in the row, never the length of its longest name: a long school name used to make the
     whole form wider than its card (width 0 + flex-grow means "no size of its own") */
  width: 0;
}

/* School / College / Association = two boxes side by side (institution-picker.js): the TYPE (School, College, Association), then the
   NAME box with the real names of that type */
.institution-pair {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

select.institution-type-select {
  flex: 0 0 160px;
  width: 160px;
}

/* The affiliation District box while a School / College / Association of the list is chosen: the District follows it by itself
   (institution-picker.js + institution-districts.js), so the box looks switched off (but is still sent with the form). */
select.district-follows {
  background-color: #e8ecf1;
  border-color: #b8c1cc;
  cursor: not-allowed;
}

select.institution-select optgroup {
  font-weight: bold;
  color: #0c2461;
  background-color: #f0f4f8;
}

.other-school-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.other-school-lbl {
  width: 250px;
  color: #ffffff;
  font-weight: bold;
}

.other-school-input {
  flex: 1;
  border: 1.5px solid #f7b731;
}

/* Width Utilities */
.grow-1 { flex: 1; }
.grow-2 { flex: 2; }
.w-45 { width: 45px; }
.w-90 { width: 90px; }
.w-100 { width: 100px; }
.w-110 { width: 110px; }
.w-130 { width: 130px; }
.w-180 { width: 180px; }
.w-200 { width: 200px; }
.w-320 { width: 320px; }
.text-center { text-align: center; }

/* Flatpickr DOB Input */
.dob-input-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 145px;
}

.dob-field {
  width: 100%;
  padding-right: 30px;
  cursor: pointer;
}

.dob-input-wrapper .calendar-icon {
  position: absolute;
  right: 8px;
  pointer-events: none;
}

/* =========================================
   SPORTS SELECTION
   ========================================= */
.sports-selection-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-left: auto;
}

.sports-grid {
  display: grid;
  grid-template-columns: 48% 48%;
  gap: 8px;
}

.sport-btn input[type="checkbox"] {
  display: none;
}

.sport-btn span {
  display: block;
  background: #ffffff;
  color: #0c2461;
  border: 2px solid #0c2461;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 800;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.sport-btn input[type="checkbox"]:checked + span {
  background-color: #0c2461;
  color: #ffffff;
}

.sport-btn input[type="checkbox"]:disabled + span {
  background-color: rgba(255, 50, 50, 0.4);
  color: #FF9595;
  border-color: #FF9595;
  cursor: not-allowed;
}

/* =========================================
   ATHLETICS SUB-PANEL (HIGH CONTRAST)
   ========================================= */
.athletics-panel {
  background: rgba(17, 20, 26, 0.95);
  border: 1.5px solid #d4af37;
  border-radius: 8px;
  padding: 14px 18px;
  margin-top: 10px;
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.athletics-panel.hidden {
  display: none !important;
}

.sub-panel-title {
  color: #f5f5f5;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-bottom: 12px;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  padding-bottom: 6px;
}

.ath-category-block {
  margin-bottom: 14px;
}

.ath-category-block:last-child {
  margin-bottom: 0;
}

.ath-category-heading {
  color: #ffcc00 !important;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.athletics-events-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.event-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1e232d;
  color: #ffffff;
  padding: 5px 11px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #333c4d;
  transition: all 0.2s ease;
}

.event-pill:hover {
  border-color: #d4af37;
  background: #252c38;
}

.event-pill input[type="checkbox"] {
  cursor: pointer;
  accent-color: #d4af37;
  width: 14px;
  height: 14px;
  margin: 0;
}

.relay-free {
  border-color: #4caf50;
  background: #16291a;
  color: #81c784;
}

.relay-free input[type="checkbox"] {
  accent-color: #4caf50;
}

/* =========================================
   BANK & T-SHIRT SECTION
   ========================================= */
.bank-section-layout {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-top: 10px;
}

.bank-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.tshirt-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 140px;
}

.tshirt-column label {
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: bold;
}

/* Document Upload Buttons */
.doc-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #111111;
  border: 1px solid #777777;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  height: 32px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease;
}

.doc-upload-btn:hover {
  background-color: #f7b731;
  border-color: #d89b1c;
  color: #000000;
}

.doc-upload-btn.file-attached {
  background-color: #27ae60;
  color: #ffffff;
  border-color: #1e8449;
}

/* =========================================
   PASSWORD FIELDS & SUBMIT
   ========================================= */
.password-group-row {
  display: flex !important;
  flex-direction: row !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 24px !important;
  margin: 10px auto 20px auto !important;
  width: 100% !important;
}

.password-field-cell {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
}

.password-field-cell label {
  color: #ffffff !important;
  font-size: 0.85rem !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
  text-shadow: 1px 1px 2px #000000;
}

.password-field-cell input[type="password"],
.password-field-cell input[type="email"] {
  width: 180px !important;
  height: 32px !important;
  background-color: #ffffff !important;
  border: 1px solid #ffffff !important;
  border-radius: 4px !important;
  padding: 4px 10px !important;
  font-size: 0.88rem !important;
  color: #000000 !important;
  outline: none !important;
  box-sizing: border-box !important;
}

.password-field-cell input[type="password"]::placeholder,
.password-field-cell input[type="email"]::placeholder {
  color: #888888;
  font-size: 0.82rem;
}

.password-field-cell input[type="password"]:focus,
.password-field-cell input[type="email"]:focus {
  border-color: #f7b731 !important;
  box-shadow: 0 0 5px rgba(247, 183, 49, 0.7) !important;
}

/* Show / hide (eye) button inside the two password boxes. The boxes are styled by the class "pw-input" as well
   as by type="password", so a box that is shown (type text) looks exactly like a hidden one. */
.password-field-cell .pw-wrap {
  position: relative;
  display: block;
  width: 180px;
}

.password-field-cell input.pw-input {
  width: 100% !important;
  height: 32px !important;
  background-color: #ffffff !important;
  border: 1px solid #ffffff !important;
  border-radius: 4px !important;
  padding: 4px 34px 4px 10px !important;
  font-size: 0.88rem !important;
  color: #000000 !important;
  outline: none !important;
  box-sizing: border-box !important;
}

.password-field-cell input.pw-input::placeholder {
  color: #888888;
  font-size: 0.82rem;
}

.password-field-cell input.pw-input:focus {
  border-color: #f7b731 !important;
  box-shadow: 0 0 5px rgba(247, 183, 49, 0.7) !important;
}

.pw-eye {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.6 12C5 8 8.3 7 12 7S19 8 21.4 12C19 16 15.7 17 12 17S5 16 2.6 12z' stroke-width='1.9'/%3E%3Ccircle cx='12' cy='12' r='3.3' stroke-width='1.9'/%3E%3Cpath d='M5.2 18.8L18.8 5.2' stroke='%23fff' stroke-width='4'/%3E%3Cpath d='M5.2 18.8L18.8 5.2' stroke-width='2'/%3E%3C/svg%3E") center / 20px 20px no-repeat;
  cursor: pointer;
}

.pw-eye.on {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.6 12C5 8 8.3 7 12 7S19 8 21.4 12C19 16 15.7 17 12 17S5 16 2.6 12z' stroke-width='1.9'/%3E%3Ccircle cx='12' cy='12' r='3.3' stroke-width='1.9'/%3E%3C/svg%3E");
}

.pw-eye:focus-visible {
  outline: 2px solid #f7b731;
  outline-offset: 1px;
  border-radius: 4px;
}

.submit-wrapper {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  margin-top: 10px !important;
  margin-bottom: 20px !important;
  width: 100% !important;
}

.gold-submit-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: linear-gradient(180deg, #fce072 0%, #e59818 100%) !important;
  color: #ffffff !important;
  border: 2px solid #573e04 !important;
  border-radius: 6px !important;
  padding: 8px 50px !important;
  font-size: 1.25rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.5px !important;
  cursor: pointer !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4) !important;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7) !important;
  transition: all 0.2s ease !important;
}

.gold-submit-btn:hover {
  background: linear-gradient(180deg, #fadc56 0%, #c9820f 100%) !important;
}

/* Validation Utilities */
.auto-locked-field {
  background-color: #f1f2f6 !important;
  color: #1e272e !important;
  font-weight: 700;
  cursor: not-allowed;
  border: 1px solid #dcdde1 !important;
}

.field-error {
  border: 2px solid #ff4d4d !important;
  box-shadow: 0 0 8px rgba(255, 77, 77, 0.8) !important;
  background-color: #fff0f0 !important;
}

.photo-error {
  border: 2px dashed #ff4d4d !important;
  box-shadow: 0 0 10px rgba(255, 77, 77, 0.9) !important;
  background-color: #ffe6e6 !important;
}

.form-error-banner {
  display: none;
  color: #ff4d4d;
  background: rgba(40, 10, 10, 0.85);
  border: 1px solid #ff4d4d;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: bold;
  text-align: center;
  margin: 10px auto;
  max-width: 500px;
}

/* =========================================
   RESPONSIVE (MOBILE & TABLET)
   ========================================= */
@media (max-width: 768px) {
  body {
    padding: 10px 6px;
  }

  .form-header-container,
  .registration-form {
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px 10px !important;
  }

  .header-top-row,
  .header-bottom-row {
    flex-direction: column !important;
    text-align: center !important;
    gap: 10px !important;
  }

  .form-layout-with-sidebar {
    flex-direction: column !important;
    align-items: center !important;
    gap: 15px !important;
  }

  .photo-upload-container {
    width: 100% !important;
    margin-bottom: 8px !important;
  }

  .fields-container {
    width: 100% !important;
  }

  .field-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
    margin-bottom: 8px !important;
  }

  .field-row label {
    margin-top: 4px !important;
    text-align: left !important;
  }

  /* the two School / College / Association boxes one under the other (their flex size must not become a height) */
  .institution-pair {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .institution-pair select,
  select.institution-type-select {
    flex: none;
  }

  .field-row input[type="text"],
  .field-row input[type="tel"],
  .field-row input[type="email"],
  .field-row select,
  .w-45, .w-90, .w-100, .w-110, .w-130, .w-180, .w-200, .w-320,
  .grow-1, .grow-2,
  .institution-select,
  .institution-pair,
  .other-school-input {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .flex-inline,
  .dob-input-wrapper,
  .dob-input-wrapper input,
  .doc-upload-btn,
  .sports-selection-block,
  .bank-fields,
  .tshirt-column,
  .tshirt-column select,
  .gold-submit-btn {
    width: 100% !important;
  }

  .sports-grid {
    grid-template-columns: 48% 48% !important;
    justify-content: space-between !important;
    gap: 8px !important;
    width: 100% !important;
  }

  /* Properly Contained Mobile Athletics Pills */
  .athletics-events-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .event-pill {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
    font-size: 0.8rem !important;
    padding: 6px 8px !important;
  }

  .relay-free {
    flex: 1 1 100% !important;
  }

  .bank-section-layout {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .password-group-row {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: stretch !important;
  }

  .password-field-cell {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
  }

  .password-field-cell input[type="password"],
  .password-field-cell input[type="email"] {
    width: 100% !important;
  }

  .password-field-cell .pw-wrap {
    width: 100%;
  }
}