/* style.css - Combined Stylesheet for yacht.racing Race Timer */

/* ============================================================================ */
/* GLOBAL STYLES */
/* ============================================================================ */

html,
body {
  font-family: sans-serif;
  margin: 0;
  padding: 0;
}

body {
  font-family: sans-serif;
  margin: 0;
  padding: 15px;
  min-height: 100%;
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
  box-sizing: border-box;
}

/* Modified to allow body scrolling when modal is open */
body.modal-open {
  overflow: auto !important;
}

/* ============================================================================ */
/* HEADER STYLES */
/* ============================================================================ */

/* Default header image style */
#headerImage {
  float: right;
  width: 200px;
  height: auto;
}

/* Media query for mobile: reduce header logo size */
@media (max-width: 600px) {
  #headerImage {
    width: 150px;
    height: auto;
    margin-top: 10px;
  }
}

#header {
  width: 25%;
  height: 200px;
  background: var(--header-logo) no-repeat right center;
  background-size: auto 100%;
}

/* ============================================================================ */
/* MENU STYLES */
/* ============================================================================ */

#mainMenu {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 300;
  width: 100%;
}

#menuTopRow {
  display: flex;
  align-items: center;
}

#menuButton {
  font-size: 14px;
  padding: 8px 12px;
  background-color: #33b1ff;
  border: 2px solid black;
  cursor: pointer;
  margin-right: 15px;
}

#menuDropdown {
  display: none;
  position: absolute;
  background-color: white;
  min-width: 120px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 300;
  border: 2px solid black;
}

.menu-item {
  padding: 8px 12px;
  text-decoration: none;
  display: block;
  color: black;
  cursor: pointer;
  text-align: left;
  border: none;
  background: none;
  width: 100%;
  font-size: 14px;
}

.menu-item:hover {
  background-color: #f1f1f1;
}

.submenu-container {
  position: relative;
}

.submenu-container .menu-item {
  padding-right: 24px;
}

.submenu-container::after {
  content: "▶";
  position: absolute;
  right: 10px;
  top: 0%;
}

.submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  background-color: white;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 300;
  border: 2px solid black;
}

.submenu-container:hover .submenu {
  display: block;
}

.menu-info {
  cursor: default !important;
  font-size: 10px !important;
  color: #004876 !important;
  padding: 4px 16px !important;
  font-style: bold;
  background: none !important;
}

.menu-info:hover {
  background-color: transparent !important;
}

/* ============================================================================ */
/* TIME DISPLAY STYLES */
/* ============================================================================ */

#startTimeDisplay,
#elapsedTimeDisplay {
  font-size: 16px;
  margin-left: 10px;
  vertical-align: middle;
  text-align: center;
}

#startTimeDisplay {
  display: none !important;
}

/* ============================================================================ */
/* BUTTON STYLES */
/* ============================================================================ */

.fullwidth-orange {
  display: block;
  width: 100%;
  background-color: orange;
  color: black;
  border: 2px solid black;
  padding: 10px 0;
  font-size: 14px;
  margin: 5px 0;
  cursor: pointer;
}

button {
  font-size: 14px;
  margin: 5px 0;
  border-radius: 4px;
}

/* ============================================================================ */
/* TABLE STYLES */
/* ============================================================================ */

/* Containers for tables */
#boatTimesContainer {
  margin-top: 10px;
  width: 100%;
  max-width: 1200px;
  text-align: center;
  margin-right: 0;
  margin-left: 0;
  margin-bottom: 0px;
}

#boatTimesContainer table tr td:first-child {
  text-align: left !important;
}

#markComparisonsContainer table th:first-child,
#markComparisonsContainer table td:first-child {
  position: sticky;
  left: 0;
  background: #33b1ff;
  z-index: 2;
  border-right: 2px solid black;
}

#boatTimesContainer table th:first-child,
#boatTimesContainer table td:first-child {
  left: 0;
  background: #33b1ff;
  z-index: 2;
}

/* Responsive table wrapper */
.responsive-table-wrapper {
  overflow-x: auto;
  width: 100%;
}

table {
  width: auto;
  border-collapse: collapse;
  border-spacing: 0;
  margin-top: 10px;
  border-radius: 4px;
}

th {
  background-color: #33b1ff;
  border: 2px solid black;
  padding: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
}

