/* ==========================================================================
   Sanctions Form - Consolidated Styles
   ========================================================================== */

/* ==========================================================================
   1. Table Styles
   ========================================================================== */

#session_schedule_table th:nth-child(1),
#session_schedule_table td:nth-child(1),
#session_schedule_table th:last-child,
#session_schedule_table td:last-child,
#event_schedule_table th:nth-child(1),
#event_schedule_table td:nth-child(1),
#event_schedule_table th:nth-child(2),
#event_schedule_table td:nth-child(2),
#event_schedule_table th:last-child,
#event_schedule_table td:last-child {
  width: 1%;
  white-space: nowrap;
}

#event_schedule_table th:nth-child(3),
#event_schedule_table td:nth-child(3) {
  width: 20%;
}

#session_schedule_table th:nth-child(4),
#session_schedule_table td:nth-child(4),
#session_schedule_table th:nth-child(5),
#session_schedule_table td:nth-child(5),
#event_schedule_table th:nth-child(4),
#event_schedule_table td:nth-child(4) {
  width: 25%;
}

#session_schedule_table th:nth-child(3),
#session_schedule_table td:nth-child(3),
#event_schedule_table th:nth-child(5),
#event_schedule_table td:nth-child(5) {
  width: 100%;
}

#session_schedule_table th:nth-child(2),
#session_schedule_table td:nth-child(2) {
  width: 25%;
}

/* ==========================================================================
   2. Quill Rich Text Editor Styles
   ========================================================================== */

.ql-container {
  font-family: Arial, sans-serif;
  font-size: 12pt;
  height: 200px;
  border-bottom-left-radius: 0.375rem;
  border-bottom-right-radius: 0.375rem;
}

.ql-editor {
  height: 200px;
  overflow-y: auto;
}

.ql-toolbar {
  background-color: #f3f4f6;
  border-top-left-radius: 0.375rem;
  border-top-right-radius: 0.375rem;
}

.quill-wrapper {
  margin: 0 0 1.5rem 0;
  padding: 0;
  display: block;
}

div[id$="_editor"] {
  margin: 0;
  padding: 0;
  clear: both;
  position: relative;
  display: block;
}

textarea.ql-hidden {
  display: none !important;
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  width: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
}

.relative:has(> .ql-hidden),
.relative:has(> .quill-wrapper) {
  margin-top: 0.5rem !important;
  margin-bottom: 0 !important;
  min-height: 0 !important;
  height: auto !important;
}

/* ==========================================================================
   3. Show/Hide Element Styles
   ========================================================================== */

.relative:has(> input[style*="display: none"]),
.relative:has(> input[style*="display:none"]),
.relative:has(> textarea[style*="display: none"]),
.relative:has(> textarea[style*="display:none"]) {
  display: none !important;
}

.relative:has(> input[style*="opacity: 0"]),
.relative:has(> input[style*="opacity:0"]),
.relative:has(> textarea[style*="opacity: 0"]),
.relative:has(> textarea[style*="opacity:0"]) {
  display: none !important;
}

div[style*="display: none"]:not([id$="_editor"]),
div[style*="display:none"]:not([id$="_editor"]) {
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
}

/* Only apply collapsing styles to form field containers, not modals */
div.relative.hidden,
form div.hidden:not(#loadingModal) {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  grid-column: span 0 !important;
  grid-row: span 0 !important;
  width: 0 !important;
}

div[style*="display: none"]:not(#loadingModal),
div[style*="display:none"]:not(#loadingModal) {
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  grid-column: span 0 !important;
  grid-row: span 0 !important;
  width: 0 !important;
}

/* ==========================================================================
   4. Officials Section - Conditional Field Hiding
   ========================================================================== */

#admin_referee_name_wrapper[style*="opacity: 0"],
#admin_referee_name_wrapper[style*="opacity:0"],
#admin_referee_name_wrapper[style*="display: none"],
#admin_referee_name_wrapper[style*="display:none"],
#admin_referee_name_wrapper.hidden,
#admin_referee_email_wrapper[style*="opacity: 0"],
#admin_referee_email_wrapper[style*="opacity:0"],
#admin_referee_email_wrapper[style*="display: none"],
#admin_referee_email_wrapper[style*="display:none"],
#admin_referee_email_wrapper.hidden,
#chief_judge_name_wrapper[style*="opacity: 0"],
#chief_judge_name_wrapper[style*="opacity:0"],
#chief_judge_name_wrapper[style*="display: none"],
#chief_judge_name_wrapper[style*="display:none"],
#chief_judge_name_wrapper.hidden,
#chief_judge_email_wrapper[style*="opacity: 0"],
#chief_judge_email_wrapper[style*="opacity:0"],
#chief_judge_email_wrapper[style*="display: none"],
#chief_judge_email_wrapper[style*="display:none"],
#chief_judge_email_wrapper.hidden,
#starter_name_wrapper[style*="opacity: 0"],
#starter_name_wrapper[style*="opacity:0"],
#starter_name_wrapper[style*="display: none"],
#starter_name_wrapper[style*="display:none"],
#starter_name_wrapper.hidden,
#starter_email_wrapper[style*="opacity: 0"],
#starter_email_wrapper[style*="opacity:0"],
#starter_email_wrapper[style*="display: none"],
#starter_email_wrapper[style*="display:none"],
#starter_email_wrapper.hidden,
#individual_late_fees_wrapper[style*="opacity: 0"],
#individual_late_fees_wrapper[style*="opacity:0"],
#individual_late_fees_wrapper[style*="display: none"],
#individual_late_fees_wrapper[style*="display:none"],
#individual_late_fees_wrapper.hidden,
#relay_late_fees_wrapper[style*="opacity: 0"],
#relay_late_fees_wrapper[style*="opacity:0"],
#relay_late_fees_wrapper[style*="display: none"],
#relay_late_fees_wrapper[style*="display:none"],
#relay_late_fees_wrapper.hidden {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

#individual_fees_wrapper:has(#individual_late_fees_wrapper.hidden),
#individual_fees_wrapper:has(#individual_late_fees_wrapper[style*="display: none"]),
#individual_fees_wrapper:has(#individual_late_fees_wrapper[style*="display:none"]),
#relay_fees_wrapper:has(#relay_late_fees_wrapper.hidden),
#relay_fees_wrapper:has(#relay_late_fees_wrapper[style*="display: none"]),
#relay_fees_wrapper:has(#relay_late_fees_wrapper[style*="display:none"]) {
  grid-template-columns: 1fr !important;
}

