body { font-family: Arial, sans-serif; margin: 20px; }

.title-container {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

#copyUrlButton {
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  height: fit-content;
}

/* Layout Containers */
.main-container {
  display: flex;
  align-items: flex-start;
  gap: 30px;
}

.form-wrapper {
  flex: 0 0 650px; /* Do not grow, do not shrink, base width 650px */
  position: sticky;
  top: 20px;
}

.results-wrapper {
  flex-grow: 1; /* Take up remaining space */
}

.form-container {
  max-width: 650px;
  /* margin: 20px auto; REMOVED for flexbox layout */
  padding: 20px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background-color: #f9f9f9;
}

label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

label > div {
  display: flex;
  align-items: center;
}

input, select { padding: 5px; width: 220px; box-sizing: border-box; }
button { margin-top: 15px; padding: 8px 15px; }
table { border-collapse: collapse; margin-top: 20px; width: 100%; } /* Ensure table takes full width of its container */
th, td { border: 1px solid #ccc; padding: 6px 10px; text-align: right; }
th { background-color: #f4f4f4; }
.tooltip {
  display: inline-block;
  position: relative;
  cursor: pointer;
  font-weight: bold;
  color: #0077cc;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  text-align: center;
  line-height: 18px;
  font-size: 12px;
  background-color: #e0e0e0;
  margin-left: 10px;
}
.tooltip-text {
  visibility: hidden;
  opacity: 0;
  width: 250px;
  background-color: #333;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 8px;
  position: absolute;
  z-index: 1;
  bottom: 125%; /* Above the icon */
  left: 50%;
  transform: translateX(-50%);
  transition: opacity 0.3s;
  font-size: 13px;
}
.tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: #333 transparent transparent transparent;
}
.tooltip:focus .tooltip-text,
.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Loading Indicator and Fading Styles */
.loading-dots span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #3498db;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots .dot1 {
  animation-delay: -0.32s;
}

.loading-dots .dot2 {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  } 40% {
    transform: scale(1.0);
  }
}

#results.fading {
  opacity: 0.3;
  transition: opacity 0.3s ease-in-out;
}

/* Responsive Styles */
@media (max-width: 1024px) {
  .main-container {
    flex-direction: column;
  }

  .form-wrapper {
    position: static; /* Remove sticky positioning on mobile */
    width: 100%;
  }

  .form-container {
     max-width: none; /* Allow form to take full width */
  }
}

/* More specific mobile styles */
@media (max-width: 768px) {
  label {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-top: 15px;
  }

  label > div {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  input, select {
    width: 100%; /* Make inputs take full width of their container */
  }
}

.radio-group-horizontal, .radio-group-vertical {
  display: flex;
  align-items: center;
  margin-top: 5px;
}

.radio-group-horizontal {
  flex-direction: row;
}

.radio-group-vertical {
  flex-direction: column;
  align-items: flex-start;
}

.radio-group-horizontal input[type="radio"], .radio-group-vertical input[type="radio"] {
  margin-right: 5px;
}

.radio-group-horizontal label, .radio-group-vertical label {
  margin-right: 15px;
  font-weight: normal;
}

.label-for-radio {
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

/* AI Explanation Styles */
.ai-explanation-container {
  margin-top: 20px;
  padding: 15px;
  background-color: #f0f4f8;
  border-left: 4px solid #3498db;
  border-radius: 4px;
  white-space: pre-wrap; /* Preserve line breaks */
}

/* Modal Styles */
.modal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
}

.modal-content {
  background-color: #fefefe;
  margin: 10% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  max-width: 500px;
  border-radius: 8px;
  position: relative;
}

.close-button {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close-button:hover,
.close-button:focus {
  color: black;
  text-decoration: none;
}

.modal-instructions {
  background-color: #f9f9f9;
  border: 1px solid #ddd;
  padding: 10px;
  margin: 15px 0;
  border-radius: 4px;
}

.modal-instructions ol {
  padding-left: 20px;
}

#apiKeyInput {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
}

/* Global Help Button */
.global-help-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: #3498db;
  color: #fff;
  border: none;
  font-size: 20px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  z-index: 200;
  transform: translateZ(0);
  transition: background-color 0.3s ease;
}
.global-help-btn.active {
  background-color: #28a745; /* A shade of green */
}
.global-help-btn:hover {
  background-color: #2b82bf;
}
.cursor-help-active, .cursor-help-active * {
  cursor: help !important;
}
.cursor-wait-active, .cursor-wait-active * {
  cursor: wait !important;
}

/* Explanation Popover Styles */
.popover {
  display: none; /* Hidden by default */
  position: absolute;
  z-index: 200;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 15px;
  max-width: 300px;
  font-size: 14px;
  line-height: 1.5;
}

.popover-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
}

.popover.arrow-bottom .popover-arrow {
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 10px 10px 0 10px;
  border-color: #fff transparent transparent transparent;
}

/* This is a filter to make the arrow border match the popover border */
.popover.arrow-bottom .popover-arrow::after {
  content: "";
  position: absolute;
  top: -11px; /* (border-width - 1px) */
  left: -10px;
  border-width: 10px 10px 0 10px;
  border-style: solid;
  border-color: #ccc transparent transparent transparent;
  z-index: -1;
}