td {
  border: 2px solid black;
  padding: 5px 10px;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================================ */
/* MODAL STYLES */
/* ============================================================================ */

/* Universal Modal styling */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  overflow: auto;
}

/* Universal modal content styling for all modals */
.modal-content {
  background-color: #fff;
  margin: 2% auto;
  padding: 20px;
  width: auto;
  min-width: 300px;
  max-width: 600px;
  position: relative;
  border: solid #000f52 3px;
  border-radius: 10px;
  overflow: visible;
  box-sizing: border-box;
  transition: transform 0.3s ease-out, margin 0.3s ease-out;
}

/* Add animation for modal appearance */
@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  animation: modalFadeIn 0.25s ease-out;
}

/* Universal content styling for modal elements */
.modal-content table {
  font-size: 14px;
  width: 100% !important;
  border-collapse: collapse;
  margin: 10px 0;
  overflow-x: visible;
}

#startTimeModal button {
  font-size: 14px;
  padding: 10px 16px;
  margin: 6px 3px;
  min-width: 120px;
}

.modal-content th,
.modal-content td {
  padding: 8px;
  text-align: center;
  border: 1px solid #ddd;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.modal-content td:first-child {
  text-align: left;
}

/* Remove the responsive wrapper for modal tables */
.modal-content .responsive-table-wrapper {
  overflow-x: visible;
}

/* Override the specific table width settings for modal tables */
.modal table {
  width: 100% !important;
}

/* List areas in modals - without scrolling */
#boatSelectionList,
#boatsList,
#marksList {
  margin: 10px 0;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 5px;
}

.close {
  position: absolute;
  right: 10px;
  top: 5px;
  font-size: 18px;
  cursor: pointer;
}

/* Confirmation modal (special case) */
.confirmation-modal {
  display: none;
  position: fixed;
  z-index: 1500;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
}

.confirmation-modal-content {
  background-color: #fff;
  margin: 10% auto;
  padding: 20px;
  width: auto;
  max-width: 250px;
  position: relative;
  border: solid #000f52 3px;
  border-radius: 10px;
  text-align: center;
  transition: transform 0.3s ease-out, margin 0.3s ease-out;
}

.confirmation-buttons {
  margin-top: 20px;
}

.confirmation-btn-yes {
  background-color: #f70b0b;
  color: white;
  margin-right: 10px;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.confirmation-btn-no {
  background-color: #ccc;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* Mark Rounding modal larger styling */
.mark-rounding-modal-content {
  font-size: 14px;
}

.mark-rounding-modal-content label,
.mark-rounding-modal-content button,
.mark-rounding-modal-content select,
.mark-rounding-modal-content input {
  font-size: 14px;
  padding: 8px 12px;
  margin: 5px;
}

/* ============================================================================ */
/* FORM STYLES */
/* ============================================================================ */

/* Placeholder styling for dropdowns */
select option.placeholder {
  color: #999 !important;
  font-style: italic;
  display: none;
}

select:invalid {
  color: #999;
}

/* ============================================================================ */
/* CHART STYLES */
/* ============================================================================ */

#chartContainer {
  width: 100%;
  min-width: 1000px;
  max-width: 1600px;
  margin: 0 auto;
  overflow-x: auto;
}

.chart-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

/* ============================================================================ */
/* INTERACTIVE FEEDBACK STYLES */
/* ============================================================================ */

/* Add interactive feedback for clickable elements */
th[style*="cursor:pointer"],
td[style*="cursor:pointer"],
.boat-cell,
.mark-header,
.mark-boat-cell {
  position: relative;
  overflow: hidden;
}

th[style*="cursor:pointer"]:active,
td[style*="cursor:pointer"]:active,
.boat-cell:active,
.mark-header:active,
.mark-boat-cell:active {
  background-color: rgba(51, 177, 255, 0.7);
}

/* Feedback for boat selection buttons */
.boat-selection-btn:not(.disabled):active {
  background-color: #e6e6e6 !important;
  transform: translateY(1px);
}

/* ============================================================================ */
/* BOTTOM BUTTONS STYLES */
/* ============================================================================ */

#clearDataContainer {
  width: 100%;
  text-align: center;
  background-color: #fff;
  padding: 10px 0;
  border-top: 1px solid #ccc;
  margin-top: 15px;
}

#clearDataContainer button:hover {
  background-color: orange;
}

