/* =========================================================
   MODEX Labs — Dashboard
   ========================================================= */

.dashboard-shell{
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

/* --- Wasser-Szene: gestaffelte Wellen am oberen Rand --- */
.water-scene{
  position: absolute;
  inset: 0 0 auto 0;
  height: 360px;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.water-scene .wave{
  position: absolute;
  left: -10%;
  width: 120%;
  height: 220px;
  border-radius: 44%;
  background: linear-gradient(180deg, var(--pool) 0%, var(--deep-end) 100%);
  opacity: .14;
  animation: drift 16s ease-in-out infinite;
}
.water-scene .wave.two{
  top: 70px;
  height: 260px;
  opacity: .1;
  animation-duration: 22s;
  animation-direction: reverse;
}
.water-scene .wave.three{
  top: 150px;
  height: 240px;
  opacity: .08;
  animation-duration: 28s;
}
body[data-theme="dark"] .water-scene .wave{
  background: linear-gradient(180deg, var(--lane) 0%, transparent 100%);
  opacity: .06;
}
body[data-theme="dark"] .water-scene .wave.two{ opacity: .045; }
body[data-theme="dark"] .water-scene .wave.three{ opacity: .035; }

@keyframes drift{
  0%,100%{ transform: translateX(0) translateY(0) rotate(0deg); }
  50%{ transform: translateX(3%) translateY(-8px) rotate(1.2deg); }
}

.dashboard-content{
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 3rem) clamp(1rem, 4vw, 2.6rem) 4rem;
}

/* --- Hero --- */
.hero{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding-bottom: 1.6rem;
  margin-bottom: 1.8rem;
}

.brand-block{
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.brand-mark{
  width: 58px;
  height: 58px;
  flex: none;
  border-radius: 16px;
  background: linear-gradient(155deg, var(--pool), var(--deep-end));
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}
.brand-mark span{
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.8rem;
  color: #fff;
}

.brand-copy .eyebrow{
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--pool);
  margin: 0 0 .25rem;
  font-weight: 600;
}
body[data-theme="dark"] .brand-copy .eyebrow{ color: var(--lane); }

.brand-copy h1{
  font-size: clamp(2.1rem, 5vw, 3.1rem);
  line-height: .95;
  margin-bottom: .4rem;
}

.brand-copy .hero-copy{
  font-size: 1rem;
  max-width: 46ch;
  margin: 0;
}

.hero-actions{ flex: none; padding-top: .2rem; }

/* Bahnseile sitzen direkt an den einzelnen Modulen. */
.hero::after{ content: none; }
.dashboard-content > .hero + .modules{ margin-top: 0; }

/* --- Modul-Bahnen --- */
.modules{
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  position: relative;
}

@media (max-width: 880px){
  .modules{ grid-template-columns: 1fr; }
  .hero{ flex-direction: column; }
}

.module{
  --rope-step: 14px;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.module::after,
.module:first-child::before{
  content: "";
  height: 6px;
  border-radius: 999px;
  background: repeating-linear-gradient(
    90deg,
    var(--lane) 0 var(--rope-step),
    var(--pool) var(--rope-step) calc(var(--rope-step) * 2)
  );
  opacity: .9;
}

body[data-theme="dark"] .module::after,
body[data-theme="dark"] .module:first-child::before{
  background: repeating-linear-gradient(
    90deg,
    var(--lane) 0 var(--rope-step),
    var(--pool-dim) var(--rope-step) calc(var(--rope-step) * 2)
  );
}

.module-header{
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  padding: clamp(.75rem, 2vw, 1.05rem) .15rem;
}

.module-title-group{
  display: flex;
  align-items: center;
  gap: .85rem;
  min-width: 0;
}

/* "Bahn 1 / Bahn 2" — echte Bahnnummer statt generischer 01/02-Marker */
.module-tag{
  flex: none;
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent);
  padding: .3rem .55rem;
  border-radius: var(--radius-sm);
  line-height: 1.3;
}

.module-title-group h2{
  font-size: clamp(1.25rem, 2.1vw, 1.55rem);
  margin-bottom: .2rem;
}
.module-title-group p{
  font-size: .9rem;
  margin: 0;
  max-width: 62ch;
}
.module-title-group > div{
  min-width: 0;
}

.module-link{
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--pool);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 42px;
  padding: .55rem .95rem;
  background: var(--surface);
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.module-link:hover{
  background: var(--bg-alt);
  border-color: var(--border-strong);
  transform: translateX(2px);
}
body[data-theme="dark"] .module-link{ color: var(--lane); }

@media (max-width: 620px){
  .module-header{
    grid-template-columns: 1fr;
    align-items: start;
    gap: .75rem;
  }

  .module-title-group{
    align-items: flex-start;
  }

  .module-link{
    width: 100%;
  }
}

.plan-link{
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .7rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--pool);
  text-decoration: none;
  font-size: .85rem;
}
.plan-link:hover{
  background: var(--surface);
}

