/* Reset & Grundlayout */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #f4f6f8;
}

/* Haupt-Präsentationsbühne (Screen Stage) */
.screen-stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  background-color: #ffffff;
  overflow: hidden;
  user-select: none;
  transition: background-color 0.3s ease;
}

/* --- DRAGGABLE ELEMENTE --- */
.draggable-element {
  position: absolute;
  cursor: grab;
  z-index: 10;
  transition: box-shadow 0.2s, outline 0.2s;
  touch-action: none;
}

.draggable-element:active {
  cursor: grabbing;
}

body.builder-active .draggable-element {
  outline: 2px dashed rgba(66, 153, 225, 0.6);
  outline-offset: 4px;
}

body.builder-active .draggable-element:hover {
  outline: 2px solid #3182ce;
}

.drag-handle {
  display: none;
  position: absolute;
  top: -14px;
  right: -14px;
  width: 28px;
  height: 28px;
  background: #3182ce;
  color: #fff;
  border-radius: 50%;
  font-size: 14px;
  font-weight: bold;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  cursor: grab;
  z-index: 20;
}

body.builder-active .drag-handle {
  display: flex;
}

/* --- COUNTDOWN STYLING --- */
.countdown-wrapper {
  background: #000000;
  color: #ffffff;
  padding: 12px 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
  min-width: 220px;
}

.countdown-digits {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.element-label-bottom {
  margin-top: 10px;
  font-size: 20px;
  font-weight: 500;
  color: #1a202c;
  padding-left: 2px;
}

/* --- SLIDESHOW STYLING --- */
.slideshow-label-top {
  font-size: 19px;
  font-weight: 500;
  color: #1a202c;
  margin-bottom: 8px;
}

.slideshow-wrapper {
  box-sizing: border-box;
  width: 450px;
  height: 270px;
  transition: width 0.8s ease-in-out, height 0.8s ease-in-out;
  background: #0f172a;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  border: 4px solid #ffffff;
  overflow: hidden;
  position: relative;
}

.slideshow-inner {
  width: 100%;
  height: 100%;
  position: relative;
}

.slide-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.8s ease-in-out, visibility 0.8s ease-in-out, transform 0.8s ease-in-out;
  transform: scale(0.98);
}

.slide-img.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
  transform: scale(1);
}

/* --- DEKORATION (UNTEN) --- */
.decoration-layer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 48vh;
  min-height: 280px;
  pointer-events: none;
  z-index: 1;
}

.decoration-layer svg,
.decoration-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: bottom center;
  display: block;
}

.decoration-label {
  position: absolute;
  right: 28%;
  bottom: 30%;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.35;
  color: #1a202c;
  z-index: 5;
  pointer-events: none;
}

/* --- PAGEBUILDER SIDEBAR --- */
.builder-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  height: 100vh;
  max-height: 100vh;
  max-height: 100dvh;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.builder-sidebar.collapsed {
  transform: translateX(100%);
}

.sidebar-header {
  padding: 16px 20px;
  background: #1a202c;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-title h2 {
  font-size: 18px;
  font-weight: 600;
}

.badge {
  font-size: 11px;
  background: #3182ce;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  font-weight: bold;
}

.sidebar-scrollable {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: #a0aec0 #edf2f7;
}

.sidebar-scrollable::-webkit-scrollbar {
  width: 8px;
}

.sidebar-scrollable::-webkit-scrollbar-track {
  background: #edf2f7;
}

.sidebar-scrollable::-webkit-scrollbar-thumb {
  background-color: #a0aec0;
  border-radius: 4px;
  border: 2px solid #edf2f7;
}

.sidebar-scrollable::-webkit-scrollbar-thumb:hover {
  background-color: #718096;
}

/* Wichtig: Verhindert, dass Flexbox die Sektionen auf kleinen Bildschirmen staucht */
.sidebar-scrollable > * {
  flex-shrink: 0;
}

