/* ═══════════════════════════════════════════════════════════════════════════
   SETTINGS PAGE / PROFILE EDITOR
   ═══════════════════════════════════════════════════════════════════════════ */

/* Settings Page - Full Screen Slide-in (legacy overlay mode) */
.settings-page {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 450px;
  background: linear-gradient(180deg, var(--surface-base) 0%, var(--surface-raised) 100%);
  z-index: 1100;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
  box-shadow: -5px 0 20px var(--surface-scrim);
}

.settings-page.visible {
  transform: translateX(0);
}

/* Settings View - Content Area Mode (rendered by ContentManager) */
#content-area .settings-view {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  background: linear-gradient(180deg, var(--surface-base) 0%, var(--surface-raised) 100%);
  min-height: 100dvh;
  transform: none;
  box-shadow: none;
  padding-bottom: 40px;
}

#content-area .settings-view .settings-page-header {
  position: sticky;
  top: 0;
  z-index: 10;
}

.settings-page-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface-sunken);
  z-index: 1099;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.settings-page-overlay.visible {
  opacity: 0;
  visibility: visible;
}

.settings-page-header {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 20px;
  background: var(--gradient-nav);
  border-bottom: 2px solid var(--color-accent-gold);
  position: sticky;
  top: 0;
  z-index: 10;
}

.settings-page-header h2 {
  margin: 0;
  color: var(--color-accent-gold);
  font-size: 1.4em;
  flex: 1;
}

.settings-page-header .close-btn {
  background: var(--surface-hover);
  border: none;
  color: var(--text-secondary);
  font-size: 1.2em;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.settings-page-header .close-btn:hover {
  background: var(--surface-active);
  color: var(--text-primary);
}

/* Settings Sections */
.settings-section {
  padding: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h3 {
  margin: 0 0 8px 0;
  color: var(--color-accent);
  font-size: 1.2em;
}

.settings-description {
  margin: 0 0 15px 0;
  color: var(--text-secondary);
  font-size: 0.9em;
  line-height: 1.4;
}

/* Settings Select Dropdown */
.settings-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 1em;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  box-sizing: border-box;
}

.settings-select:focus {
  outline: none;
  border-color: var(--color-accent);
}

.settings-select option {
  background: var(--surface-base);
  color: var(--text-primary);
}

/* Location Controls */
.settings-location-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.settings-location-method {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.settings-radio-label:hover {
  background: var(--surface-hover);
}

.settings-radio-label input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.settings-location-option {
  margin-top: 10px;
}

.settings-coords-inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-coords-inputs label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text-primary);
  font-size: 0.9em;
}

.settings-coord-input {
  padding: 8px 12px;
  font-size: 1em;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  color: var(--text-primary);
  box-sizing: border-box;
}

.settings-coord-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.settings-location-current {
  margin-top: 10px;
  padding-top: 15px;
  border-top: 1px solid var(--border-subtle);
}

.settings-current-value {
  margin: 0 0 10px 0;
  color: var(--text-primary);
  font-size: 0.9em;
}