/* ==========================================================================
   5. Fixed Panel at Top
   ========================================================================== */

.fixed-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: white;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: flex;
  justify-content: center;
  gap: 1rem;
  align-items: center;
}

.form-container {
  margin-top: 5rem;
}

/* ==========================================================================
   6. Tooltip Styles
   ========================================================================== */

.tooltip {
  position: relative;
  display: block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 200px;
  background-color: #555;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px;
  position: absolute;
  z-index: 1;
  top: 125%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  transition: opacity 0.3s;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* ==========================================================================
   7. Required Fields Counter
   ========================================================================== */

.required-counter {
  background-color: #f3f4f6;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #374151;
  border: 1px solid #d1d5db;
  cursor: pointer;
  transition: all 0.2s ease;
}

.required-counter:hover {
  background-color: #e5e7eb;
  transform: translateY(-1px);
}

.required-counter.warning {
  background-color: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.required-counter.warning:hover {
  background-color: #fecaca;
}

/* ==========================================================================
   8. Validation & Error Styles
   ========================================================================== */

.input-error {
  border-color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.05) !important;
}

.border-red-500 {
  border-color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.05) !important;
}

.required-indicator {
  color: #ef4444;
  font-weight: bold;
}

/* ==========================================================================
   9. Officials Grid Layouts
   ========================================================================== */

.three-officials-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-flow: row;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .three-officials-grid #meet_director_name_wrapper,
  .three-officials-grid #meet_director_email_wrapper,
  .three-officials-grid #meet_director_phone_wrapper,
  .three-officials-grid #meet_referee_name_wrapper,
  .three-officials-grid #meet_referee_email_wrapper,
  .three-officials-grid #meet_referee_phone_wrapper {
    grid-column: span 2;
  }

  .three-officials-grid #admin_referee_name_wrapper,
  .three-officials-grid #admin_referee_email_wrapper,
  .three-officials-grid #chief_judge_name_wrapper,
  .three-officials-grid #chief_judge_email_wrapper,
  .three-officials-grid #starter_name_wrapper,
  .three-officials-grid #starter_email_wrapper,
  .three-officials-grid #admin_official_name_wrapper,
  .three-officials-grid #admin_official_email_wrapper {
    grid-column: span 3;
  }
}

.three-officials-grid > div.hidden {
  display: none !important;
  grid-column: span 0 !important;
  grid-row: span 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  position: absolute !important;
  overflow: hidden !important;
  width: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.six-officials-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-flow: row;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .six-officials-grid #meet_director_name_wrapper,
  .six-officials-grid #meet_director_email_wrapper,
  .six-officials-grid #meet_director_phone_wrapper,
  .six-officials-grid #meet_referee_name_wrapper,
  .six-officials-grid #meet_referee_email_wrapper,
  .six-officials-grid #meet_referee_phone_wrapper {
    grid-column: span 2;
  }

  .six-officials-grid #admin_referee_name_wrapper,
  .six-officials-grid #admin_referee_email_wrapper,
  .six-officials-grid #chief_judge_name_wrapper,
  .six-officials-grid #chief_judge_email_wrapper,
  .six-officials-grid #starter_name_wrapper,
  .six-officials-grid #starter_email_wrapper,
  .six-officials-grid #admin_official_name_wrapper,
  .six-officials-grid #admin_official_email_wrapper {
    grid-column: span 3;
  }
}

/* ==========================================================================
   10. Toast Notification
   ========================================================================== */

@keyframes slideIn {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

#toast {
  animation: slideIn 0.3s ease-out forwards, fadeOut 0.5s ease-in forwards 2.5s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   11. Loading Spinner
   ========================================================================== */

.loader {
  margin: 0 auto;
  border: 8px solid #f3f4f6;
  border-top: 8px solid #2563eb;
  border-radius: 50%;
  width: 64px;
  height: 64px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   12. Field Highlight Animation
   ========================================================================== */

@keyframes highlight-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

.highlight-field {
  animation: highlight-pulse 2s ease-out;
  border-color: #3b82f6 !important;
}

/* ==========================================================================
   13. Button Styles (Non-Tailwind overrides)
   ========================================================================== */

#meet_info_btn,
#app_sanction_btn {
  background-color: #2563eb !important;
}

#meet_info_btn:hover,
#app_sanction_btn:hover {
  background-color: #1d4ed8 !important;
}

#saveButton {
  background-color: #4b5563 !important;
}

#saveButton:hover {
  background-color: #374151 !important;
}
