/* ============================================================
   Frontek Drop — trasferimento file P2P (WebRTC) nel browser
   Palette brand frontek + tema chiaro/scuro (allineato a data/tools)
   ============================================================ */

:root{
  --teal:#2A9D8F; --coral:#E76F51; --dark:#264653; --gold:#E9C46A;
  --green:#8AB17D; --danger:#c0432c;

  --bg:#f4f2ea; --bg2:#ece8dc; --card:#ffffff; --line:#e4e0d4;
  --ink:#21333b; --muted:#5a6b73; --faint:#8a979c;
  --shadow:0 1px 2px rgba(38,70,83,.06), 0 6px 20px rgba(38,70,83,.06);
  --accent:var(--teal);
  --code:#0e1a1f; --code-ink:#d6efe9;

  --axis:#d6d1c4; --hover:rgba(42,157,143,.10);
}

@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#0f1a1f; --bg2:#132229; --card:#17272e; --line:#24373f;
    --ink:#e8efee; --muted:#9db0b6; --faint:#6f8189;
    --shadow:0 1px 2px rgba(0,0,0,.3), 0 8px 26px rgba(0,0,0,.32);
    --code:#0a1418; --code-ink:#cfe9e3;
    --axis:#2c434c; --hover:rgba(42,157,143,.16);
  }
}
:root[data-theme="dark"]{
  --bg:#0f1a1f; --bg2:#132229; --card:#17272e; --line:#24373f;
  --ink:#e8efee; --muted:#9db0b6; --faint:#6f8189;
  --shadow:0 1px 2px rgba(0,0,0,.3), 0 8px 26px rgba(0,0,0,.32);
  --code:#0a1418; --code-ink:#cfe9e3;
  --axis:#2c434c; --hover:rgba(42,157,143,.16);
}

*{ box-sizing:border-box; }
html{ -webkit-text-size-adjust:100%; }
body{
  margin:0; min-height:100vh;
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  color:var(--ink);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(42,157,143,.10), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(231,111,81,.08), transparent 55%),
    var(--bg);
  display:flex; flex-direction:column;
}
a{ color:var(--accent); text-decoration:none; }
a:hover{ text-decoration:underline; }
h1,h2,h3{ line-height:1.2; }
[hidden]{ display:none !important; }

/* ---- TOP BAR ---- */
.top{ display:flex; align-items:center; gap:12px; padding:14px clamp(14px,4vw,34px); }
.brand{ font-size:1.02rem; letter-spacing:.16em; font-weight:800; text-transform:uppercase; color:var(--ink); }
.brand:hover{ text-decoration:none; }
.brand span{ color:var(--coral); }
.top__spacer{ flex:1 1 auto; }
.iconbtn{ border:1px solid var(--line); background:var(--card); color:var(--ink);
  width:40px; height:40px; border-radius:11px; font-size:1.15rem; cursor:pointer;
  display:inline-flex; align-items:center; justify-content:center;
  transition:transform .12s ease, border-color .12s ease; }
.iconbtn:hover{ transform:translateY(-1px); border-color:var(--accent); }

/* ---- LAYOUT ---- */
.wrap{ flex:1 1 auto; width:100%; max-width:880px; margin:0 auto;
  padding:clamp(8px,2.4vw,22px) clamp(14px,4vw,34px) 26px; }
.card{ background:var(--card); border:1px solid var(--line); border-radius:16px; box-shadow:var(--shadow); }
.inp{ border:1px solid var(--line); border-radius:10px; background:var(--bg2); color:var(--ink);
  padding:11px 13px; font-size:.95rem; outline:none; min-width:0; }
.inp:focus{ border-color:var(--accent); }
.btn--big{ padding:15px 26px; font-size:1.05rem; border-radius:12px; }
.label{ font-size:.74rem; text-transform:uppercase; letter-spacing:.08em; color:var(--faint); font-weight:700; }
.hint{ margin:0; font-size:.84rem; color:var(--muted); }

