/* ==========================================================================
   TypeRush — Settings Panel & Custom Theme Builder Styles
   Matches MonkeyType dark, monospace, minimalist aesthetic
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Slide-in Drawer Foundation
   -------------------------------------------------------------------------- */
.tr-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.tr-drawer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.tr-settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 540px;
  max-width: 100vw;
  background: #1c1e22;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.6);
  z-index: 1110;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-family, 'JetBrains Mono', monospace);
  color: var(--text-color, #d1d0c5);
}

.tr-settings-drawer.active {
  transform: translateX(0);
}

/* Header */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.drawer-header-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.drawer-header-title i {
  color: var(--main-color, #e2b714);
  font-size: 1.25rem;
}

.drawer-header-title h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color, #d1d0c5);
  margin: 0;
}

.drawer-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Search Bar */
.drawer-search-wrapper {
  position: relative;
  padding: 0.85rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.drawer-search-wrapper .search-icon {
  position: absolute;
  left: 2.35rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sub-color, #646669);
  font-size: 0.9rem;
  pointer-events: none;
}

.drawer-search-input {
  width: 100%;
  padding: 0.65rem 2.25rem 0.65rem 2.5rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--text-color, #d1d0c5);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.drawer-search-input:focus {
  border-color: var(--main-color, #e2b714);
  background: rgba(255, 255, 255, 0.07);
}

.search-clear-btn {
  position: absolute;
  right: 2.25rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--sub-color, #646669);
  cursor: pointer;
  font-size: 0.95rem;
}

.search-clear-btn:hover {
  color: var(--text-color, #d1d0c5);
}

/* Category Quick Jump Pills */
.drawer-category-nav {
  display: flex;
  gap: 0.4rem;
  padding: 0.65rem 1.5rem;
  overflow-x: auto;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.drawer-category-nav::-webkit-scrollbar {
  height: 4px;
}

.drawer-category-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  color: var(--sub-color, #646669);
  font-size: 0.75rem;
  text-decoration: none;
  transition: all 0.2s ease;
}

.cat-pill:hover {
  color: var(--text-color, #d1d0c5);
  border-color: var(--main-color, #e2b714);
  background: rgba(226, 183, 20, 0.08);
}

/* Content Area */
.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.drawer-content::-webkit-scrollbar {
  width: 6px;
}

.drawer-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
}

/* Section Group */
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.group-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--main-color, #e2b714);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Setting Card Item */
.setting-item {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem 1.15rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.setting-item:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.setting-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-color, #d1d0c5);
}

.setting-desc {
  font-size: 0.75rem;
  color: var(--sub-color, #646669);
  line-height: 1.35;
}

/* Option Buttons Group */
.setting-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.opt-btn {
  padding: 0.35rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--sub-color, #646669);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.opt-btn:hover {
  color: var(--text-color, #d1d0c5);
  border-color: rgba(255, 255, 255, 0.2);
}

.opt-btn.active {
  background: var(--main-color, #e2b714);
  color: var(--bg-color, #323437);
  border-color: var(--main-color, #e2b714);
  font-weight: 600;
}

.font-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  width: 100%;
}

.font-pill {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

/* Sliders */
.slider-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.tr-range {
  flex: 1;
  accent-color: var(--main-color, #e2b714);
  cursor: pointer;
}

.range-val-badge {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--main-color, #e2b714);
  min-width: 45px;
  text-align: right;
}

/* --------------------------------------------------------------------------
   2. Theme Switcher Section & Swatches Grid
   -------------------------------------------------------------------------- */
.theme-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.theme-search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.theme-count-tag {
  font-size: 0.75rem;
  color: var(--sub-color, #646669);
  white-space: nowrap;
}

.themes-swatch-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.themes-swatch-grid::-webkit-scrollbar {
  width: 5px;
}

.themes-swatch-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.theme-swatch-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-swatch-card:hover {
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.theme-swatch-card.active {
  border-color: var(--main-color, #e2b714);
  background: rgba(226, 183, 20, 0.08);
}

.swatch-colors {
  display: flex;
  gap: 3px;
  margin-right: 0.5rem;
}

.swatch-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.3);
}

.swatch-info {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
}

.swatch-name {
  font-size: 0.75rem;
  color: var(--text-color, #d1d0c5);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  text-transform: capitalize;
}

.btn-fav-theme {
  background: transparent;
  border: none;
  color: var(--sub-color, #646669);
  cursor: pointer;
  padding: 0 0.2rem;
  font-size: 0.75rem;
  transition: color 0.15s ease;
}

.btn-fav-theme:hover,
.theme-swatch-card.is-fav .btn-fav-theme {
  color: #ffd700;
}

/* --------------------------------------------------------------------------
   3. Custom Theme Builder Modal
   -------------------------------------------------------------------------- */
.tr-theme-builder-card {
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
}

.theme-builder-preview-wrapper {
  background: var(--bg-color, #323437);
  border: 1px solid var(--sub-alt-color, #2c2e31);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  transition: all 0.15s ease;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--sub-color, #646669);
  margin-bottom: 0.75rem;
}

.preview-theme-title {
  color: var(--main-color, #e2b714);
  font-weight: 600;
}

.preview-typing-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.35rem;
  line-height: 1.4;
  user-select: none;
}

.preview-word {
  display: inline-flex;
}

.preview-letter.correct {
  color: var(--text-color, #d1d0c5);
}

.preview-letter.incorrect {
  color: var(--error-color, #ca4754);
}

.preview-letter.extra {
  color: var(--error-extra-color, #7e2a33);
}

.preview-letter.untyped {
  color: var(--sub-color, #646669);
}

.preview-caret {
  width: 2px;
  height: 1.4rem;
  background: var(--caret-color, #e2b714);
  animation: previewCaretBlink 1s infinite;
}

@keyframes previewCaretBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Presets Bar */
.theme-builder-presets {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.presets-label {
  font-size: 0.8rem;
  color: var(--sub-color, #646669);
}

.presets-list {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.preset-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--text-color, #d1d0c5);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip-btn:hover {
  border-color: var(--main-color, #e2b714);
}

.preset-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Color Pickers Grid */
.theme-colors-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.color-picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
}

.color-picker-label {
  display: flex;
  flex-direction: column;
}

.tok-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-color, #d1d0c5);
}

.tok-key {
  font-size: 0.7rem;
  color: var(--sub-color, #646669);
}

.color-picker-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.color-wheel-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.color-wheel-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-wheel-input::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

.color-hex-input {
  width: 72px;
  padding: 0.25rem 0.4rem;
  font-size: 0.78rem;
  font-family: inherit;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: var(--text-color, #d1d0c5);
  text-align: center;
}

/* Actions */
.theme-builder-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 1.25rem;
}

.actions-left,
.actions-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Floating Toast Notification */
.tr-toast-notification {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #23272a;
  color: var(--main-color, #e2b714);
  border: 1px solid rgba(226, 183, 20, 0.4);
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font-family, monospace);
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}

.tr-toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 640px) {
  .tr-settings-drawer {
    width: 100vw;
  }
  .theme-colors-grid {
    grid-template-columns: 1fr;
  }
  .themes-swatch-grid {
    grid-template-columns: 1fr;
  }
  .font-options-grid {
    grid-template-columns: 1fr;
  }
}
