/* PairDrop-PHP – Oberflaeche */

:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e2e8f0;
  --text: #10151c;
  --muted: #63707f;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --accent-soft: #e8efff;
  --ok: #15803d;
  --ok-soft: #e6f6ec;
  --warn: #b45309;
  --err: #c02626;
  --err-soft: #fdeaea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 21, 28, .05), 0 8px 24px rgba(16, 21, 28, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1319;
    --panel: #171d26;
    --panel-2: #1d242f;
    --border: #2a323e;
    --text: #e7ecf3;
    --muted: #95a2b3;
    --accent: #4d84ff;
    --accent-text: #0b1220;
    --accent-soft: #1b2740;
    --ok: #4ade80;
    --ok-soft: #16281d;
    --warn: #fbbf24;
    --err: #f87171;
    --err-soft: #2c1a1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  }
}

* { box-sizing: border-box; }

/* Muss VOR allen display-Regeln stehen und braucht !important:
   Autoren-CSS gewinnt grundsaetzlich gegen das [hidden] des Browsers. Ohne
   diese Zeile wuerden .view und .backdrop ihr hidden-Attribut aushebeln und
   Raumansicht bzw. Ziel-Dialog waeren dauerhaft sichtbar. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  padding: 0 0 3rem;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

h1 { font-size: 1.35rem; margin: 0 0 .4rem; }
h2 { font-size: 1rem; margin: 0; letter-spacing: .01em; }
h3 { font-size: 1.05rem; margin: 0 0 .8rem; }
p  { margin: .5rem 0; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .1em .35em;
  word-break: break-all;
}

.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ------------------------------------------------------------------ Topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem clamp(.9rem, 3vw, 2rem);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-weight: 650;
  letter-spacing: -.01em;
}

.logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  position: relative;
  flex: none;
}
.logo::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 5px;
  width: 2px;
  height: 9px;
  background: var(--accent-text);
  transform: translateX(-50%);
  box-shadow: 0 0 0 0 transparent;
}
.logo::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 10px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--accent-text);
  border-bottom: 2px solid var(--accent-text);
  transform: translateX(-50%) rotate(45deg);
}

.topbar-right { display: flex; align-items: center; gap: .6rem; }

.room-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: .25rem .7rem;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------------- Views */

.view {
  max-width: 940px;
  margin: 0 auto;
  padding: clamp(.9rem, 3vw, 1.6rem);
  display: grid;
  gap: 1rem;
}

.view-join {
  min-height: 70vh;
  place-content: center;
}

.card, .panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem clamp(1rem, 3vw, 1.4rem);
}

.card-join { max-width: 520px; margin: 0 auto; width: 100%; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .85rem;
}

/* -------------------------------------------------------------- Formulare */

label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin: .9rem 0 .3rem;
}

input[type=text], input[type=password], textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: .6rem .7rem;
}
input[readonly] { color: var(--muted); }

input:focus-visible, textarea:focus-visible, .dropzone:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

textarea { resize: vertical; min-height: 4.5rem; }

.row { display: flex; gap: .5rem; align-items: stretch; }
.row > input { flex: 1 1 auto; min-width: 0; }

.check {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 400;
  margin: 1rem 0 .2rem;
}
.check input { width: auto; }

/* --------------------------------------------------------------- Buttons */

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 9px;
  border: 1px solid transparent;
  padding: .55rem .95rem;
  cursor: pointer;
  white-space: nowrap;
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--border);
}
.btn:hover:not(:disabled) { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: default; }

.btn-primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn-ghost   { background: transparent; }
.btn-block   { display: block; width: 100%; margin-top: 1.1rem; }
.btn-sm      { padding: .35rem .7rem; font-size: .85rem; }

.linkbtn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

/* ----------------------------------------------------------------- Status */

.pill {
  font-size: .78rem;
  font-weight: 600;
  border-radius: 999px;
  padding: .2rem .6rem;
  white-space: nowrap;
}
.pill-ok   { background: var(--ok-soft);    color: var(--ok); }
.pill-wait { background: var(--accent-soft); color: var(--accent); }
.pill-err  { background: var(--err-soft);  color: var(--err); }

.error {
  background: var(--err-soft);
  color: var(--err);
  border-radius: 9px;
  padding: .5rem .7rem;
  font-size: .9rem;
  margin-top: .8rem;
}

.empty { color: var(--muted); font-size: .9rem; margin: 0; }

/* ------------------------------------------------------------------ Peers */

.peers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .6rem;
}

.peer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  text-align: center;
  padding: .9rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color .12s, transform .12s;
}
.peer:hover { border-color: var(--accent); }
.peer.drag  { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.02); }

.peer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  background: var(--accent-soft);
  color: var(--accent);
}
.peer-name { font-weight: 600; word-break: break-word; }

/* ------------------------------------------------------------- Dropzone */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 1.6rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.drag  { border-color: var(--accent); background: var(--accent-soft); }

.dz-inner { display: grid; gap: .2rem; justify-items: center; }

.dz-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 2px solid var(--accent);
  position: relative;
  margin-bottom: .35rem;
}
.dz-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 7px;
  width: 2px;
  height: 14px;
  background: var(--accent);
  transform: translateX(-50%);
}
.dz-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 7px;
  width: 9px;
  height: 9px;
  border-left: 2px solid var(--accent);
  border-top: 2px solid var(--accent);
  transform: translateX(-50%) rotate(45deg);
}

.sendtext { display: grid; gap: .5rem; margin-top: .8rem; }
.sendtext .btn { justify-self: start; }

/* -------------------------------------------------------------- Transfers */

.items { display: grid; gap: .55rem; }

.item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: .75rem;
  align-items: center;
  padding: .7rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.item-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1rem;
}
.item.done .item-icon { background: var(--ok-soft); color: var(--ok); }

.item-main { min-width: 0; }
.item-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-sub { font-size: .82rem; color: var(--muted); }
.item-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.item-text {
  grid-column: 1 / -1;
  margin: 0;
  padding: .6rem .7rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 11rem;
  overflow: auto;
}

.bar {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .18s linear;
}

/* ---------------------------------------------------------------- Picker */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 18, .55);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 60;
}
.card-picker { max-width: 400px; width: 100%; }
.picker-list { display: grid; gap: .45rem; }

.picker-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  padding: .6rem .7rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  cursor: pointer;
}
.picker-item:hover { border-color: var(--accent); }

/* ---------------------------------------------------------------- Toasts */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  display: grid;
  gap: .4rem;
  z-index: 80;
  width: min(420px, calc(100vw - 2rem));
}

.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: .6rem .8rem;
  font-size: .9rem;
  animation: rise .18s ease-out;
}
.toast.err { border-left-color: var(--err); }
.toast.ok  { border-left-color: var(--ok); }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------- Sonstiges */

.hint { margin-top: 1.2rem; font-size: .9rem; }
.hint summary { cursor: pointer; color: var(--accent); }
.hint > *:not(summary) { margin-top: .6rem; }

.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 .3rem;
}

@media (max-width: 480px) {
  .item { grid-template-columns: auto 1fr; }
  .item-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