/* ============================================================================ */
/* MODE TOGGLE STYLES */
/* ============================================================================ */

.mode-toggle {
  display: inline-flex;
  background-color: #f0f0f0;
  border: 2px solid #333;
  border-radius: 4px;
  margin-left: 10px;
  overflow: hidden;
}

.mode-toggle button {
  background-color: transparent;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
  margin: 0;
}

.mode-toggle button.active {
  background-color: #33b1ff;
  color: white;
}

.mode-toggle button:hover:not(.active) {
  background-color: #e0e0e0;
}

/* ============================================================================ */
/* TOD (TIME ON DISTANCE) STYLES */
/* ============================================================================ */

.tod-config-section {
  background-color: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
  margin-top: 10px;
}

.tod-config-section h3 {
  margin-top: 0;
  font-size: 16px;
  color: #333;
}

.tod-field-config {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 5px;
  margin-bottom: 10px;
}

.tod-field-config label {
  text-align: right;
  padding-right: 10px;
  align-self: center;
}

.tod-field-config input {
  padding: 4px;
  border: 1px solid #ccc;
  border-radius: 3px;
}

#distanceInputContainer {
  display: flex;
  align-items: center;
  margin-left: 15px;
}

#distanceInput {
  font-size: 16px;
  margin-left: 5px;
  margin-right: 5px;
  width: 50px;
}

#activeRatingSelect {
  margin-left: 1px;
  padding: 4px 8px;
  font-size: 14px;
}

/* Dynamic ToD fields scrollable container */
#dynamicToDFields {
  max-height: 300px;
  overflow-y: auto;
  margin: 10px 0;
}

#todFieldCount {
  margin-bottom: 15px;
}

/* ============================================================================ */
/* MOBILE STYLES */
/* ============================================================================ */

@media (max-width: 600px) {
  body {
    padding: 5px;
    font-size: 16px;
  }

  #headerImage {
    width: 100px;
    height: auto;
  }

  #appTitle {
    font-size: 12px !important;
  }

  #topButtons button {
    font-size: 12px;
    padding: 4px 6px;
    margin-right: 5px;
  }

  /* Ensure mode toggle buttons remain usable on mobile */
  .mode-toggle {
    margin-left: 5px;
    min-width: 80px;
    flex-shrink: 0;
  }
  
  .mode-toggle button {
    padding: 6px 8px;
    font-size: 12px;
    min-width: 35px;
  }
  
  /* Allow menu row to wrap on very narrow screens */
  #menuTopRow {
    flex-wrap: wrap;
    gap: 5px;
  }

  #clearDataContainer button {
    width: 100%;
    margin: 5px auto;
    display: block;
    font-size: 12px;
    padding: 6px 10px;
  }

  table {
    font-size: 14px;
    width: 40px !important;
  }

  table th,
  table td {
    padding: 8px 2px;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 50px !important;
  }

  /* Mobile view for start time modal buttons */
  #startTimeModal button {
    font-size: 14px;
    padding: 10px 16px;
    margin: 6px 3px;
    min-width: 120px;
  }

  #startTimeModal .fullwidth-orange {
    font-size: 14px;
    padding: 10px 0;
    margin: 6px 0;
    border-radius: 4px;
  }

  /* Taller rows for mark comparisons table on mobile */
  #markComparisonsContainer table th,
  #markComparisonsContainer table td {
    padding: 10px 2px;
    font-size: 14px;
    min-height: 40px;
  }

  /* Restrict boat column width - Simple version */
  #boatTimesContainer table td:first-child,
  #boatTimesContainer table th:first-child {
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #markComparisonsContainer table td:first-child,
  #markComparisonsContainer table th:first-child {
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Modal styling for mobile - consistent with desktop */
  .modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    max-height: none !important;
    background-color: rgba(0, 0, 0, 0.4);
    overflow: auto;
  }

  /* Updated Universal modal styling for mobile */
  .modal-content {
    width: 90%;
    max-height: none !important;
    margin: 20px auto;
    max-height: calc(100vh - 40px) !important;
    overflow-y: auto !important;
    max-width: 90%;
    min-width: 280px;
    padding: 12px;
    overflow: visible;
    background-color: #fff;
    border: solid #000f52 3px;
    border-radius: 10px;
    box-sizing: border-box;
  }

  /* Universal content styling for all modal elements on mobile */
  .modal-content table {
    width: 100% !important;
    display: table !important;
    overflow-x: auto;
    overflow-y: auto;
  }

  .modal-content th,
  .modal-content td {
    padding: 4px;
    font-size: 14px;
    min-width: 40px;
  }

  /* List areas in modals - without scrolling for mobile */
  #boatSelectionList,
  #boatsList,
  #marksList {
    margin: 10px 0;
  }

  #boatsList table td:first-child,
  #boatsList table th:first-child {
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mark-rounding-modal-content {
    font-size: 12px;
    margin: 30vh auto;
  }

  .mark-rounding-modal-content label,
  .mark-rounding-modal-content button,
  .mark-rounding-modal-content select,
  .mark-rounding-modal-content input {
    font-size: 12px;
    padding: 2px;
    margin: 5px auto;
  }

  .confirmation-modal-content {
    width: 90%;
    margin: 30vh auto;
    padding: 15px;
  }

  .confirmation-btn-yes,
  .confirmation-btn-no {
    padding: 6px 12px;
    font-size: 14px;
  }

  /* Ensure modals don't position too high when virtual keyboard appears */
  .modal-content[style*="transform"] {
    max-height: 80vh;
  }
}

