/* Panel voicewa - ta sama paleta co strona nagrywania, ale uklad "biurkowy". */

:root {
  --bg: #0b1120;
  --bg-2: #131c31;
  --card: #16203a;
  --card-2: #1b2542;
  --line: #24314f;
  --fg: #eef2ff;
  --muted: #93a3c4;
  --dim: #6b7ba0;
  --accent: #7c5cff;
  --accent-2: #a78bfa;
  --wa: #25d366;
  --err: #ff6b6b;
  --ok: #4ade80;
  --warn: #fbbf24;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background:
    radial-gradient(1000px 600px at 12% -10%, #1e2a4d 0%, transparent 60%),
    radial-gradient(900px 500px at 92% 0%, #2a1e4d 0%, transparent 55%),
    var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }

/* --- brama logowania ------------------------------------------------------ */

body.gate { display: grid; place-items: center; min-height: 100vh; padding: 20px; }

.gate-box {
  width: min(380px, 100%);
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 26px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.gate-box .lock { font-size: 34px; margin-bottom: 6px; }
.gate-box h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.gate-box p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.gate-box input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #0e1526;
  outline: none;
}
.gate-box input:focus { border-color: var(--accent); }
.gate-box button {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(160deg, var(--accent), #5b21b6);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.gate-box .err { color: var(--err); margin: 12px 0 0; font-size: 14px; }

/* --- szkielet ------------------------------------------------------------- */

.app { display: flex; min-height: 100vh; }

.side {
  width: 232px;
  flex: none;
  border-right: 1px solid var(--line);
  background: rgba(11, 17, 32, .72);
  backdrop-filter: blur(8px);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand .mark {
  width: 32px; height: 32px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, var(--accent), #5b21b6);
  font-size: 16px;
}
.brand b { font-size: 15px; letter-spacing: -.01em; }
.brand span { display: block; font-size: 11px; color: var(--dim); }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav button {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav button:hover { background: rgba(124, 92, 255, .1); color: var(--fg); }
.nav button.on { background: rgba(124, 92, 255, .18); color: var(--fg); font-weight: 600; }
.nav .ico { width: 18px; text-align: center; font-size: 15px; }
.nav .badge {
  margin-left: auto;
  font-size: 11px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.wa-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 12.5px;
  color: var(--muted);
}
.wa-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.wa-pill.on  .dot { background: var(--wa); box-shadow: 0 0 0 3px rgba(37, 211, 102, .18); }
.wa-pill.off .dot { background: var(--err); }
.wa-pill b { color: var(--fg); font-weight: 600; font-size: 12.5px; }

.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }

.page-head {
  display: flex; align-items: baseline; gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: 13.5px; }
.page-head .spacer { flex: 1; }

/* --- elementy wspolne ----------------------------------------------------- */

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.btn {
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--fg);
  cursor: pointer;
  font-size: 13.5px;
  transition: border-color .15s, background .15s;
}
a.btn { text-decoration: none; text-align: center; color: var(--fg); }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; border-color: var(--line); }
.btn.primary { background: linear-gradient(160deg, var(--accent), #5b21b6); border-color: transparent; font-weight: 600; }
.btn.danger:hover { border-color: var(--err); color: #ffd9d9; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }

.inp {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0e1526;
  outline: none;
  width: 100%;
}
.inp:focus { border-color: var(--accent); }

.muted { color: var(--muted); }
.dim { color: var(--dim); }
.hidden { display: none !important; }
.err-text { color: var(--err); }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.avatar {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #2b3a63, #1d2947);
  color: var(--accent-2);
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
}
.avatar.group { background: linear-gradient(160deg, #2f4a3a, #1d3327); color: #7ee2a8; }

/* --- pulpit --------------------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.tile {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.tile .n { font-size: 25px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .k { font-size: 12px; color: var(--muted); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

.rows { display: flex; flex-direction: column; gap: 9px; }
.row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(36, 49, 79, .6);
}
.row:last-child { border-bottom: none; padding-bottom: 0; }
.row .k { color: var(--muted); }
.row .v { margin-left: auto; text-align: right; }

/* wykres slupkowy - czysty CSS, bez bibliotek */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 110px; margin-top: 4px; }
.chart .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; min-width: 3px; }
.chart .bar i { display: block; border-radius: 2px; background: var(--accent); }
.chart .bar i.out { background: var(--wa); }
.chart-legend { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.chart-legend s { width: 9px; height: 9px; border-radius: 2px; display: inline-block; vertical-align: -1px; margin-right: 5px; }

.qr-box { text-align: center; padding: 8px 0; }
.qr-box img { width: 240px; max-width: 100%; border-radius: 12px; background: #fff; padding: 8px; }
.qr-ok { font-size: 46px; color: var(--wa); }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }

/* postęp pobierania w bocznym pasku */
.prog {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 9px 11px;
}
.prog-top { display: flex; align-items: baseline; gap: 8px; }
.prog-label { font-size: 12px; color: var(--muted); }
.prog-top b { margin-left: auto; font-size: 13px; font-variant-numeric: tabular-nums; }
.prog .gauge { margin: 6px 0 5px; height: 6px; }
.prog-sub { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.prog.done .prog-top b { color: var(--ok); }

/* pasek zajętości dysku */
.gauge {
  height: 9px;
  border-radius: 6px;
  background: #0e1526;
  border: 1px solid var(--line);
  overflow: hidden;
  margin: 4px 0 10px;
}
.gauge i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .3s;
}
.gauge.warn i { background: linear-gradient(90deg, #d97706, var(--warn)); }
.gauge.bad  i { background: linear-gradient(90deg, #b91c1c, var(--err)); }
.gauge.done i { background: linear-gradient(90deg, #15803d, var(--ok)); }

.note {
  border-left: 3px solid var(--accent);
  background: rgba(124, 92, 255, .07);
  padding: 10px 13px;
  border-radius: 0 10px 10px 0;
  font-size: 13px;
  color: var(--muted);
}
.note.warn { border-color: var(--warn); background: rgba(251, 191, 36, .07); }

/* --- wiadomosci ----------------------------------------------------------- */

.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  height: calc(100vh - 130px);
  min-height: 440px;
}
@media (max-width: 900px) { .chat-layout { grid-template-columns: 1fr; height: auto; } }

.pane {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.pane-head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  flex: none;
}
.pane-body { overflow-y: auto; flex: 1; min-height: 0; }
@media (max-width: 900px) { .pane-body { max-height: 60vh; } }

.chat-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(36, 49, 79, .45);
  transition: background .12s;
}
.chat-item:hover { background: rgba(124, 92, 255, .07); }
.chat-item.on { background: rgba(124, 92, 255, .15); }
.chat-item .txt { min-width: 0; flex: 1; }
.chat-item .nm { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .pv { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .rt { text-align: right; flex: none; font-size: 11px; color: var(--dim); }
.chat-item .rt .cnt {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(124, 92, 255, .18);
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

.thread { padding: 16px; display: flex; flex-direction: column; gap: 8px; }

.day-sep { text-align: center; margin: 10px 0 4px; }
.day-sep span {
  font-size: 11.5px; color: var(--dim);
  background: rgba(14, 21, 38, .8);
  padding: 3px 11px; border-radius: 20px;
  border: 1px solid var(--line);
}

.bub {
  max-width: min(560px, 78%);
  padding: 8px 12px 6px;
  border-radius: 14px;
  background: var(--card-2);
  border: 1px solid var(--line);
  align-self: flex-start;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.bub.me {
  align-self: flex-end;
  background: linear-gradient(160deg, #2a3f6b, #223257);
  border-color: #33487a;
}
.bub .who { font-size: 11.5px; color: var(--accent-2); font-weight: 600; margin-bottom: 2px; }
.bub .body { white-space: pre-wrap; font-size: 14px; }
.bub .foot { font-size: 10.5px; color: var(--dim); text-align: right; margin-top: 3px; }
.bub .foot .tick { color: var(--wa); margin-left: 4px; }

.bub .quote {
  border-left: 3px solid var(--accent);
  padding: 3px 0 3px 8px;
  margin-bottom: 5px;
  font-size: 12.5px;
  color: var(--muted);
  opacity: .9;
}

.att {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px;
  border-radius: 10px;
  background: rgba(11, 17, 32, .45);
  border: 1px solid var(--line);
  margin-bottom: 5px;
  font-size: 13px;
}
.att .ic { font-size: 17px; }
.att .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att .sz { font-size: 11px; color: var(--dim); }
.bub img.shot { max-width: 100%; border-radius: 10px; display: block; margin-bottom: 5px; }
.bub audio, .bub video { max-width: 100%; display: block; margin-bottom: 5px; border-radius: 10px; }

.empty { padding: 44px 20px; text-align: center; color: var(--dim); font-size: 14px; }

/* --- tabela (kontakty, konta) --------------------------------------------- */

.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--dim);
  font-weight: 600;
  padding: 0 10px 9px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
  background: #141d34;
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid rgba(36, 49, 79, .5); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: rgba(124, 92, 255, .07); }
.tbl .num { font-variant-numeric: tabular-nums; color: var(--muted); }
.tbl .name-cell { display: flex; align-items: center; gap: 10px; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tag.live { border-color: rgba(37, 211, 102, .5); color: var(--wa); }
.tag.grp { border-color: rgba(126, 226, 168, .35); color: #7ee2a8; }

.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%);
  background: #1b2542;
  border: 1px solid var(--line);
  padding: 11px 18px;
  border-radius: 11px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  font-size: 13.5px;
  z-index: 50;
  max-width: min(520px, 92vw);
}
.toast.bad { border-color: var(--err); color: #ffd9d9; }
.toast.good { border-color: rgba(37, 211, 102, .5); }
