/* =========================================================
 Categories Helper - Page Specific Styles
 (Base styles are in /public/categories-helper-shared.css)
 ========================================================= */

ol {
  padding-left: 20px;
}

ol li {
  margin-bottom: 1rem;
  line-height: 1.4;
}

ol li p {
  margin: 0.1rem 0;
}

.controls {
  margin-bottom: 20px;
}

.controls .fetch-btn {
  width: 120px;
}

.puzzle-info {
  text-align: center;
  color: #555;
  font-weight: 500;
  margin-bottom: 15px;
}

button {
  margin-top: 10px;
  margin-right: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background-color: #f0f0f0;
  border: 1px solid #ccc;
}

button:hover {
  background-color: #e0e0e0;
}

button.fetch-btn {
  background-color: #e8b86d;
  border: 1px solid #d6a65d;
}

button.fetch-btn:hover {
  background-color: #d6a65d;
}

.grid-container {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  flex: 1;
}

.lock-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 0;
}

.lock-row {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lock-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.lock-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
}

/* ---------------- Tiles ---------------- */

.word-tile {
  background-color: var(--row-color);
  border-radius: 10px;
  padding: 20px 10px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
  cursor: grab;
  position: relative;
  overflow: hidden;

  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;

  border: 2px solid transparent;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

  transition:
    background-color 0.25s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border 0.15s ease;
}

.word-tile.locked {
  cursor: not-allowed;
  opacity: 0.8;
}

/* Mobile optimization: Reduce horizontal padding to prevent text clipping on small screens */
@media (max-width: 480px) {
  .word-tile {
    padding: 20px 4px; /* Reduced from 10px to 4px horizontal padding */
  }
}

/* Tablet optimization: Slightly reduce padding for medium screens */
@media (min-width: 481px) and (max-width: 650px) {
  .word-tile {
    padding: 20px 6px; /* Reduced from 10px to 6px horizontal padding */
  }
}

.word-tile-text {
  position: relative;
  z-index: 2;
  pointer-events: none;
  word-break: break-word; /* Allow long words to wrap if needed */
  overflow-wrap: break-word; /* Additional browser compatibility */
  max-width: 100%; /* Ensure text doesn't exceed tile width */
}

/* Quadrant backgrounds for color marking */
.word-tile-colors {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.quadrant {
  background-color: transparent;
}

.word-tile.dragging {
  opacity: 0.35;
  cursor: grabbing;
}

.word-tile.drag-over {
  border: 2px dashed #666;
}

/* ---------------- Ghost ---------------- */

.drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.05);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  opacity: 0.95;
}

/* ---------------- Color Picker ---------------- */

.color-picker {
  margin-top: 20px;
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 15px;
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  border: 4px solid transparent;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.color-circle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.color-circle.active {
  border: 4px solid #333;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.color-circle.yellow {
  background-color: #f9df6d;
}

.color-circle.green {
  background-color: #a0c35a;
}

.color-circle.blue {
  background-color: #b0c4ef;
}

.color-circle.purple {
  background-color: #ba81c5;
}

.clear-colors-btn {
  background-color: #ff6b6b;
  border: 1px solid #e05555;
  color: white;
}

.clear-colors-btn:hover {
  background-color: #e05555;
}

/* ---------------- Instructions ---------------- */

.instructions-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  margin-bottom: 10px;
  cursor: pointer;
  color: #666;
}

.instructions-control input[type="checkbox"] {
  cursor: pointer;
}

.controls-row-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  margin-bottom: 10px;
}

.controls-row-inline .instructions-control {
  margin: 0;
}

.tile-mode-control {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #666;
}

.tile-mode-label {
  font-size: 14px;
}

.tile-mode-option {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.tile-mode-option input[type="radio"] {
  cursor: pointer;
}

.instructions-toggle,
.sources-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: #666;
  user-select: none;
}

.instructions-toggle {
  margin-top: 20px;
  margin-bottom: 10px;
}

.instructions-toggle:hover,
.sources-toggle:hover {
  color: #333;
}

.save-preferences-link {
  cursor: pointer;
  color: #666;
  font-size: 14px;
  user-select: none;
  margin-left: auto;
}

.save-preferences-link:hover {
  color: #333;
  text-decoration: underline;
}

/* ---------------- Site List ---------------- */

.site-list {
  margin: 20px 0;
  padding: 0;
}

.site-item {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #ddd;
}

.site-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.site-title {
  display: block;
  font-size: 1.4em;
  font-weight: 600;
  color: #0066cc;
  text-decoration: none;
  margin-bottom: 8px;
}

.site-title:hover {
  text-decoration: underline;
}

.site-description {
  color: #555;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.toggle-arrow {
  font-size: 12px;
  transition: transform 0.2s ease;
}

.instructions-toggle.collapsed .toggle-arrow,
.sources-toggle.collapsed .toggle-arrow {
  transform: rotate(-90deg);
}

.new-version-banner {
  font-size: 1.5em;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
}

.instructions-section {
  text-align: left;
  color: #666;
  transition: all 0.3s ease;
}

.instructions-section.hidden {
  display: none;
}

/* ---------------- Modal ---------------- */

.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: white;
  padding: 30px;
  border-radius: 10px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
  margin-bottom: 15px;
}

.modal-content textarea {
  width: 100%;
  height: 300px;
  padding: 10px;
  font-family: monospace;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
  margin-bottom: 15px;
}

.modal-content p {
  margin-bottom: 15px;
  line-height: 1.5;
}

.modal-checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  cursor: pointer;
}

.modal-checkbox-group input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-buttons .primary-btn {
  background-color: #e8b86d;
  border: 1px solid #d6a65d;
}

.modal-buttons .primary-btn:hover {
  background-color: #d6a65d;
}

.pref-controls {
  margin: 15px 0;
}

.pref-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.pref-row:last-child {
  border-bottom: none;
}

.pref-label {
  color: #666;
  margin-right: 12px;
}

.pref-options {
  display: flex;
  gap: 12px;
}

.pref-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #333;
}

.pref-checkbox input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.pref-select {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  color: #333;
  background-color: #fff;
  cursor: pointer;
  min-width: 180px;
}

.pref-select:focus {
  outline: none;
  border-color: #666;
}

/* ---------------- Error Message ---------------- */

.error-message {
  background-color: #fee;
  border: 1px solid #c00;
  padding: 10px;
  margin-bottom: 20px;
  border-radius: 5px;
  color: #c00;
}

/* ---------------- Controls Layout ---------------- */

.controls-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.spacer {
  flex: 1;
}

.source-select-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.source-label {
  font-size: 14px;
  color: #666;
  margin-bottom: 4px;
}

.source-select {
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #ccc;
}

.form-inline {
  display: contents;
}

.form-archive {
  display: flex;
  flex-direction: column;
  width: 120px;
}

.date-input {
  width: 120px;
  padding: 6px 8px;
  font-size: 14px;
  border: 1px solid #ccc;
  margin-bottom: 4px;
}

.fetch-btn.no-margin-top {
  margin-top: 0;
}

/* ---------------- Instructions Styling ---------------- */

.instructions-section h3 {
  padding-bottom: 10px;
}

.instructions-section ol ol {
  list-style-type: lower-alpha;
}

.text-bold {
  font-weight: bold;
}

.text-bold-dark {
  font-weight: bold;
  color: black;
}

/* ---------------- Modal Intro ---------------- */

.modal-intro {
  margin-bottom: 10px;
  color: #666;
}

/* ---------------- Utility ---------------- */

.hidden {
  display: none;
}
