/* Reset, typografia i szkielet układu. */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p  { margin: 0 0 .75em; }
p:last-child { margin-bottom: 0; }

a { color: inherit; text-decoration: none; }

button, input, textarea, select {
  font: inherit; color: inherit; margin: 0;
}

button { cursor: pointer; background: none; border: none; padding: 0; }
button:disabled { cursor: not-allowed; }

img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--coal);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Widoczne tylko dla czytników ekranu. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- paski przewijania --- */
.scroll-y { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.scroll-y::-webkit-scrollbar { width: 10px; }
.scroll-y::-webkit-scrollbar-track { background: transparent; }
.scroll-y::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
.scroll-y::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

/* --- szkielet aplikacji --- */
#app { height: 100%; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
}

.main {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background: var(--bg);
}

/* Obszar widoku pod paskiem tytułu — musi wypełnić resztę wysokości,
   inaczej wewnętrzne `flex: 1` (wątek czatu, listy) nie ma czego wypełniać. */
.content {
  flex: 1; min-height: 0; min-width: 0;
  display: flex; flex-direction: column;
}

/* --- pasek boczny --- */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex; flex-direction: column;
  min-height: 0;
  border-right: 1px solid #000;
}

.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
}
.sidebar__mark {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--yellow);
  display: grid; place-items: center;
  overflow: hidden; flex: none;
}
.sidebar__mark img { width: 30px; height: auto; }
.sidebar__title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; line-height: 1.1; }
.sidebar__sub { font-size: 11px; color: var(--sidebar-muted); letter-spacing: .06em; text-transform: uppercase; }

.sidebar__section { padding: 6px 12px; }
.sidebar__label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--sidebar-muted); padding: 12px 8px 6px; font-weight: 600;
}

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }

.navlink {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--sidebar-fg); font-size: 14px; font-weight: 500;
  transition: background var(--dur) var(--ease);
  width: 100%; text-align: left;
}
.navlink:hover { background: var(--sidebar-hover); }
.navlink[aria-current="page"] { background: var(--yellow); color: var(--coal); font-weight: 700; }
.navlink__icon { width: 18px; height: 18px; flex: none; }
.navlink__badge {
  margin-left: auto; background: var(--yellow); color: var(--coal);
  font-size: 11px; font-weight: 700; min-width: 20px; height: 20px;
  border-radius: var(--r-pill); display: grid; place-items: center; padding: 0 6px;
}
/* `display: grid` przebiłby atrybut hidden — pusty znaczek nie może zostać kropką. */
.navlink__badge[hidden] { display: none; }
.navlink[aria-current="page"] .navlink__badge { background: var(--coal); color: var(--yellow); }

.sidebar__chats { flex: 1; min-height: 0; padding: 0 12px 12px; }

.chatlink {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--sidebar-muted); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  position: relative;
}
.chatlink:hover { background: var(--sidebar-hover); color: var(--sidebar-fg); }
.chatlink[aria-current="true"] { background: var(--sidebar-hover); color: var(--yellow); font-weight: 600; }
.chatlink__del {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 6px; display: none;
  place-items: center; color: var(--sidebar-muted);
}
.chatlink:hover .chatlink__del { display: grid; }
.chatlink__del:hover { background: #3d3d3d; color: #fff; }

.sidebar__foot {
  padding: 12px; border-top: 1px solid #2e2e2e;
  display: flex; align-items: center; gap: 10px;
}
.sidebar__phone { font-size: 13px; font-weight: 600; }
.sidebar__logout { margin-left: auto; font-size: 12px; color: var(--sidebar-muted); }
.sidebar__logout:hover { color: var(--yellow); text-decoration: underline; }

/* --- nagłówek treści --- */
.topbar {
  height: var(--header-h); flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__title { font-size: 17px; font-weight: 700; }
.topbar__spacer { flex: 1; }

/* --- responsywność --- */
.sidebar__toggle { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, var(--sidebar-w));
    z-index: 60; transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
  }
  .shell[data-nav="open"] .sidebar { transform: none; }
  .shell[data-nav="open"]::after {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50;
  }
  .sidebar__toggle { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); }
  .sidebar__toggle:hover { background: var(--surface-sunk); }
}