/* ---- INGRESSO ---- */
.landing{ text-align:center; padding-top:clamp(10px,4vh,40px); }
.landing__title{ margin:0 0 10px; font-size:clamp(1.6rem,4.6vw,2.4rem); letter-spacing:-.01em; }
.landing__sub{ margin:0 auto 26px; color:var(--muted); font-size:1.05rem; max-width:620px; }
.start{ max-width:440px; margin:0 auto; padding:24px; display:flex; flex-direction:column; align-items:stretch; gap:14px; }
.start__or{ display:flex; align-items:center; gap:10px; color:var(--faint); font-size:.84rem; }
.start__or::before, .start__or::after{ content:""; flex:1; border-top:1px solid var(--line); }
.join{ display:flex; gap:8px; }
.join .inp{ flex:1 1 auto; }
.inp--code{ font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:1.1rem; letter-spacing:.12em;
  text-transform:uppercase; text-align:center; }
.start__err{ margin:0; color:var(--danger); font-size:.86rem; }
.points{ list-style:none; padding:0; margin:30px 0 0; display:grid; gap:14px;
  grid-template-columns:repeat(3,1fr); text-align:left; }
.points li{ background:var(--card); border:1px solid var(--line); border-radius:14px; padding:14px 16px; }
.points b{ display:block; margin-bottom:4px; }
.points span{ color:var(--muted); font-size:.88rem; }

/* ---- STANZA ---- */
.room{ display:flex; flex-direction:column; gap:16px; }
.room__head{ display:flex; gap:20px; align-items:center; justify-content:space-between; padding:20px; }
.room__info{ display:flex; flex-direction:column; gap:10px; min-width:0; }
.code{ font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:clamp(1.7rem,5vw,2.3rem);
  font-weight:800; letter-spacing:.12em; }
