/* OnAir — Admin
 * Mobile-first responsive admin dashboard.
 * Breakpoints: 360 (default), 768 (tablet), 1024+ (desktop).
 */

/* === Topbar === */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: linear-gradient(180deg, rgba(15,18,64,.95) 0%, rgba(10,18,64,.7) 100%);
  border-bottom: 1px solid var(--c-border-soft);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.topbar .logo-mark .tile { width: 28px; height: 28px; font-size: 14px; box-shadow: 3px 3px 0 var(--c-sky); }
.topbar .logo-mark .tile.accent { box-shadow: 3px 3px 0 var(--c-magenta); }

.brand-text { min-width: 0; }
.brand-text .title {
  font-family: var(--ff-display); font-weight: 800; font-size: 16px;
  display: flex; align-items: center; gap: var(--sp-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text .badge {
  background: var(--gd-primary);
  font-size: 9px; padding: 2px 6px; border-radius: var(--r-pill);
  font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  box-shadow: var(--glow-violet);
}
.brand-text .sub { display: none; }
.who { display: none; font-size: 12px; color: var(--c-text-muted); }
.who::before { content: "\f007"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: 6px; color: var(--c-sky); }
#logout { padding: 10px; min-width: 44px; min-height: 44px; }
#logout .logout-label { display: none; }

.container { max-width: 1280px; margin: 0 auto; padding: var(--sp-4) var(--sp-3); }

/* === Card / Login === */
.card {
  background: linear-gradient(180deg, rgba(26,37,112,.85) 0%, rgba(15,27,92,.7) 100%);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--sh-md);
  backdrop-filter: blur(10px);
}

.login-card { max-width: 440px; margin: var(--sp-5) auto; }
.login-card h2 {
  font-family: var(--ff-display); font-size: 14px;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--c-text-muted);
  margin: 0 0 var(--sp-4);
}

/* === Form generico === */
.form-group { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.form-row { display: grid; grid-template-columns: 1fr; gap: var(--sp-3); }
.form-group label {
  font-size: 11px; color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: .12em; font-weight: 600;
}
.form-group input, .form-group select,
.modal input, .modal select {
  font-size: 16px;
  padding: 12px 14px;
  min-height: 44px;
}
.form-group .hint, .modal .hint {
  font-size: 11px; color: var(--c-text-dim); margin-top: 2px;
}

.input-with-action {
  display: flex; gap: var(--sp-2); align-items: center;
}
.input-with-action > input { flex: 1; }
.btn-icon-only {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--c-navy-soft);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  color: var(--c-text);
  cursor: pointer;
  transition: background var(--t-fast) var(--easing);
}
.btn-icon-only:hover { background: var(--c-navy); border-color: var(--c-sky); }
.chk {
  display: flex; gap: 8px; align-items: center;
  font-size: 13px; color: var(--c-text-muted);
  white-space: nowrap; padding: 0 var(--sp-2);
}

.actions {
  display: flex; gap: var(--sp-3);
  flex-direction: column;
  margin-top: var(--sp-3);
}
.actions .btn { width: 100%; min-height: 48px; }
.err { color: var(--c-coral); font-size: 13px; min-height: 18px; margin-top: var(--sp-2); }

/* L'attributo [hidden] deve sempre vincere sui display delle classi.
   Altrimenti il dashboard (display:flex) resta visibile prima del login. */
[hidden] { display: none !important; }

/* === Dashboard === */
.dashboard {
  display: flex; flex-direction: column;
  gap: var(--sp-4);
}

/* Stats: card piene a tutta larghezza su mobile, 3 colonne su tablet+ */
.stats {
  display: grid; grid-template-columns: 1fr;
  gap: var(--sp-3);
}
.stat {
  padding: var(--sp-4);
  background: linear-gradient(135deg, rgba(94,44,237,.18), rgba(112,191,236,.10));
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  text-align: left;
  display: flex; align-items: baseline; gap: var(--sp-3);
}
.stat .num {
  font-family: var(--ff-display);
  font-size: 32px; font-weight: 800;
  background: var(--gd-onair);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}