@media (max-width: 440px) {
  #boatTimesContainer {
    padding-top: 30px;
  }
}

@media (max-width: 375px) {
  #boatTimesContainer {
    margin-top: 30px;
  }
  #todControls {
    padding-top: 40px;
  }
}

@media (max-width: 300px) {
  /* Fix menu top row layout for narrow screens */
  #menuTopRow {
    flex-wrap: wrap;
    gap: 2px;
  }

  /* Make Set ET input narrower on mobile */
  #fixETInput {
    font-size: 16px !important;
    margin-left: 2px !important;
    margin-right: 2px !important;
    width: 90px !important;
    min-width: 90px !important;
  }

  #fixETDayInput {
    font-size: 16px !important;
    margin-left: 2px !important;
    margin-right: 2px !important;
    width: 40px !important;
    min-width: 40px !important;
  }

  #fixETDayLabel {
    font-size: 14px !important;
    margin-right: 2px !important;
  }
}

/* ============================================================================ */
/* ADDITIONAL UTILITY STYLES */
/* ============================================================================ */

/* Additional modal positioning styles that won't interfere with existing styles */
.modal.active {
  display: block;
}

/* Allow clicking through the modal backdrop to confirm actions */
.modal-clickthrough {
  pointer-events: none;
}

.modal-clickthrough .modal-content {
  pointer-events: auto;
}

/* Ensure consistent modal behavior regardless of viewport height */
.modal-content {
  max-height: none;
}

/* ============================================================================ */
/* ANIMATION STYLES */
/* ============================================================================ */

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================================================ */
/* BOAT HEADER ANIMATION STYLES */
/* ============================================================================ */

@keyframes flashGreen {
  0%, 100% { 
    background-color: rgb(71, 163, 71); 
  }
  50% { 
    background-color: lightgreen; 
  }
}

.boat-header-flashing {
  animation: flashGreen 1.5s infinite;
  cursor: pointer;
}

th.boat-header-orange {
  background-color: orange !important;
  cursor: pointer;
}

/* Content Modal Specific Styles */
#userGuideModal .modal-content,
#eulaModal .modal-content {
  max-width: 90%;
  width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  margin: 2% auto;
}

#userGuideContent,
#eulaContent {
  padding: 0;
  font-size: 14px;
  line-height: 1.5;
}

#userGuideContent h1,
#eulaContent h1 {
  margin-top: 0;
  padding-top: 0;
}

#userGuideContent img,
#eulaContent img {
  max-width: 100%;
  height: auto;
}

/* Mobile adjustments for content modals */
@media (max-width: 600px) {
  #userGuideModal .modal-content,
  #eulaModal .modal-content {
    width: 95%;
    max-height: 95vh;
    margin: 2.5% auto;
    padding: 10px;
  }
  
  #userGuideContent,
  #eulaContent {
    font-size: 13px;
  }
  
  #userGuideContent h1,
  #eulaContent h1 {
    font-size: 18px;
  }
  
  #userGuideContent h2,
  #eulaContent h2 {
    font-size: 16px;
  }
  
  #userGuideContent h3,
  #eulaContent h3 {
    font-size: 14px;
  }
}