/* Settings Buttons */
.settings-btn {
  padding: 10px 16px;
  font-size: 1em;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.settings-btn-secondary {
  background: var(--border-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.settings-btn-secondary:hover:not(:disabled) {
  background: var(--border-default);
}

.settings-btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.settings-btn-danger {
  background: rgba(220, 50, 50, 0.25);
  color: var(--color-error);
  border: 1px solid rgba(220, 50, 50, 0.4);
}

.settings-btn-danger:hover:not(:disabled) {
  background: rgba(220, 50, 50, 0.4);
}

.settings-btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Settings Map Container */
.settings-map-container {
  margin: 15px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

/* Theme Options */
.settings-theme-options {
  display: flex;
  gap: 15px;
}

.settings-note {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 0.9em;
  font-style: italic;
}

/* Profile Row */
.profile-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.profile-select {
  flex: 1;
  padding: 10px 12px;
  font-size: 1em;
  background: var(--surface-sunken);
  border: 1px solid var(--surface-highlight);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
}

.profile-select:focus {
  outline: none;
  border-color: var(--color-accent);
}

.profile-icon-btn {
  background: var(--border-subtle);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.profile-icon-btn:hover:not(:disabled) {
  background: var(--border-default);
}

.profile-icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Settings Options (button grid) */
.settings-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-option-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 15px 20px;
  background: var(--surface-hover);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  color: var(--text-primary);
  cursor: pointer;
  flex: 1;
  min-width: 90px;
  transition: all 0.2s;
}

.settings-option-btn:hover {
  background: var(--surface-active);
  border-color: var(--border-strong);
}

.settings-option-btn.selected {
  border-color: var(--accent-gold);
  background: var(--accent-gold-muted);
}

.settings-option-btn .option-icon {
  font-size: 2.5em;
}

/* Moon phase icons - extra large */
.settings-option-btn[data-phase] .option-icon {
  font-size: 3.5em;
}

.settings-option-btn .option-label {
  font-size: 0.85em;
  font-weight: 500;
}

.settings-option-btn .option-hint {
  font-size: 0.75em;
  opacity: 0.7;
  font-weight: normal;
  text-align: center;
}

/* Theme preview swatches — each button shows a preview of its theme */
.settings-option-btn[data-theme="auto"] {
  background: linear-gradient(135deg, #1a3a5c 50%, #f5f0e8 50%);
  border-color: #6a8aac;
  color: #ffffff;
}
.settings-option-btn[data-theme="auto"] .option-label {
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.settings-option-btn[data-theme="auto"]:hover {
  border-color: #7ec8e3;
}
.settings-option-btn[data-theme="auto"].selected {
  border-color: #d4a017;
  box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.3);
}

.settings-option-btn[data-theme="dark"] {
  background: #1a3a5c;
  border-color: #2a5a8c;
  color: #ffffff;
}
.settings-option-btn[data-theme="dark"]:hover {
  border-color: #7ec8e3;
}
.settings-option-btn[data-theme="dark"].selected {
  border-color: #d4a017;
  box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.3);
}

.settings-option-btn[data-theme="light"] {
  background: #f5f0e8;
  border-color: #ddd5c8;
  color: #2c2416;
}
.settings-option-btn[data-theme="light"]:hover {
  border-color: #1a6b7a;
}
.settings-option-btn[data-theme="light"].selected {
  border-color: #9e7510;
  box-shadow: 0 0 0 2px rgba(158, 117, 16, 0.3);
}

/* Disabled state for preset profiles */
.settings-section.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.settings-option-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.settings-option-btn:disabled:hover {
  background: var(--surface-hover);
}

/* Settings Expandable Details */
.settings-details {
  margin-top: 15px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--surface-hover);
}

.settings-details-toggle {
  cursor: pointer;
  padding: 12px 15px;
  color: var(--color-accent);
  font-size: 0.95em;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-details-toggle::-webkit-details-marker {
  display: none;
}

.settings-details-toggle::before {
  content: '▶';
  font-size: 0.7em;
  transition: transform 0.2s;
}

.settings-details[open] .settings-details-toggle::before {
  transform: rotate(90deg);
}

.settings-details-toggle:hover {
  color: var(--accent-primary-hover);
}

.settings-details-content {
  padding: 15px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.9em;
  line-height: 1.6;
}

.settings-details-content h4 {
  color: var(--color-accent);
  margin: 0 0 8px 0;
  font-size: 1em;
}

.settings-details-content h4:not(:first-child) {
  margin-top: 18px;
}

.settings-details-content p {
  margin: 0 0 10px 0;
}

.settings-details-content p:last-child {
  margin-bottom: 0;
}

/* Profile Name Modal */
.profile-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface-scrim);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.profile-modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.profile-modal {
  background: linear-gradient(135deg, var(--surface-base) 0%, var(--surface-raised) 100%);
  border: 1px solid var(--surface-highlight);
  border-radius: 12px;
  padding: 24px;
  min-width: 320px;
  max-width: 90%;
  box-shadow: 0 10px 40px var(--surface-scrim);
  transform: scale(0.9);
  transition: transform 0.2s;
}

.profile-modal-overlay.visible .profile-modal {
  transform: scale(1);
}

.profile-modal h3 {
  margin: 0 0 16px 0;
  color: var(--color-accent);
  font-size: 1.2em;
}

.profile-modal-input {
  width: 100%;
  padding: 12px 15px;
  font-size: 1.1em;
  background: var(--surface-sunken);
  border: 1px solid var(--surface-highlight);
  border-radius: 8px;
  color: var(--text-primary);
  margin-bottom: 8px;
  box-sizing: border-box;
}

.profile-modal-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.profile-modal-error {
  color: var(--color-error);
  font-size: 0.9em;
  margin-bottom: 12px;
  min-height: 1.2em;
}

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

.profile-modal-btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 1em;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
}

.profile-modal-btn.cancel {
  background: var(--border-subtle);
  color: var(--text-secondary);
}

.profile-modal-btn.cancel:hover {
  background: var(--border-default);
}

.profile-modal-btn.save {
  background: var(--surface-highlight);
  color: var(--text-primary);
}

.profile-modal-btn.save:hover {
  background: var(--surface-highlight);
}

/* Make profile display clickable */
.profile-display {
  cursor: pointer;
  transition: background 0.2s;
  border-radius: 6px;
  padding: 4px 8px;
}

.profile-display:hover {
  background: var(--border-subtle);
}

/* Settings Mobile Responsive */
@media (max-width: 500px) {
  .settings-page {
    max-width: 100%;
  }
  
  .settings-section {
    padding: 15px;
  }
  
  .settings-option-btn {
    min-width: 80px;
    padding: 12px 8px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TRANSLATION SORT LIST (Drag-and-Drop Priority)
   ═══════════════════════════════════════════════════════════════════════════ */

.translation-sort-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  user-select: none;
}

.translation-sort-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-hover);
  border: 1px solid var(--surface-hover);
  border-radius: 8px;
  cursor: default;
  transition: background 0.15s, opacity 0.15s, transform 0.15s;
  min-height: 44px;
}

.translation-sort-item:hover {
  background: var(--border-subtle);
}

.translation-sort-item.dragging {
  opacity: 0.4;
  transform: scale(0.97);
}

.ts-grip {
  color: var(--border-strong);
  font-size: 1.2em;
  flex-shrink: 0;
  cursor: grab;
  line-height: 1;
  /* Make a generous 44px touch target */
  padding: 8px 4px;
  margin: -8px -4px;
  touch-action: none;
}

.ts-grip:active {
  cursor: grabbing;
}

.ts-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95em;
  flex-shrink: 0;
  min-width: 40px;
}

