/* Settings button */
.settings-button {
  position: fixed;
  top: 20px;
  right: 20px;
  background: transparent;
  color: #f4f4f5;
  border: none;
  width: 42px;
  height: 42px;
  cursor: pointer;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.settings-button:hover {
  opacity: 0.7;
}

.settings-button svg {
  width: 26px;
  height: 26px;
}

/* Fullscreen button at side of setting icon */
.fullscreen-button {
  position: fixed;
  top: 20px;
  right: 68px;
  background: transparent;
  color: #f4f4f5;
  border: none;
  width: 42px;
  height: 42px;
  cursor: pointer;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.fullscreen-button:hover {
  opacity: 0.7;
}

.fullscreen-button svg {
  width: 24px;
  height: 24px;
}

/* Settings panel */
.settings-panel {
  position: fixed;
  top: 72px;
  right: 20px;
  background: #18181b;
  border-radius: 12px;
  padding: 16px;
  color: #e4e4e7;
  z-index: 10000;
  width: 360px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  display: none;
  scroll-behavior: smooth;
  border: 1px solid #27272a;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13.5px;
}

.settings-panel.visible {
  display: block;
}

/* Custom Scrollbar */
.settings-panel::-webkit-scrollbar {
  width: 6px;
}
.settings-panel::-webkit-scrollbar-track {
  background: #18181b;
}
.settings-panel::-webkit-scrollbar-thumb {
  background: #27272a;
  border-radius: 3px;
}
.settings-panel::-webkit-scrollbar-thumb:hover {
  background: #3f3f46;
}

/* Settings search */
.settings-search-container {
  position: sticky;
  top: -16px;
  margin: -16px -16px 14px -16px;
  padding: 14px 16px;
  background: #18181b;
  z-index: 10;
  border-bottom: 1px solid #27272a;
  display: flex;
  align-items: center;
}

.settings-search-input {
  width: 100%;
  padding: 8px 32px 8px 12px;
  background: #09090b;
  border: 1px solid #27272a;
  border-radius: 6px;
  color: #f4f4f5;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}

.settings-search-input:focus {
  border-color: #3b82f6;
}

.settings-search-input::placeholder {
  color: #71717a;
}

.settings-search-container .search-icon {
  position: absolute;
  right: 26px;
  color: #71717a;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Settings main menu */
.settings-main-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-category-label {
  margin-top: 12px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #a1a1aa;
  padding: 0 4px;
}

.settings-category-label:first-child {
  margin-top: 0;
}

.settings-menu-item {
  padding: 9px 12px;
  background: #18181b;
  border-radius: 6px;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  border: 1px solid transparent;
  color: #d4d4d8;
  user-select: none;
}

.settings-menu-item:hover {
  background: #27272a;
  color: #ffffff;
}

.settings-menu-item:active {
  background: #3f3f46;
}

.settings-menu-item .icon {
  margin-right: 10px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  flex-shrink: 0;
}

.settings-menu-item:hover .icon {
  color: #60a5fa;
}

.settings-menu-item span[data-ui-key],
.settings-menu-item span:not(.icon):not(.chevron) {
  font-size: 13.5px;
  font-weight: 500;
  flex-grow: 1;
}

.settings-menu-item .chevron {
  margin-left: auto;
  color: #71717a;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.settings-menu-item:hover .chevron {
  color: #e4e4e7;
}

/* Flattened Search View */
.settings-panel.searching .settings-main-menu {
  display: none !important;
}

.settings-panel.searching .settings-submenu {
  display: block !important;
  padding: 0;
  border-bottom: none;
}

.settings-panel.searching .submenu-header {
  display: none !important;
}

.settings-panel.searching .settings-item {
  display: none !important;
}

.settings-panel.searching .settings-item.search-match {
  display: block !important;
  padding: 10px 12px;
  background: #27272a;
  border-radius: 6px;
  margin-bottom: 6px;
  border: 1px solid #3f3f46;
}

.settings-panel.searching .settings-submenu::before {
  content: attr(data-category-name);
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: #3b82f6;
  letter-spacing: 0.05em;
  margin: 12px 0 6px 0;
  padding-left: 2px;
}

.settings-panel.searching .settings-submenu:not(:has(.search-match)) {
  display: none !important;
}

.no-results {
  text-align: center;
  padding: 32px 16px;
  color: #71717a;
  font-size: 13px;
}

/* Settings submenus */
.settings-submenu {
  display: none;
}

.settings-submenu.active {
  display: block;
}

.submenu-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #27272a;
}

.submenu-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #f4f4f5;
  letter-spacing: -0.01em;
}

.back-button {
  background: #27272a;
  border: 1px solid #3f3f46;
  color: #d4d4d8;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.back-button:hover {
  background: #3f3f46;
  color: #ffffff;
}

/* Settings items */
.settings-item {
  margin-bottom: 14px;
}

.provider-section {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #27272a;
}

.provider-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.provider-section-header {
  margin: 0 0 10px;
}

.provider-section-header h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #a1a1aa;
}

.settings-item label {
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  color: #e4e4e7;
  margin-bottom: 6px;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
}

.settings-item input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: #27272a;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.settings-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  background: #3b82f6;
  border-radius: 50%;
  border: 2px solid #18181b;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.settings-item input[type="range"]::-webkit-slider-thumb:hover {
  background: #60a5fa;
  transform: scale(1.1);
}

