/* ================================================================
   UIM Theme Engine — Panel Styles
   Foundation layer: /_content/UMM.Foundation/css/theme-engine.css
   All colors are hardcoded — panel must NOT theme itself.
   ================================================================ */

/* Container */
.uim-theme-engine {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 100vw;
  height: 100vh;
  overflow-y: auto;
  background: #1a1a2e;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  z-index: 10000;
  box-shadow: -4px 0 24px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

/* On mobile, full width */
@media (max-width: 480px) {
  .uim-theme-engine {
    width: 100vw;
  }
}

/* Header */
.uim-te__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #2a2a4a;
  flex-shrink: 0;
}

.uim-te__title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #888;
}

.uim-te__close {
  background: none;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.uim-te__close:hover {
  color: #e0e0e0;
  background: #2a2a4a;
}

/* Presets Row */
.uim-te__presets {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid #2a2a4a;
  flex-shrink: 0;
}

.uim-te__preset-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #16213e;
  border: 1px solid #2a2a4a;
  color: #888;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.uim-te__preset-btn:hover,
.uim-te__preset-btn--active {
  border-color: #7c3aed;
  color: #e0e0e0;
}

.uim-te__preset-btn--active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}

/* Tabs */
.uim-te__tabs {
  display: flex;
  border-bottom: 1px solid #2a2a4a;
  flex-shrink: 0;
}

.uim-te__tab {
  flex: 1;
  padding: 8px 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #888;
  cursor: pointer;
  transition: all 0.2s;
}

.uim-te__tab:hover {
  color: #e0e0e0;
}

.uim-te__tab--active {
  color: #7c3aed;
  border-bottom-color: #7c3aed;
}

/* Tab Content Area */
.uim-te__content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.uim-te__panel,
.uim-te__tab-panel {
  display: none;
}

.uim-te__panel--active,
.uim-te__tab-panel--active {
  display: block;
}

/* Section Labels */
.uim-te__section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 8px;
  margin-top: 16px;
}

.uim-te__section-label:first-child {
  margin-top: 0;
}

/* Color Picker */
.uim-te__color-group {
  margin-bottom: 16px;
}

.uim-te__color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.uim-te__color-input {
  width: 32px;
  height: 32px;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
  background: none;
}

.uim-te__color-input::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.uim-te__color-input::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.uim-te__color-hex {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: #e0e0e0;
  background: #16213e;
  border: 1px solid #2a2a4a;
  padding: 4px 8px;
  border-radius: 4px;
  width: 80px;
  text-align: center;
}

.uim-te__color-label {
  font-size: 12px;
  color: #888;
  flex: 1;
}

/* Scale Preview Strip */
.uim-te__scale-strip {
  display: flex;
  height: 12px;
  border-radius: 2px;
  overflow: hidden;
}

.uim-te__scale-swatch {
  flex: 1;
}

/* Range Slider */
.uim-te__slider-group {
  margin-bottom: 14px;
}

.uim-te__slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.uim-te__slider-label {
  font-size: 12px;
  color: #e0e0e0;
}

.uim-te__slider-value {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: #7c3aed;
}

.uim-te__slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #2a2a4a;
  border-radius: 2px;
  outline: none;
}

.uim-te__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #7c3aed;
  cursor: pointer;
  border: 2px solid #1a1a2e;
}

.uim-te__slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #7c3aed;
  cursor: pointer;
  border: 2px solid #1a1a2e;
}

/* Button Group (for Shape tab) */
.uim-te__btn-group {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}

.uim-te__btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 500;
  background: #16213e;
  border: 1px solid #2a2a4a;
  color: #888;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  text-align: center;
}

.uim-te__btn:hover {
  border-color: #7c3aed;
  color: #e0e0e0;
}

.uim-te__btn--active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}

/* Font Picker */
.uim-te__font-picker {
  margin-bottom: 16px;
}

.uim-te__font-search {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  background: #16213e;
  border: 1px solid #2a2a4a;
  color: #e0e0e0;
  border-radius: 4px;
  outline: none;
  margin-bottom: 6px;
}

.uim-te__font-search:focus {
  border-color: #7c3aed;
}

.uim-te__font-search::placeholder {
  color: #666;
}

.uim-te__font-categories {
  display: flex;
  gap: 3px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.uim-te__font-cat-btn {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 500;
  background: #16213e;
  border: 1px solid #2a2a4a;
  color: #888;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

.uim-te__font-cat-btn:hover {
  color: #e0e0e0;
}

.uim-te__font-cat-btn--active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}

.uim-te__font-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  background: #16213e;
}

.uim-te__font-list::-webkit-scrollbar {
  width: 6px;
}

.uim-te__font-list::-webkit-scrollbar-track {
  background: #16213e;
}

.uim-te__font-list::-webkit-scrollbar-thumb {
  background: #2a2a4a;
  border-radius: 3px;
}

.uim-te__font-item {
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
  color: #e0e0e0;
  border-bottom: 1px solid #1a1a2e;
}

.uim-te__font-item:last-child {
  border-bottom: none;
}

.uim-te__font-item:hover {
  background: #2a2a4a;
}

.uim-te__font-item--active {
  background: rgba(124, 58, 237, 0.15);
  color: #c4b5fd;
}