.ts-fullname {
  color: var(--text-secondary);
  font-size: 0.8em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ts-year {
  color: var(--accent-primary);
  font-size: 0.7em;
  flex-shrink: 0;
}

.ts-badges {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.ts-badge {
  font-size: 0.65em;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.ts-badge-default {
  background: var(--accent-gold-muted);
  color: var(--accent-gold);
}

.ts-badge-strongs {
  background: var(--accent-primary-muted);
  color: var(--accent-primary);
}

/* Divider between visible and hidden */
.translation-sort-divider {
  display: flex;
  align-items: center;
  padding: 6px 0;
  margin: 4px 0;
}

.translation-sort-divider::before,
.translation-sort-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--accent-gold-muted);
}

.ts-divider-label {
  padding: 0 12px;
  font-size: 0.7em;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Second divider: "not loaded" tier — red/muted styling */
.ts-divider-noload::before,
.ts-divider-noload::after {
  background: rgba(200, 80, 80, 0.3);
}

.ts-divider-noload .ts-divider-label {
  color: #c85050;
}

/* Touch drag clone */
.ts-touch-clone {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.85;
  transform: scale(1.03);
  box-shadow: 0 4px 16px var(--shadow-lg);
  border-radius: 8px;
  background: rgba(30, 60, 90, 0.95);
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .ts-fullname {
    display: none;
  }
  
  .translation-sort-item {
    padding: 10px 8px;
    gap: 6px;
  }
}
