﻿/* =============================================
   MODULE SYSTEM
   ============================================= */

/* â”€â”€ Modules Panel (Full-Screen, wie OBS-Panel) â”€â”€ */
#modules-panel {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-0);
  z-index: 150;
  flex-direction: column;
  overflow: hidden;
}
#modules-panel.open { display: flex; }

#modules-panel-header,
#modules-editor-header {
  flex: 0 0 var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

#modules-list-page,
#modules-editor-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

#modules-panel-body,
#modules-editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 40px;
}

.modules-hint {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
  margin-bottom: 16px;
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
}

/* â”€â”€ Modul-Karten â”€â”€ */
#module-list { display: flex; flex-direction: column; gap: 8px; }

.module-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.module-card-active {
  border-color: var(--purple);
  background: color-mix(in srgb, var(--purple) 8%, var(--bg-2));
}
.module-card-icon {
  font-size: 22px;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}
.module-card-info { flex: 1; min-width: 0; }
.module-card-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.module-card-desc {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}
.module-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.module-activate-btn { white-space: nowrap; }
.module-active-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--purple);
  background: color-mix(in srgb, var(--purple) 15%, var(--bg-0));
  padding: 3px 8px;
  border-radius: 20px;
}
.module-card-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  opacity: 0.6;
  transition: opacity 0.15s;
}
.module-card-icon-btn:hover { opacity: 1; }

/* â”€â”€ Editor â”€â”€ */
.module-name-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 14px;
}
.module-name-input:focus { outline: none; border-color: var(--purple); }

.module-icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.module-icon-opt {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.module-icon-opt.active  { border-color: var(--purple); background: color-mix(in srgb, var(--purple) 15%, var(--bg-2)); }
.module-icon-opt:hover   { border-color: var(--text-3); }

/* Layout-Picker */
.module-layout-row { display: flex; gap: 10px; }
.module-layout-opt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  transition: border-color 0.15s, background 0.15s;
}
.module-layout-opt.active {
  border-color: var(--purple);
  background: color-mix(in srgb, var(--purple) 12%, var(--bg-2));
  color: var(--purple);
}
.module-layout-preview {
  width: 52px; height: 44px;
  border-radius: 6px;
  border: 1.5px solid currentColor;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 3px;
}
.module-layout-split > div { flex: 1; background: currentColor; border-radius: 3px; opacity: 0.35; }
.module-layout-single > div { flex: 1; background: currentColor; border-radius: 3px; opacity: 0.35; }

/* Block-Picker */
.module-slots { display: flex; flex-direction: column; gap: 14px; }
.module-slot  { display: flex; flex-direction: column; gap: 6px; }
.module-slot-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.module-block-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.module-block-opt {
  padding: 7px 12px;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.module-block-opt.active {
  border-color: var(--purple);
  background: color-mix(in srgb, var(--purple) 15%, var(--bg-2));
  color: var(--purple);
}
.module-block-opt:hover { border-color: var(--text-3); }

/* â”€â”€ Dynamische Dashboard-BlÃ¶cke â”€â”€ */
.module-dyn-block {
  display: flex;
  flex-direction: column;
  overflow: hidden;          /* kein horizontales Herausragen */
  min-width: 0;              /* Flex-Kind darf unter Inhalt schrumpfen */
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-1);
}
.module-block-hdr {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  background: var(--bg-2);
  min-width: 0;
}
#module-obs-body,
#module-preview-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  min-width: 0;
  box-sizing: border-box;
}
.module-block-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  padding: 32px 16px;
  gap: 4px;
}
.module-preview-img {
  width: 100%;
  border-radius: var(--radius-sm);
  display: block;
}

/* â”€â”€ Quick-Picker (Bottom-Sheet) â”€â”€ */
#module-quick-picker {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 600;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  max-height: 60vh;
  display: flex;
  flex-direction: column;
}
#module-quick-picker.open { transform: translateY(0); }

.module-quick-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#module-quick-list {
  overflow-y: auto;
  padding: 8px 0 env(safe-area-inset-bottom, 8px);
}
.module-quick-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--text-1);
  font-size: 14px;
  transition: background 0.1s;
}
.module-quick-row:hover   { background: var(--bg-2); }
.module-quick-row.active  { color: var(--purple); }
.module-quick-icon        { font-size: 20px; width: 28px; text-align: center; }
.module-quick-name        { flex: 1; font-weight: 600; }
.module-quick-check       { font-size: 16px; color: var(--purple); font-weight: 800; }

/* â”€â”€ Stream-Stats Block â”€â”€ */
#module-stats-body {
  padding: 12px; display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto; overflow-x: hidden; flex: 1; min-width: 0; box-sizing: border-box;
}
.mstat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr));
  gap: 10px;
  width: 100%;
}
.mstat-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 14px 8px;
  background: var(--bg-2); border-radius: var(--radius); border: 1px solid var(--border);
  min-width: 0;
}
.mstat-icon  { font-size: 20px; }
.mstat-val   { font-size: 22px; font-weight: 800; color: var(--text-1); line-height: 1; min-width: 0; }
.mstat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); font-weight: 700; text-align: center; }
.mstat-info  { display: flex; flex-direction: column; gap: 6px; width: 100%; min-width: 0; }
.mstat-row   {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px;
  background: var(--bg-2); border-radius: var(--radius-sm);
  min-width: 0; overflow: hidden;
}
.mstat-info-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); font-weight: 700; }
.mstat-info-val   { font-size: 13px; color: var(--text-1); font-weight: 600; word-break: break-word; overflow-wrap: anywhere; }