.stat:nth-child(2) .num { background: var(--gd-primary); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat:nth-child(3) .num { background: var(--gd-rec); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat .lbl {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--c-text-muted); margin: 0;
}

/* Grid form / lista */
.grid {
  display: grid; grid-template-columns: 1fr; gap: var(--sp-4);
  align-items: start;
}

.panel {
  background: linear-gradient(180deg, rgba(26,37,112,.55) 0%, rgba(15,27,92,.45) 100%);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  backdrop-filter: blur(12px);
  box-shadow: var(--sh-md);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.panel h2 {
  font-family: var(--ff-display); font-size: 13px;
  letter-spacing: .15em; text-transform: uppercase;
  color: var(--c-text-muted); margin: 0;
}
.panel-head .btn-ghost { min-width: 44px; min-height: 44px; padding: 10px; }

#new-room button[type="submit"] { width: 100%; min-height: 48px; margin-top: var(--sp-2); }

/* === Rooms list === */
.rooms { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.room {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "id meta"
    "actions actions";
  gap: var(--sp-3);
  align-items: start;
  padding: var(--sp-4);
  background: rgba(15,27,92,.5);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-md);
}
.room .room-id {
  grid-area: id;
  font-family: var(--ff-mono);
  background: var(--c-navy-soft);
  padding: 6px 10px; border-radius: var(--r-sm);
  letter-spacing: .12em; font-weight: 600;
  color: var(--c-sky-bright);
  font-size: 13px;
  white-space: nowrap;
}
.room .meta { grid-area: meta; min-width: 0; }
.room .meta .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room .meta .info {
  font-size: 12px; color: var(--c-text-muted); margin-top: 4px;
  display: flex; flex-wrap: wrap; gap: 12px;
}
.room .meta .info i { margin-right: 4px; color: var(--c-sky); }
.room .meta .info .onair { color: var(--c-mint); font-weight: 600; }
.room .meta .info .expires-soon { color: var(--c-amber); }
.room .meta .info .expired { color: var(--c-coral); }
.room.onair .room-id { color: var(--c-mint); box-shadow: var(--glow-mint); }
.room .actions {
  grid-area: actions;
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  margin-top: 0;
  flex-direction: row;
}
.room .actions .btn {
  padding: 10px 14px;
  font-size: 13px;
  min-height: 44px;
  width: auto;
  flex: 1 1 auto;
}

/* === Modal: condivisi === */
.modal {
  background: var(--c-navy);
  border: 0;
  color: var(--c-text);
  padding: 0;
  margin: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  overflow: hidden;
}
.modal::backdrop { background: rgba(8,12,40,.7); backdrop-filter: blur(6px); }
.modal form {
  display: flex; flex-direction: column;
  /* height:100% solo su mobile (modal full-screen); su desktop il form
     si adatta al contenuto cosi` modali piccole non diventano enormi. */
  height: 100%;
  animation: slide-up var(--t-med) var(--easing);
}
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4);
  border-bottom: 1px solid var(--c-border-soft);
}
.modal-head h3 {
  font-family: var(--ff-display);
  font-size: 18px; margin: 0;
  display: flex; align-items: center; gap: var(--sp-2);
}
.modal-head .mono { color: var(--c-sky-bright); font-family: var(--ff-mono); }
.modal-head .btn-icon-only {
  background: transparent; border: 0; color: var(--c-text-muted);
  width: 36px; height: 36px;
}
.modal-head .btn-icon-only:hover { color: var(--c-text); }

/* Tabs */
.tabs {
  display: flex; gap: 4px;
  padding: var(--sp-3) var(--sp-4) 0;
  border-bottom: 1px solid var(--c-border-soft);
  flex-wrap: wrap;
}
.tab {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: var(--r-md) var(--r-md) 0 0;
  color: var(--c-text-muted);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600; font-size: 13px;
  display: flex; align-items: center; gap: 6px;
  min-height: 40px;
}
.tab.active {
  color: var(--c-text);
  background: var(--c-navy-soft);
  border-color: var(--c-border-soft);
  border-bottom-color: var(--c-navy-soft);
  margin-bottom: -1px;
}

.tab-body {
  padding: var(--sp-4);
  overflow-y: auto;
  flex: 1;
}
.tab-body[hidden] { display: none; }
.subhead {
  font-family: var(--ff-display);
  font-size: 12px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin: var(--sp-4) 0 var(--sp-3);
}
.subhead:first-child { margin-top: 0; }

