/* Komunikator PixlMore - interfejs
   Author: PixlMore (https://pixlmore.pl)
   Fonty wylacznie systemowe (prywatnosc: brak zewnetrznych requestow). */

:root {
    --ink:        #16181d;
    --ink-soft:   #6b6e76;
    --line:       #e6e5e1;
    --surface:    #ffffff;
    --bg:         #fafaf8;
    --brand:      #c8102e;
    --brand-ink:  #9c0c24;
    --brand-tint: #fcecef;
    --received:   #f1f1ee;
    --ok:         #1f8a52;
    --radius:     12px;
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-ink); }
button { font-family: inherit; }

/* Micro-etykieta monospaced - podpis wizualny (status, szyfrowanie, czas). */
.mono {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

/* ---------- Uklad ---------- */
.app {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: 100dvh;
}
.app.admin { grid-template-columns: 300px 1fr 320px; }
.app.client { grid-template-columns: 1fr; }

/* ---------- Rail (lista klientow) ---------- */
.rail {
    border-right: 1px solid var(--line);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.rail-head {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brandmark { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.brandmark .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--brand); }
.rail-list { overflow-y: auto; flex: 1; }

.client-row {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 18px;
    border-left: 3px solid transparent;
    text-decoration: none;
    color: inherit;
}
.client-row:hover { background: var(--bg); }
.client-row.active { border-left-color: var(--brand); background: var(--brand-tint); }
.client-row .who { min-width: 0; }
.client-row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-row .sub { display: flex; gap: 8px; align-items: center; }

.avatar { width: 40px; height: 40px; border-radius: 11px; flex: none; object-fit: cover; background: var(--received); }
.avatar.lg { width: 46px; height: 46px; }

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.status-dot.inactive { background: var(--ink-soft); }
.status-dot.pending  { background: #d99a1f; }

/* ---------- Czat ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.chat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.chat-head .title { font-weight: 650; }
.chat-head .spacer { flex: 1; }
.back { display: none; text-decoration: none; color: var(--ink-soft); font-size: 22px; line-height: 1; }
.lock { display: flex; align-items: center; gap: 6px; }
.lock svg { width: 13px; height: 13px; }

.thread {
    flex: 1;
    overflow-y: auto;
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.empty { margin: auto; text-align: center; color: var(--ink-soft); max-width: 320px; }

.msg { max-width: 72%; display: flex; flex-direction: column; gap: 3px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.bubble {
    padding: 9px 13px;
    border-radius: var(--radius);
    background: var(--received);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.msg.mine .bubble { background: var(--brand-tint); }
.meta { display: flex; gap: 8px; }
.attach {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); text-decoration: none; color: var(--ink);
}
.attach .fname { font-weight: 600; }
.attach .fsize { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); }

/* ---------- Composer ---------- */
.composer {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 12px 16px;
    background: var(--surface);
    border-top: 1px solid var(--line);
}
.composer textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    font: inherit;
    max-height: 140px;
    min-height: 44px;
    background: var(--bg);
}
.composer textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.icon-btn {
    width: 44px; height: 44px; flex: none;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); cursor: pointer; color: var(--ink-soft);
    display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--ink); }
.btn {
    border: none; border-radius: var(--radius); cursor: pointer;
    padding: 0 18px; height: 44px; font-weight: 600;
    background: var(--brand); color: #fff;
}
.btn:hover { background: var(--brand-ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--brand-ink); border: 1px solid var(--line); }
.btn.sm { height: 36px; padding: 0 12px; font-size: 13px; }
.file-name { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); align-self: center; }

/* ---------- Panel admina (profil + akcje) ---------- */
.panel { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
.panel-sec { padding: 18px; border-bottom: 1px solid var(--line); }
.panel h3 { margin: 0 0 12px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
.field { margin-bottom: 10px; }
.field label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--ink-soft); }
.field input, .field textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--line);
    border-radius: 8px; font: inherit; background: var(--bg);
}
.field textarea { resize: vertical; min-height: 60px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Flash / linki ---------- */
.flash { margin: 14px 20px 0; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.flash.ok  { border-color: var(--ok); }
.flash.err { border-color: var(--brand); }
.invite-link {
    display: flex; gap: 8px; margin-top: 8px;
    font-family: var(--mono); font-size: 12px;
}
.invite-link code {
    flex: 1; padding: 8px 10px; background: var(--bg);
    border: 1px solid var(--line); border-radius: 8px;
    overflow-x: auto; white-space: nowrap;
}

/* ---------- Formularz "nowy klient" ---------- */
.newclient { padding: 14px 18px; border-bottom: 1px solid var(--line); display: none; }
.newclient.open { display: block; }
.newclient .field { margin-bottom: 8px; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
    .app.admin, .app { grid-template-columns: 1fr; }
    .app.admin .panel { display: none; }
    .app.admin.has-conv .rail { display: none; }
    .app.admin:not(.has-conv) .chat { display: none; }
    .back { display: block; }
    .msg { max-width: 86%; }
}
