/* TV-Wall Webinterface - bewusst ohne externe Abhaengigkeiten, da der Pi als
   Access Point keine Internetverbindung hat. */

:root {
  --bg: #0d1117;
  --bg-card: #161c26;
  --bg-soft: #1e2632;
  --line: #2a3442;
  --fg: #e7edf5;
  --fg-dim: #94a3b8;
  --accent: #52b6ff;
  --accent-dark: #1d84cc;
  --danger: #ff6b6b;
  --ok: #4ade80;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 0 3rem;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2 { margin: 0; font-weight: 650; }
h1 { font-size: 1.15rem; letter-spacing: .02em; }
h2 { font-size: .95rem; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-dim); }

/* ---------- Kopfzeile ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: .75rem;
  align-items: center; justify-content: space-between;
  padding: .85rem 1rem;
  padding-top: max(.85rem, env(safe-area-inset-top));
  background: rgba(13, 17, 23, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .7rem; }
.logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(150deg, var(--accent), var(--accent-dark));
  box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset;
}
.sub { margin: 0; font-size: .78rem; color: var(--fg-dim); }
.now {
  display: flex; align-items: center; gap: .5rem;
  font-size: .82rem; color: var(--fg-dim);
  max-width: 100%; overflow: hidden;
}
.now span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--fg-dim); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(74,222,128,.7); }
.dot.err { background: var(--danger); }

/* ---------- Layout ---------- */
main { max-width: 780px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.counter { font-size: .8rem; color: var(--fg-dim); }
.hint { margin: .5rem 0 .9rem; font-size: .8rem; color: var(--fg-dim); }

/* ---------- Upload ---------- */
/* Nicht display:none - sonst laesst sich das Feld auf manchen Browsern nicht
   ueber das Label ansprechen. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}

.drop {
  margin-top: .8rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .4rem; text-align: center;
  min-height: 140px; padding: 1.2rem;
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--bg-soft); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:active, .drop.over { border-color: var(--accent); background: #1b2939; }
.drop-icon { font-size: 1.8rem; color: var(--accent); line-height: 1; }
.drop-text { font-size: .92rem; color: var(--fg-dim); }
.drop-text b { color: var(--fg); font-weight: 600; }
.drop-hint { font-size: .74rem; color: var(--fg-dim); opacity: .75; }

.progress { display: flex; align-items: center; gap: .7rem; margin-top: .8rem; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-dark), var(--accent)); transition: width .2s; }
.progress-label { font-size: .78rem; color: var(--fg-dim); min-width: 3.2rem; text-align: right; }

/* ---------- Buttons ---------- */
.controls { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.btn {
  flex: 1 1 auto; min-width: 6.5rem; min-height: 44px;
  padding: .55rem .9rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-soft); color: var(--fg);
  font-size: .9rem; font-weight: 550; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { background: #253242; }
.btn.ghost { background: transparent; color: var(--fg-dim); }
.btn.small { flex: 0 0 auto; min-width: auto; min-height: 38px; font-size: .82rem; }
.btn[disabled] { opacity: .45; cursor: default; }

/* ---------- Einstellungen ---------- */
.settings { display: flex; flex-wrap: wrap; align-items: center; gap: .9rem; margin-top: 1rem;
  padding-top: 1rem; border-top: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .82rem; color: var(--fg-dim); }
.input-unit { display: flex; align-items: center; gap: .4rem; }
.input-unit span { font-size: .8rem; }
input[type="number"] {
  width: 5.5rem; min-height: 40px; padding: .35rem .6rem;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg-soft); color: var(--fg); font-size: .95rem;
}
.switch { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--fg-dim); cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- Playliste ---------- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.item {
  display: grid;
  grid-template-columns: auto auto 84px 1fr auto;
  align-items: center; gap: .7rem;
  padding: .5rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-soft);
}
.item.playing { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(82,182,255,.25); }
.item.dragging { opacity: .4; }
.item.drop-target { border-color: var(--accent); border-style: dashed; }
.grip { cursor: grab; padding: .4rem .2rem; color: var(--fg-dim); font-size: 1.1rem; line-height: 1; touch-action: none; user-select: none; }
.grip:active { cursor: grabbing; }

/* Haken: bestimmt, ob der Eintrag auf der Wand erscheint */
.toggle { display: grid; place-items: center; padding: .2rem; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.item.off { opacity: .55; }
.item.off .thumb { filter: grayscale(1); }
.badge.off { background: #3a2a1e; color: #e0b088; }
.thumb {
  width: 84px; height: 56px; border-radius: 8px; object-fit: cover;
  background: #0b1220; display: block;
}
.meta { min-width: 0; }
.name { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags { display: flex; gap: .4rem; align-items: center; margin-top: .2rem; font-size: .72rem; color: var(--fg-dim); }
.badge { padding: .1rem .4rem; border-radius: 5px; background: #223247; color: #9dc7ee; font-size: .68rem; letter-spacing: .03em; }
.badge.video { background: #33244a; color: #c6a8f0; }
.actions { display: flex; gap: .25rem; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--fg-dim);
  font-size: 1rem; cursor: pointer;
}
.icon-btn:hover { background: #22303f; color: var(--fg); }
.icon-btn.del:hover { color: var(--danger); }
.empty { color: var(--fg-dim); font-size: .85rem; text-align: center; padding: 1.2rem 0; }

.foot { text-align: center; font-size: .74rem; color: var(--fg-dim); opacity: .8; }

/* ---------- Meldungen ---------- */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 50;
  display: grid; gap: .4rem; width: min(90vw, 460px);
}
.toast {
  padding: .6rem .9rem; border-radius: 10px;
  background: #223142; border: 1px solid var(--line);
  color: var(--fg); font-size: .85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  animation: pop .2s ease-out;
}
.toast.err { background: #3a2028; border-color: #6b2b36; }
.toast.ok { background: #1c3527; border-color: #2f6b47; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 420px) {
  .item { grid-template-columns: auto auto 64px 1fr auto; }
  .thumb { width: 64px; height: 44px; }
}