.settings-item input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  background: #3b82f6;
  border-radius: 50%;
  border: 2px solid #18181b;
  cursor: pointer;
}

.settings-item input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  margin-right: 10px;
  width: 16px;
  height: 16px;
  border: 1px solid #3f3f46;
  border-radius: 4px;
  background: #09090b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.settings-item input[type="checkbox"]:hover {
  border-color: #71717a;
}

.settings-item input[type="checkbox"]:checked {
  background: #2563eb;
  border-color: #3b82f6;
}

.settings-item input[type="checkbox"]:checked::after {
  content: '';
  width: 4px;
  height: 8px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

select.settings-select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px !important;
}

.settings-item .settings-select,
.settings-item .settings-textarea,
.settings-item input[type="text"],
.settings-item input[type="new-password"] {
  width: 100%;
  padding: 8px 11px;
  background: #09090b;
  color: #f4f4f5;
  border: 1px solid #27272a;
  border-radius: 6px;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}

.settings-item .settings-select:focus,
.settings-item .settings-textarea:focus,
.settings-item input:focus {
  border-color: #3b82f6;
  box-shadow: none;
}

.settings-item .settings-textarea {
  height: 90px;
  resize: vertical;
  margin-bottom: 6px;
  line-height: 1.45;
}

.settings-item button,
.settings-action-btn,
.model-action-btn {
  background: #27272a;
  color: #f4f4f5;
  border: 1px solid #3f3f46;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.settings-item button:hover,
.settings-action-btn:hover,
.model-action-btn:hover {
  background: #3f3f46;
  border-color: #52525b;
}

.settings-item button:active {
  background: #52525b;
}

.value-display {
  font-size: 11.5px;
  color: #71717a;
  margin-top: 4px;
  line-height: 1.35;
}

/* Hide small description paragraphs and helper texts under settings options */
.value-display[data-ui-desc],
.settings-item .value-display:not(:has(span)),
.settings-panel .description,
.settings-panel small {
  display: none !important;
}

.button-row {
  display: flex;
  gap: 8px;
}

.button-row button {
  flex: 1;
}

.reset-button {
  background: #27272a !important;
  border-color: #3f3f46 !important;
  color: #a1a1aa !important;
}

.reset-button:hover {
  background: #3f3f46 !important;
  color: #ffffff !important;
}

/* Links in settings */
.links-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.link-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: #d4d4d8;
  background: #09090b;
  border: 1px solid #27272a;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  font-size: 13px;
  font-weight: 500;
}

.link-item:hover {
  background: #27272a;
  border-color: #3f3f46;
  color: #ffffff;
}

.link-icon {
  display: none;
}

.link-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hide old separate containers */
.radio-container,
.model-selector-container,
.language-display-settings-container {
  display: none !important;
}