.saved-page{
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 3rem) clamp(1rem, 4vw, 2.6rem) 4rem;
}

.saved-actions{
  display: flex;
  flex-wrap: wrap;
  gap: .8rem;
  margin-bottom: 1.4rem;
}

.archive-status{
  margin: -.6rem 0 1.2rem;
  font-size: .86rem;
  color: var(--ink-soft);
}
.archive-status[data-mode="file"]{
  color: var(--ok);
}

.saved-list{
  display: grid;
  grid-template-columns: 1fr;
  gap: .9rem;
}

@media (max-width: 860px){
  .saved-list{ grid-template-columns: 1fr; }
}

.plan-card{
  --archive-rope-step: 10px;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.plan-card::after,
.plan-card:first-child::before{
  content: "";
  height: 3px;
  border-radius: 999px;
  background: repeating-linear-gradient(
    90deg,
    var(--lane) 0 var(--archive-rope-step),
    var(--pool) var(--archive-rope-step) calc(var(--archive-rope-step) * 2)
  );
  opacity: .8;
}

body[data-theme="dark"] .plan-card::after,
body[data-theme="dark"] .plan-card:first-child::before{
  background: repeating-linear-gradient(
    90deg,
    var(--lane) 0 var(--archive-rope-step),
    var(--pool-dim) var(--archive-rope-step) calc(var(--archive-rope-step) * 2)
  );
}

.plan-card-head{
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.2rem;
  align-items: center;
  padding: .85rem .15rem;
}

.plan-card-copy{
  min-width: 0;
}

.plan-card-head h2{
  margin: 0 0 .55rem;
  font-size: clamp(1.1rem, 1.8vw, 1.35rem);
}

.plan-facts{
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: .65rem 1rem;
  margin: 0;
}
.plan-facts div{
  min-width: 0;
}
.plan-facts dt{
  font-family: var(--font-mono);
  font-size: .66rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.plan-facts dd{
  margin: .1rem 0 0;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 600;
}

.plan-card-actions{
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  justify-content: flex-end;
}

.plan-card-actions .plan-delete{
  padding: .45rem .7rem;
  font-size: .85rem;
  color: var(--flag);
}

@media (max-width: 760px){
  .plan-card-head{
    grid-template-columns: 1fr;
    align-items: start;
    gap: .75rem;
  }

  .plan-facts{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .plan-card-actions{
    justify-content: flex-start;
  }
}

@media (max-width: 460px){
  .plan-facts{
    grid-template-columns: 1fr;
  }
}

.empty-state-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  color: var(--ink-soft);
  grid-column: 1 / -1;
}

/* =========================================================
   Dashboard anpassen: Module wählen und sortieren
   ========================================================= */
.hero-actions{ flex-wrap: wrap; justify-content: flex-end; }
.dash-edit{
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 600;
  min-height: 40px;
  padding: .5rem .95rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.dash-edit:hover{ background: var(--bg-alt); border-color: var(--border-strong); }
.dash-edit[aria-pressed="true"]{ background: var(--lane); color: var(--lane-ink); border-color: var(--lane); }

.dash-bar{ min-height: 0; }
.dash-note{ margin: -.6rem 0 1rem; font-size: .88rem; color: var(--ink-soft); }
.dash-note:empty{ display: none; }
.dash-inline{
  font: inherit; font-weight: 700; color: var(--pool); background: none; border: 0; padding: 0;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
body[data-theme="dark"] .dash-inline{ color: var(--lane); }

/* Griff und Ausblenden nur im Bearbeiten-Modus */
.mod-handle, .mod-remove{ display: none; }
.dash-editing .mod-handle{
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 44px; margin-left: -.2rem;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-soft);
  cursor: grab; touch-action: none;
}
.dash-editing .mod-handle:hover{ color: var(--ink); border-style: solid; }
.dash-editing .mod-handle:focus-visible{ outline: 3px solid var(--lane); outline-offset: 2px; }
.dash-dragging, .dash-dragging *{ cursor: grabbing !important; user-select: none; }
.dash-editing .module-link{ display: none; }
.dash-editing .mod-remove{
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: .76rem; font-weight: 600;
  min-height: 40px; padding: .5rem .9rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--flag); cursor: pointer; white-space: nowrap;
}
.dash-editing .mod-remove:hover{ border-color: var(--flag); }
.dash-editing .module{ border-radius: var(--radius); }
.dash-editing .module-header{ padding-left: .4rem; padding-right: .4rem; }

.module.is-dragging{
  position: relative; z-index: 5;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  transition: none !important;
}
.module.is-dragging::before, .module.is-dragging::after{ opacity: 0 !important; }
.module.just-added .module-header{ animation: dashFlash 1.2s ease; }
@keyframes dashFlash{ 0%{ background: color-mix(in srgb, var(--lane) 45%, transparent); } 100%{ background: transparent; } }

.dash-empty{
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 2rem 1.4rem;
  text-align: center;
  color: var(--ink-soft);
}

/* Ablage für ausgeblendete Module */
.dash-tray{
  margin-top: 2rem;
  padding: 1.3rem 1.4rem 1.4rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.dash-tray[hidden]{ display: none; }
.dash-tray h2{ font-size: 1.3rem; margin: 0 0 .25rem; }
.dash-tray-hint{ margin: 0 0 .9rem; font-size: .88rem; color: var(--ink-soft); }
.dash-tray-list{ display: flex; flex-wrap: wrap; gap: .55rem; }
.dash-chip{
  display: inline-flex; align-items: center; gap: .45rem;
  font: inherit; font-size: .92rem; font-weight: 600;
  min-height: 42px; padding: .5rem .95rem;
  border-radius: 999px; border: 1px dashed var(--border-strong);
  background: var(--bg-alt); color: var(--ink); cursor: pointer;
}
.dash-chip:hover{ border-style: solid; border-color: var(--pool); }
.dash-chip svg{ color: var(--pool); }
body[data-theme="dark"] .dash-chip svg{ color: var(--lane); }
.dash-tray-actions{ margin-top: 1.1rem; }

.sr-only{ position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.dash-editing .mod-remove{ gap: .4rem; }
@media (max-width: 620px){
  .dash-editing .module-header{ grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .6rem; }
  .dash-editing .module-title-group{ align-items: center; gap: .6rem; }
  .dash-editing .module-title-group p,
  .dash-editing .module-tag{ display: none; }
  .dash-editing .module-title-group h2{ font-size: 1.1rem; margin: 0; overflow-wrap: anywhere; }
  .dash-editing .mod-remove{ width: 44px; height: 44px; padding: 0; }
  .dash-editing .mod-remove-txt{ position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
@media (prefers-reduced-motion: reduce){
  .module, .module.just-added .module-header{ transition: none !important; animation: none !important; }
}
