/* ============================================================
   Tweaks Panel — visuelle Design-Kontrolle über die Live-Seite
   Kompletter Editor als Overlay rechts. Immer sichtbarer FAB-Button.
   ============================================================ */

/* Floating Action Button — Immer sichtbar unten rechts */
.tw-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #17163F;
  color: #FAF7F1;
  border: 2px solid #FF5F1E;
  border-radius: 999px;
  font-family: "Fira Sans", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tw-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(255, 95, 30, 0.45);
}

/* Main Panel */
.tw-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  bottom: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  z-index: 9999;
  background: #FAF7F1;
  border: 1px solid rgba(34, 33, 101, 0.20);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  font-family: "Fira Sans", sans-serif;
  color: #1A1A22;
  overflow: hidden;
  animation: tw-slide-in 0.3s cubic-bezier(.22,.61,.36,1);
}
@keyframes tw-slide-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Header */
.tw-head {
  padding: 18px 20px 14px;
  background: #17163F;
  color: #FAF7F1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.tw-head-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}
.tw-head-sub {
  font-size: 11px;
  color: rgba(220, 219, 237, 0.7);
  margin: 4px 0 0;
  letter-spacing: 0.02em;
}
.tw-close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: rgba(220, 219, 237, 0.15);
  color: #FAF7F1;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.tw-close:hover { background: #FF5F1E; color: #17163F; }

/* Tabs */
.tw-tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  background: #17163F;
  border-bottom: 1px solid rgba(220, 219, 237, 0.15);
}
.tw-tab {
  padding: 10px 4px;
  border: 0;
  background: transparent;
  color: rgba(220, 219, 237, 0.65);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
  border-bottom: 2px solid transparent;
}
.tw-tab:hover { color: #FAF7F1; background: rgba(255, 255, 255, 0.04); }
.tw-tab.active {
  color: #FF5F1E;
  background: #FAF7F1;
  border-bottom-color: #FF5F1E;
}

/* Body (Scroll) */
.tw-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  background: #FAF7F1;
  scrollbar-width: thin;
  scrollbar-color: rgba(34, 33, 101, 0.3) transparent;
}
.tw-body::-webkit-scrollbar { width: 6px; }
.tw-body::-webkit-scrollbar-thumb { background: rgba(34, 33, 101, 0.25); border-radius: 3px; }

/* Section */
.tw-section {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(34, 33, 101, 0.10);
}
.tw-section:last-child { border-bottom: 0; }
.tw-section-head { margin: 0 0 12px; }
.tw-section-head h4 {
  font-size: 13px;
  font-weight: 700;
  color: #222165;
  margin: 0 0 3px;
  letter-spacing: -0.005em;
}
.tw-section-head p {
  font-size: 11px;
  color: #7A7A82;
  margin: 0;
  line-height: 1.4;
}

/* Field-Basis */
.tw-field {
  margin-bottom: 12px;
}
.tw-field:last-child { margin-bottom: 0; }
.tw-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #4A4A55;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.tw-field-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.tw-field-row label { margin-bottom: 0; }
.tw-field-val {
  font-size: 11px;
  color: #FF5F1E;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 95, 30, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Slider */
.tw-field input[type="range"] {
  width: 100%;
  height: 22px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.tw-field input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: rgba(34, 33, 101, 0.15);
  border-radius: 2px;
}
.tw-field input[type="range"]::-moz-range-track {
  height: 4px;
  background: rgba(34, 33, 101, 0.15);
  border-radius: 2px;
}
.tw-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #FF5F1E;
  border: 2px solid #FAF7F1;
  border-radius: 50%;
  cursor: pointer;
  margin-top: -7px;
  box-shadow: 0 2px 6px rgba(255, 95, 30, 0.4);
  transition: transform 0.15s ease, background 0.15s ease;
}
.tw-field input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.15); background: #E04D0E; }
.tw-field input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #FF5F1E;
  border: 2px solid #FAF7F1;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(255, 95, 30, 0.4);
}

/* Text/Textarea/Select */
.tw-field input[type="text"],
.tw-field textarea,
.tw-field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(34, 33, 101, 0.20);
  border-radius: 6px;
  background: #FFFFFF;
  color: #1A1A22;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tw-field input[type="text"]:focus,
.tw-field textarea:focus,
.tw-field select:focus {
  border-color: #FF5F1E;
  box-shadow: 0 0 0 3px rgba(255, 95, 30, 0.12);
}
.tw-field textarea {
  resize: vertical;
  min-height: 44px;
  font-family: inherit;
  line-height: 1.4;
}
.tw-field select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23222165' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* Color */
.tw-color-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tw-color-row input[type="color"] {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(34, 33, 101, 0.20);
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
  background: #FFFFFF;
}
.tw-color-hex {
  flex: 1;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace !important;
  font-size: 12px !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Palette Grid */
.tw-palettes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tw-palette {
  padding: 8px;
  background: #FFFFFF;
  border: 2px solid rgba(34, 33, 101, 0.10);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  font-family: inherit;
}
.tw-palette:hover { border-color: rgba(34, 33, 101, 0.30); transform: translateY(-1px); }
.tw-palette.active {
  border-color: #FF5F1E;
  box-shadow: 0 4px 12px rgba(255, 95, 30, 0.15);
}
.tw-palette-swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  height: 32px;
  border-radius: 4px;
  overflow: hidden;
}
.tw-palette-swatches span { display: block; height: 100%; }
.tw-palette-name {
  font-size: 11px;
  font-weight: 600;
  color: #222165;
  letter-spacing: -0.005em;
}

/* Toggle */
.tw-field--toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  margin-bottom: 4px;
}
.tw-field--toggle label { margin-bottom: 0; font-size: 12px; color: #1A1A22; }
.tw-toggle {
  width: 40px;
  height: 22px;
  background: rgba(34, 33, 101, 0.15);
  border: 0;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  padding: 0;
  flex-shrink: 0;
}
.tw-toggle.on { background: #FF5F1E; }
.tw-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #FFFFFF;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(.22,.61,.36,1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.tw-toggle.on .tw-toggle-thumb { transform: translateX(18px); }

/* Footer */
.tw-foot {
  padding: 12px 20px;
  background: #EFEAE0;
  border-top: 1px solid rgba(34, 33, 101, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tw-reset {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid rgba(34, 33, 101, 0.25);
  border-radius: 6px;
  color: #222165;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tw-reset:hover { background: #222165; color: #FAF7F1; border-color: #222165; }
.tw-hint {
  font-size: 10px;
  color: #7A7A82;
  letter-spacing: 0.02em;
  text-align: right;
}

/* Mobile */
@media (max-width: 640px) {
  .tw-panel { top: 12px; right: 12px; left: 12px; bottom: 12px; width: auto; }
  .tw-tabs { grid-template-columns: repeat(3, 1fr); }
  .tw-tab { padding: 8px 4px; font-size: 9px; }
}

/* Print und Screenshots blenden das Panel aus */
@media print {
  .tw-fab, .tw-panel { display: none !important; }
}