.room__actions{ display:flex; flex-wrap:wrap; gap:8px; }
.qr{ flex:0 0 auto; background:#fff; padding:10px; border-radius:12px; border:1px solid var(--line); line-height:0; }
.qr svg{ width:156px; height:156px; display:block; }
.qr[hidden]{ display:none; }

.state{ display:inline-flex; align-items:center; gap:8px; font-size:.92rem; font-weight:600; }
.state__dot{ width:10px; height:10px; border-radius:50%; background:var(--gold); flex:0 0 auto; }
.state[data-state="waiting"] .state__dot, .state[data-state="connecting"] .state__dot{ animation:pulse 1.2s ease-in-out infinite; }
.state[data-state="connected"] .state__dot{ background:var(--teal); }
.state[data-state="failed"] .state__dot, .state[data-state="full"] .state__dot{ background:var(--danger); }
.state[data-state="failed"], .state[data-state="full"]{ color:var(--danger); }
@keyframes pulse{ 50%{ opacity:.3; } }

.send{ padding:16px; display:flex; flex-direction:column; gap:12px; }
.drop{ display:flex; flex-direction:column; align-items:center; gap:6px; cursor:pointer; text-align:center;
  padding:26px 16px; border:2px dashed var(--axis); border-radius:14px; background:var(--bg2);
  transition:border-color .12s ease, background .12s ease; }
.drop:hover{ border-color:var(--accent); background:var(--hover); }
.drop:focus-within{ outline:2px solid var(--accent); outline-offset:2px; }
.drop__ic{ width:44px; height:44px; border-radius:12px; display:flex; align-items:center; justify-content:center;
  font-size:1.3rem; font-weight:800; color:#fff; background:linear-gradient(135deg,var(--teal),var(--dark)); }
.drop__main{ font-weight:700; }
.drop__hint{ color:var(--muted); font-size:.84rem; }
.textsend{ display:flex; gap:8px; }
.textsend .inp{ flex:1 1 auto; }

.xfers{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; }
.xfers__title{ margin:0; padding:14px 16px 4px; font-size:1rem; }
.xfers-card{ padding-bottom:6px; }
.xf{ display:grid; grid-template-columns:auto minmax(0,1fr) auto; gap:4px 12px; align-items:center;
  padding:12px 16px; border-top:1px solid var(--line); }
.xf:first-child{ border-top:0; }
.xf__dir{ grid-row:1 / span 2; width:34px; height:34px; border-radius:10px; display:flex; align-items:center; justify-content:center;
  font-weight:800; background:var(--bg2); color:var(--muted); }
.xf--in .xf__dir{ color:var(--teal); }
.xf--out .xf__dir{ color:var(--coral); }
.xf__name{ font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.xf__text{ font-family:ui-monospace,Menlo,Consolas,monospace; font-size:.88rem; white-space:pre-wrap; overflow-wrap:anywhere;
  max-height:9em; overflow:auto; }
.xf__meta{ grid-column:2; font-size:.8rem; color:var(--muted); font-variant-numeric:tabular-nums; }
.xf__act{ grid-column:3; grid-row:1 / span 2; display:flex; gap:6px; }
.bar{ grid-column:2 / span 2; height:6px; border-radius:3px; background:var(--bg2); overflow:hidden; margin-top:2px; }
.bar i{ display:block; height:100%; width:0; background:var(--teal); border-radius:3px; transition:width .2s linear; }
.xf--out .bar i{ background:var(--coral); }
.xf--done .bar, .xf--err .bar{ display:none; }
.xf--err .xf__meta{ color:var(--danger); }

.toast{ position:fixed; left:50%; bottom:22px; transform:translateX(-50%); z-index:90; background:var(--dark); color:#fff;
  padding:10px 16px; border-radius:10px; font-size:.9rem; box-shadow:var(--shadow); }

/* ---- CONTROLLI ---- */
.btn{ border:0; background:var(--accent); color:#fff; padding:10px 16px; border-radius:10px; justify-content:center;
  font-size:.92rem; font-weight:600; cursor:pointer; transition:filter .12s ease; display:inline-flex;
  align-items:center; gap:4px; }
.btn:hover{ filter:brightness(1.06); }
.btn:disabled{ opacity:.55; cursor:progress; }
.btn--light{ background:var(--bg2); color:var(--ink); border:1px solid var(--line); }
.btn--ghost{ background:transparent; color:var(--accent); border:1px solid var(--line); }
.btn--sm{ padding:6px 10px; font-size:.82rem; border-radius:8px; }
/* ---- DRAG & DROP su tutta la pagina ---- */
.dropveil{ position:fixed; inset:0; z-index:80; display:flex; align-items:center; justify-content:center;
  background:rgba(15,26,31,.55); pointer-events:none; }
.dropveil span{ background:var(--card); color:var(--ink); border:2px dashed var(--accent); border-radius:16px;
  padding:22px 30px; font-weight:700; font-size:1.1rem; }

/* ---- FOOTER ---- */
.foot{ text-align:center; color:var(--muted); font-size:.82rem; padding:20px 16px 28px;
  display:flex; flex-wrap:wrap; gap:8px; justify-content:center; align-items:center; }
.foot__dot{ color:var(--faint); }

/* ---- MODALE ---- */
.modal{ position:fixed; inset:0; z-index:60; display:flex; align-items:center; justify-content:center; padding:16px; }
.modal__backdrop{ position:absolute; inset:0; background:rgba(15,26,31,.55); }
.modal__box{ position:relative; width:100%; max-width:440px; background:var(--card);
  border:1px solid var(--line); border-radius:18px; box-shadow:var(--shadow); overflow:hidden; }
.modal__head{ display:flex; align-items:center; justify-content:space-between;
  padding:16px 18px; border-bottom:1px solid var(--line); }
.modal__head h2{ margin:0; font-size:1.15rem; }
.modal__body{ padding:18px; display:flex; flex-direction:column; gap:16px; }
.field{ display:flex; flex-direction:column; gap:8px; }
.field__label{ font-size:.82rem; font-weight:600; color:var(--muted); }
.field__select{ border:1px solid var(--line); border-radius:10px; background:var(--bg2);
  color:var(--ink); padding:11px 12px; font-size:.95rem; outline:none; }
.field__select:focus{ border-color:var(--accent); }
.field__hint{ font-size:.82rem; color:var(--muted); margin:0; }

/* ---- RESPONSIVE ---- */
@media (max-width:700px){
  .points{ grid-template-columns:1fr; }
  .room__head{ flex-direction:column-reverse; align-items:stretch; text-align:center; }
  .room__info{ align-items:center; }
  .room__actions{ justify-content:center; }
  .qr{ align-self:center; }
}
@media (max-width:420px){
  .textsend{ flex-direction:column; }
}