/* â”€â”€ Mod-Tools Block â”€â”€ */
#module-modtools-body {
  padding: 10px 12px; overflow-y: auto; overflow-x: hidden;
  flex: 1; display: flex; flex-direction: column; gap: 2px;
  min-width: 0; box-sizing: border-box;
}
.modtool-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  min-width: 0;
}
.modtool-row:last-child { border-bottom: none; }
.modtool-info  { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.modtool-name  { font-size: 13px; font-weight: 700; color: var(--text-1); }
.modtool-desc  { font-size: 11px; color: var(--text-3); }
.modtool-speed-row {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 6px 0 12px; border-bottom: 1px solid var(--border);
  min-width: 0;
}
.modtool-speed-btn {
  flex: 1 1 auto;               /* gleichmÃ¤ÃŸig verteilen, umbrechen wenn nÃ¶tig */
  min-width: 52px;
  padding: 8px 10px; border-radius: 20px; font-size: 12px; font-weight: 700;
  text-align: center;
  background: var(--bg-2); border: 1.5px solid var(--border); color: var(--text-2); cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s, background 0.15s;
}
.modtool-speed-btn.active {
  border-color: var(--purple);
  background: color-mix(in srgb, var(--purple) 15%, var(--bg-2));
  color: var(--purple);
}

/* â”€â”€ Clips Block â”€â”€ */
#module-clips-body { flex: 1; overflow-y: auto; overflow-x: hidden; min-width: 0; }
#mclips-list { display: flex; flex-direction: column; gap: 1px; }
.mclip-card {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px; text-decoration: none; color: var(--text-1);
  background: var(--bg-1); border-bottom: 1px solid var(--border);
  min-width: 0; overflow: hidden;
  transition: background 0.1s;
}
.mclip-card:active { background: var(--bg-2); }
.mclip-thumb {
  width: 64px; height: 36px; object-fit: cover; border-radius: 4px; flex-shrink: 0;
}
.mclip-nothumb {
  width: 64px; height: 36px; border-radius: 4px; background: var(--bg-3);
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.mclip-info  { flex: 1; min-width: 0; overflow: hidden; }
.mclip-title {
  font-size: 12px; font-weight: 700; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mclip-meta  { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* â”€â”€ Notes Block â”€â”€ */
#module-notes-body { flex: 1; display: flex; overflow: hidden; min-width: 0; }
.module-notes-textarea {
  flex: 1; width: 100%; min-width: 0; resize: none; border: none; outline: none;
  background: var(--bg-1); color: var(--text-1);
  font-size: 13px; line-height: 1.55; padding: 12px;
  font-family: inherit; box-sizing: border-box;
}
.notes-saved-hint {
  font-size: 11px; color: var(--teal); font-weight: 600;
  margin-left: auto; opacity: 0.85;
}

/* â”€â”€ Notizen Quick-Panel Overlay â”€â”€ */
.notes-qp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.notes-qp-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.notes-qp-card {
  width: 100%;
  max-width: 600px;
  background: var(--bg-1);
  border-radius: var(--radius) var(--radius) 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: 72vh;
  transform: translateY(40px);
  transition: transform .22s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.notes-qp-overlay.open .notes-qp-card {
  transform: translateY(0);
}
.notes-qp-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notes-qp-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  flex: 1;
}
.notes-qp-counter {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
  background: var(--bg-2);
  border-radius: 10px;
  padding: 2px 8px;
  flex-shrink: 0;
}
.notes-qp-textarea {
  flex: 1;
  width: 100%;
  min-height: 160px;
  max-height: 50vh;
  resize: none;
  border: none;
  outline: none;
  background: var(--bg-1);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.6;
  padding: 12px 16px;
  font-family: inherit;
  overflow-y: auto;
}
.notes-qp-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}
.notes-qp-saved-hint {
  font-size: 11px;
  color: var(--teal);
  font-weight: 600;
  opacity: 0;
  transition: opacity .3s;
  flex: 1;
}

/* â”€â”€ Notizen Manager Overlay â”€â”€ */
.notes-manager-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1300;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.notes-manager-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.notes-manager-card {
  width: 100%;
  max-width: 600px;
  background: var(--bg-1);
  border-radius: var(--radius) var(--radius) 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  transform: translateY(40px);
  transition: transform .22s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.notes-manager-overlay.open .notes-manager-card {
  transform: translateY(0);
}
.notes-manager-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notes-manager-title {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}
.notes-manager-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.notes-manager-empty {
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
  padding: 24px 0;
}
.notes-mgr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 10px;
  transition: border-color .15s;
}
.notes-mgr-row.notes-mgr-active {
  border-color: var(--purple);
  background: color-mix(in srgb, var(--purple) 8%, var(--bg-2));
}
.notes-mgr-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  cursor: pointer;
}
.notes-mgr-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notes-mgr-date {
  font-size: 11px;
  color: var(--text-3);
}
.notes-mgr-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.notes-mgr-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: background .15s, color .15s;
}
.notes-mgr-btn:hover:not(:disabled) { background: var(--bg-1); color: var(--text-1); }
.notes-mgr-btn:active:not(:disabled) { transform: scale(0.88); }
.notes-mgr-btn:disabled { opacity: 0.25; pointer-events: none; }
.notes-mgr-del:hover { background: color-mix(in srgb,#e74c3c 14%,var(--bg-2)) !important; color: #e74c3c !important; border-color: #e74c3c !important; }