/* Panels & Sektionen */
.panel-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.panel-section summary {
  padding: 12px 14px;
  font-weight: 600;
  font-size: 14px;
  background: #edf2f7;
  cursor: pointer;
  user-select: none;
}

.section-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quick-actions {
  padding: 14px;
}

/* Formulare & Eingaben */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-row label {
  font-size: 12px;
  font-weight: 600;
  color: #4a5568;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.input-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-inline input {
  flex: 1;
}

.color-pickers,
.color-pickers-3 {
  display: flex;
  gap: 12px;
}

.color-pickers > div,
.color-pickers-3 > div {
  flex: 1;
}

input[type="color"] {
  width: 100%;
  height: 36px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-block {
  width: 100%;
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-primary {
  background: #3182ce;
  color: #ffffff;
}
.btn-primary:hover {
  background: #2b6cb0;
}

.btn-success {
  background: #38a169;
  color: #ffffff;
}
.btn-success:hover {
  background: #2f855a;
}

.btn-secondary {
  background: #e2e8f0;
  color: #2d3748;
}
.btn-secondary:hover {
  background: #cbd5e0;
}

.btn-outline {
  background: transparent;
  border-color: #cbd5e0;
  color: #4a5568;
}
.btn-outline:hover {
  background: #edf2f7;
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-row > .btn {
  flex: 1;
}

.btn-icon {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
}

/* Bild-Thumbnails in Sidebar */
.thumbs-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.thumb-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #e2e8f0;
  background: #edf2f7;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  user-select: none;
}

.thumb-item:hover {
  border-color: #cbd5e0;
}

.thumb-item.active-slide {
  border-color: #3182ce;
  box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.4);
}

.thumb-item.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

.thumb-item.drag-over {
  border-color: #3182ce;
  background-color: #ebf8ff;
  transform: scale(1.02);
}

.thumb-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #2d3748;
  cursor: pointer;
}

.thumb-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  pointer-events: none;
}

.thumb-actions {
  display: flex;
  background: #f7fafc;
  border-top: 1px solid #e2e8f0;
}

.thumb-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 6px 0;
  font-size: 13px;
  font-weight: 600;
  color: #4a5568;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.thumb-btn:not(:last-child) {
  border-right: 1px solid #e2e8f0;
}

.thumb-btn:hover:not(:disabled) {
  background: #edf2f7;
  color: #1a202c;
}

.thumb-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.thumb-btn.thumb-del:hover:not(:disabled) {
  background: #fed7d7;
  color: #c53030;
}

/* Archiv-Bereich */
.archive-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-link {
  background: none;
  border: none;
  color: #3182ce;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: #2b6cb0;
}

.section-hint {
  font-size: 11px;
  color: #718096;
  line-height: 1.35;
  margin-top: 2px;
  margin-bottom: 4px;
}

.thumbs-list.archive-list {
  background: #f1f5f9;
  padding: 8px;
  border-radius: 8px;
  border: 1px dashed #cbd5e0;
  max-height: 280px;
  overflow-y: auto;
}

.archive-thumb-item {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #cbd5e0;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.archive-thumb-del {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(229, 62, 62, 0.9);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  z-index: 5;
  transition: background 0.15s, transform 0.15s;
}

.archive-thumb-del:hover {
  background: #c53030;
  transform: scale(1.1);
}

.archive-thumb-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #2d3748;
}

.archive-thumb-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.archive-thumb-caption {
  font-size: 10px;
  color: #4a5568;
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #fff;
}