/* Model selector styles */
.settings-panel .model-selector-selected {
  background: #09090b;
  border: 1px solid #27272a;
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease;
  display: flex;
  align-items: center;
}

.settings-panel .model-selector-selected:hover {
  border-color: #3f3f46;
}

.settings-panel .model-selector-selected-img {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 50%;
  margin-right: 8px;
  border: 1px solid #3f3f46;
}

.settings-panel .model-selector-selected-name {
  flex-grow: 1;
  color: #f4f4f5;
  font-size: 13px;
}

.settings-panel .model-selector-arrow {
  margin-left: 8px;
  color: #71717a;
  transition: transform 0.2s ease;
  font-size: 11px;
}

.settings-panel .model-selector-selected.open .model-selector-arrow {
  transform: rotate(180deg);
}

.settings-panel .model-selector-dropdown {
  position: absolute;
  left: 16px;
  right: 16px;
  background: #18181b;
  border: 1px solid #27272a;
  border-radius: 6px;
  max-height: 160px;
  overflow-y: auto;
  z-index: 10001;
  display: none;
  list-style: none;
  padding: 4px;
  margin: 4px 0 0 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.settings-panel .model-selector-dropdown li {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  border-radius: 4px;
}

.settings-panel .model-selector-dropdown li:hover {
  background: #27272a;
}

.settings-panel .model-selector-option-img {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 50%;
  margin-right: 8px;
  border: 1px solid #3f3f46;
}

.settings-panel .model-selector-dropdown li span {
  color: #f4f4f5;
  font-size: 13px;
}

/* Custom model info */
#customModelInfo .custom-model-info {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #09090b;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #27272a;
}

#customModelInfo img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #3f3f46;
}

#customModelInfo .meta {
  flex: 1;
  min-width: 0;
}

#customModelInfo .meta .name {
  color: #f4f4f5;
  font-size: 13px;
  font-weight: 500;
}

#customModelInfo .meta .url {
  color: #60a5fa;
  font-size: 11px;
  word-break: break-all;
}

#customModelInfo .remove-btn {
  background: #dc2626;
  border: none;
  color: #ffffff;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
}

#customModelInfo .remove-btn:hover {
  background: #b91c1c;
}

/* Radio controls */
.radio-controls-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #09090b;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #27272a;
}

.radio-controls-inline .radio-toggle-button {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.radio-controls-inline .radio-icon {
  width: 14px;
  height: 14px;
}

.volume-control-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-grow: 1;
}

.volume-control-inline .volume-icon {
  width: 15px;
  height: 15px;
  color: #71717a;
  flex-shrink: 0;
}

.volume-control-inline #radioVolumeSlider {
  flex-grow: 1;
  height: 4px;
  min-width: 70px;
}

.volume-icon {
  width: 18px;
  height: 18px;
  color: #71717a;
}

#radioVolumeSlider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: #27272a;
  outline: none;
  border-radius: 2px;
  cursor: pointer;
}

#radioVolumeSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
}

#radioVolumeSlider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
}

/* Character gallery hero card */
.model-gallery-hero-card {
  background: #09090b;
  border: 1px solid #27272a;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}

.hero-card-content {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.hero-card-icon {
  color: #a1a1aa;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #18181b;
  border: 1px solid #27272a;
  border-radius: 6px;
}

.hero-card-text h4 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: #f4f4f5;
}

.hero-card-text p {
  display: none !important;
}

.model-gallery-open-btn {
  width: 100%;
  background: #27272a !important;
  color: #f4f4f5 !important;
  border: 1px solid #3f3f46 !important;
  border-radius: 6px !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  transition: background-color 0.15s ease, border-color 0.15s ease !important;
  box-shadow: none !important;
}

.model-gallery-open-btn:hover {
  background: #3f3f46 !important;
  border-color: #52525b !important;
}

/* Background fit group */
.bg-fit-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bg-fit-group button {
  background: #09090b;
  color: #d4d4d8;
  border: 1px solid #27272a;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
}

.bg-fit-group button:hover {
  background: #27272a;
}

.bg-fit-group button.active {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
}