.uim-te__font-preview {
  margin-top: 8px;
  padding: 10px;
  background: #16213e;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1.4;
  color: #e0e0e0;
  min-height: 48px;
}

.uim-te__font-count {
  font-size: 10px;
  color: #666;
  text-align: right;
  margin-top: 4px;
}

/* Mode Toggle (bottom bar) */
.uim-te__mode {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
  border-top: 1px solid #2a2a4a;
  flex-shrink: 0;
}

.uim-te__mode-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #16213e;
  border: 1px solid #2a2a4a;
  color: #888;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  text-align: center;
}

.uim-te__mode-btn:hover {
  border-color: #7c3aed;
  color: #e0e0e0;
}

.uim-te__mode-btn--active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}

/* Actions */
.uim-te__actions {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid #2a2a4a;
  flex-shrink: 0;
}

.uim-te__action-btn {
  flex: 1;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #16213e;
  border: 1px solid #2a2a4a;
  color: #888;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  text-align: center;
}

.uim-te__action-btn:hover {
  border-color: #7c3aed;
  color: #e0e0e0;
}

.uim-te__action-btn--danger:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* Toast Notification */
.uim-te__toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #1a1a2e;
  color: #e0e0e0;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  border: 1px solid #2a2a4a;
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.uim-te__toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Scrollbar for main content */
.uim-te__content::-webkit-scrollbar {
  width: 6px;
}

.uim-te__content::-webkit-scrollbar-track {
  background: #1a1a2e;
}

.uim-te__content::-webkit-scrollbar-thumb {
  background: #2a2a4a;
  border-radius: 3px;
}

/* ================================================================
   Additional rules matching the JS panel HTML structure
   ================================================================ */

/* Color header row */
.uim-te__color-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

/* Scale preview (strip variant) */
.uim-te__scale-preview {
  display: flex;
  height: 12px;
  border-radius: 2px;
  overflow: hidden;
  gap: 1px;
}

/* Slider row layout */
.uim-te__slider-row {
  margin-bottom: 14px;
}

/* Button group layout */
.uim-te__button-group {
  margin-bottom: 14px;
}

.uim-te__button-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 6px;
}

.uim-te__button-row {
  display: flex;
  gap: 4px;
}

/* Option buttons (shape tab) */
.uim-te__option-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 500;
  background: #16213e;
  border: 1px solid #2a2a4a;
  color: #888;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  text-align: center;
}

.uim-te__option-btn:hover {
  border-color: #7c3aed;
  color: #e0e0e0;
}

.uim-te__option-btn--active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}

/* Font picker label */
.uim-te__font-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 6px;
}

/* Mode Selector (top of panel) */
.uim-te__mode-selector {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid #2a2a4a;
  flex-shrink: 0;
}

/* Save Button */
.uim-te__action-btn--save {
  background: #16213e;
  border-color: #7c3aed;
  color: #c4b5fd;
}

.uim-te__action-btn--save:hover {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}

/* ================================================================
   Map Tab — Swatch Grid & Controls
   ================================================================ */

/* Map header with alias selector + current value */
.uim-te__map-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.uim-te__map-alias-select {
  flex: 1;
  padding: 6px 8px;
  font-size: 12px;
  background: #16213e;
  border: 1px solid #2a2a4a;
  color: #e0e0e0;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.uim-te__map-alias-select:focus {
  border-color: #7c3aed;
}

.uim-te__map-current {
  display: flex;
  align-items: center;
  gap: 6px;
}

.uim-te__map-current-swatch {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid #2a2a4a;
}

.uim-te__map-current-value {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: #888;
  min-width: 80px;
}

/* Swatch Grid */
.uim-te__swatch-grid {
  margin-bottom: 12px;
}

.uim-te__swatch-row {
  display: flex;
  gap: 2px;
  margin-bottom: 2px;
}

.uim-te__swatch-row--header {
  margin-bottom: 4px;
}

.uim-te__swatch-step-label {
  width: 30px;
  font-size: 9px;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 4px;
  flex-shrink: 0;
}

.uim-te__swatch-col-label {
  flex: 1;
  font-size: 9px;
  font-weight: 600;
  color: #666;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.uim-te__swatch-cell {
  flex: 1;
  height: 24px;
  border-radius: 2px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
  position: relative;
}

.uim-te__swatch-cell:hover {
  border-color: #e0e0e0;
  transform: scale(1.1);
  z-index: 1;
}

.uim-te__swatch-cell--selected {
  border-color: #7c3aed;
  box-shadow: 0 0 0 1px #7c3aed;
}

.uim-te__swatch-cell--assigned::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e0e0e0;
  border: 1px solid rgba(0, 0, 0, 0.3);
}

/* Map controls (opacity + literal hex) */
.uim-te__map-controls {
  margin-top: 8px;
}

.uim-te__map-literal {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.uim-te__map-literal .uim-te__color-label {
  flex: 0 0 auto;
  font-size: 11px;
}

.uim-te__map-literal .uim-te__color-hex {
  flex: 1;
  width: auto;
}

.uim-te__map-literal .uim-te__option-btn {
  flex: 0 0 auto;
  padding: 4px 10px;
}

/* Hide in print */
@media print {
  .uim-theme-engine,
  .uim-te__toast {
    display: none !important;
  }
}