.btn-add-from-archive {
  width: 100%;
  padding: 5px 4px;
  background: #3182ce;
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-add-from-archive:hover:not(:disabled) {
  background: #2b6cb0;
}

.btn-add-from-archive.already-added {
  background: #e2e8f0;
  color: #718096;
  cursor: default;
}

/* Floating Buttons */
.btn-floating-builder {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  background: #1a202c;
  color: #ffffff;
  border-radius: 30px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  z-index: 999;
  display: none;
}

body:not(.builder-active) .btn-floating-builder {
  display: block;
}

/* Fullscreen / Präsentationsmodus Anpassungen */
body:not(.builder-active) .builder-sidebar {
  display: none;
}

body:not(.builder-active) .draggable-element {
  cursor: default;
}

.presentation-hint {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.presentation-hint.show {
  opacity: 1;
}

.presentation-hint kbd {
  background: #4a5568;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}

.screens-ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.screens-ul li {
  padding: 8px 10px;
  background: #edf2f7;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.screen-del {
  border: none;
  background: #e53e3e;
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}
.screen-del:hover { background: #c53030; }

.screens-ul li:hover {
  background: #e2e8f0;
}

.ss-resize { display: none; }
body.builder-active .ss-resize {
  display: block;
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: #3182ce;
  border: 2px solid #fff;
  border-radius: 3px;
  cursor: nwse-resize;
  z-index: 20;
}
.slideshow-wrapper.resizing { transition: none; }

/* --- TEXTFELDER --- */
.textbox {
  box-sizing: border-box;
  cursor: grab;
  word-wrap: break-word;
  user-select: none;
}

.textbox .tb-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
  line-height: 1.3;
}

.textbox .tb-content h1,
.textbox .tb-content h2,
.textbox .tb-content h3,
.textbox .tb-content p,
.textbox .tb-content ul,
.textbox .tb-content ol { margin: 0 0 0.4em; }
.textbox .tb-content h1 { font-size: 2em; }
.textbox .tb-content h2 { font-size: 1.5em; }
.textbox .tb-content h3 { font-size: 1.2em; }
.textbox .tb-content ul,
.textbox .tb-content ol { padding-left: 1.4em; }

.textbox.locked { cursor: default; }
body.builder-active .textbox.selected { outline: 2px solid #f59e0b !important; }

.tb-badge,
.tb-resize { display: none; }

body.builder-active .textbox.hide-presentation { opacity: 0.55; }
body.builder-active .textbox.hide-presentation .tb-badge {
  display: block;
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  background: #744210;
  color: #fff;
  font: 11px/1 sans-serif;
  padding: 3px 6px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
}

body.builder-active .textbox:not(.locked) .tb-resize {
  display: block;
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: #3182ce;
  border: 2px solid #fff;
  border-radius: 3px;
  cursor: nwse-resize;
  z-index: 20;
}

body:not(.builder-active) .textbox.hide-presentation { display: none; }

.tb-list { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.tb-list-item {
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-list-item.active { border-color: #f59e0b; background: #fffbeb; font-weight: 600; }

.tb-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  padding: 6px;
  background: #edf2f7;
  border: 1px solid #cbd5e0;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}
.tb-toolbar button {
  min-width: 28px;
  height: 28px;
  border: 1px solid #cbd5e0;
  background: #fff;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
}
.tb-toolbar button:hover { background: #e2e8f0; }
.tb-toolbar select { height: 28px; font-size: 12px; max-width: 110px; }
.tb-toolbar input[type="color"] { width: 28px; height: 28px; padding: 0; border: 1px solid #cbd5e0; }
.tb-sep { width: 1px; height: 20px; background: #cbd5e0; margin: 0 2px; }

.tb-editor {
  min-height: 110px;
  max-height: 260px;
  overflow-y: auto;
  padding: 10px;
  background: #fff;
  color: #1a202c;
  border: 1px solid #cbd5e0;
  border-radius: 0 0 4px 4px;
  user-select: text;
  -webkit-user-select: text;
  outline: none;
  margin-bottom: 10px;
}
.tb-editor:focus { border-color: #3182ce; }

.tb-check { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 6px 0; }

.btn-danger { background: #e53e3e; color: #fff; }
.btn-danger:hover { background: #c53030; }