/* Inviti list */
.inv-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.inv-row {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "head"
    "details"
    "rowactions";
  gap: 6px;
  padding: var(--sp-3);
  background: rgba(15,27,92,.5);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-md);
}
.inv-row .head {
  grid-area: head;
  display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap;
}
.inv-row .head .name { font-weight: 600; }
.inv-row .head .role-pill {
  font-size: 10px; padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--c-navy-soft); color: var(--c-sky-bright);
  text-transform: uppercase; letter-spacing: .1em; font-weight: 700;
}
.inv-row .head .role-pill.moderator { background: var(--c-violet); color: white; }
.inv-row .head .status {
  font-size: 11px; color: var(--c-text-dim);
}
.inv-row .head .status.used { color: var(--c-mint); }
.inv-row .head .status.expired { color: var(--c-coral); }
.inv-row .head .status.email-sent { color: var(--c-sky-bright); }
.inv-row .head .status.multi { color: var(--c-amber); }
.inv-row .details {
  grid-area: details;
  font-size: 12px; color: var(--c-text-muted);
  display: flex; gap: 12px; flex-wrap: wrap;
}
.inv-row .details code {
  background: var(--c-navy-soft); padding: 2px 6px; border-radius: 4px;
  font-family: var(--ff-mono); color: var(--c-sky-bright);
}
.inv-row .rowactions {
  grid-area: rowactions;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.inv-row .rowactions .btn {
  padding: 8px 12px; font-size: 12px; min-height: 40px; flex: 1 1 auto;
}

/* Toast */
.toast {
  position: fixed; bottom: var(--sp-4); left: 50%; transform: translateX(-50%);
  background: var(--c-navy-soft);
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  padding: 10px 20px;
  z-index: 1000;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.error { border-color: var(--c-coral); color: var(--c-coral); }
.toast.success { border-color: var(--c-mint); }

/* Decorative blobs */
.blob { position: fixed; pointer-events: none; filter: blur(100px); opacity: .25; z-index: -1; border-radius: 50%; }
.blob.b1 { top: -200px; left: -150px; width: 400px; height: 400px; background: var(--c-violet); }
.blob.b2 { bottom: -200px; right: -150px; width: 480px; height: 480px; background: var(--c-cyan); }

/* === Tablet (>= 768px) === */
@media (min-width: 768px) {
  .container { padding: var(--sp-5) var(--sp-5); }
  .topbar { padding: var(--sp-3) var(--sp-5); }
  .topbar .logo-mark .tile { width: 32px; height: 32px; font-size: 16px; }
  .brand-text .title { font-size: 22px; }
  .brand-text .sub { display: block; font-size: 12px; color: var(--c-text-muted); letter-spacing: .12em; text-transform: uppercase; }
  .who { display: inline; }
  #logout { padding: 10px 14px; }
  #logout .logout-label { display: inline; }

  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat { gap: var(--sp-4); }
  .stat .num { font-size: 36px; }

  .form-row { grid-template-columns: 1fr 1fr; }
  .actions { flex-direction: row; justify-content: flex-end; }
  .actions .btn { width: auto; min-width: 140px; }

  .room {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "id meta actions";
    gap: var(--sp-4);
  }
  /* Pulsanti azione: tutti affiancati, di default solo icona; al
     hover/focus appare anche il testo. Cosi` non rubano spazio al nome. */
  .room .actions {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--sp-2);
    flex: 0 0 auto;
    align-self: center;
  }
  .room .actions .btn {
    flex: 0 0 auto;
    width: auto;
    /* Sovrascrive .actions .btn { min-width: 140px } per default:
       collassato il pulsante mostra solo l'icona centrata. */
    min-width: 0;
    min-height: 40px;
    padding: 8px 12px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;       /* icona centrata quando manca la label */
    gap: 0;                        /* niente spazio fra icona e .label collassata */
    transition: min-width var(--t-med) var(--easing);
  }
  .room .actions .btn .label {
    max-width: 0;
    padding-left: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-width var(--t-med) var(--easing),
                padding-left var(--t-med) var(--easing),
                opacity var(--t-fast) var(--easing);
  }
  /* Al hover/focus si espande a min-width 100px, icona+label centrati insieme */
  .room .actions .btn:hover,
  .room .actions .btn:focus-visible {
    min-width: 100px;
  }
  .room .actions .btn:hover .label,
  .room .actions .btn:focus-visible .label {
    max-width: 200px;
    padding-left: 6px;
    opacity: 1;
  }

  /* Modal centrata */
  .modal {
    width: min(720px, calc(100vw - 32px));
    height: auto;
    max-height: calc(100vh - 64px);
    margin: 32px auto;
    border-radius: var(--r-lg);
    border: 1px solid var(--c-border);
  }
  .modal-lg { width: min(820px, calc(100vw - 32px)); }
  /* Su desktop il form si adatta al contenuto (no full-height) */
  .modal form { height: auto; }
  .modal .tab-body { flex: 0 1 auto; max-height: 70vh; }

  /* Login admin: bottone "Entra" largo come i campi (no row layout) */
  .login-card .actions { flex-direction: column; }
  .login-card .actions .btn { width: 100%; }

  .inv-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "head rowactions"
      "details rowactions";
    align-items: center;
  }
  .inv-row .rowactions { flex-direction: row; flex-wrap: nowrap; }
}

/* === Sidebar contestuale + viste === */
.side-menu {
  display: flex;
  flex-direction: row;             /* mobile: tab orizzontali */
  gap: var(--sp-2);
  overflow-x: auto;
  padding-bottom: var(--sp-2);
}
.side-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--c-navy-soft);
  border: 1px solid var(--c-border-soft);
  color: var(--c-text-muted);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast) var(--easing),
              color var(--t-fast) var(--easing),
              border-color var(--t-fast) var(--easing);
}
.side-link i { color: var(--c-sky); }
.side-link:hover { color: var(--c-text); border-color: var(--c-sky); }
.side-link.active {
  background: var(--gd-primary);
  color: white;
  border-color: transparent;
  box-shadow: var(--glow-violet);
}
.side-link.active i { color: white; }

.views .view { display: block; }
.views .view[hidden] { display: none !important; }

.head-actions { display: flex; gap: var(--sp-2); }

/* === Desktop (>= 1024px): sidebar verticale === */
@media (min-width: 1024px) {
  .grid {
    grid-template-columns: 220px 1fr;
    gap: var(--sp-4);
  }
  .side-menu {
    flex-direction: column;
    overflow-x: visible;
    padding: 0;
    position: sticky;
    top: 80px;
    align-self: start;
  }
  .side-link {
    width: 100%;
    justify-content: flex-start;
    padding: 12px 16px;
  }
}
