/* =========================================================================
   Koyne — layout.css
   The app shell — sidebar + main area used by every authenticated screen.
   ========================================================================= */

.k-shell { display: flex; min-height: 100vh; align-items: stretch; }
.k-main  { flex: 1; padding: 28px 36px 60px; min-width: 0; max-width: 100%; }

.k-sidebar {
  width: 240px; flex-shrink: 0;
  padding: 28px 18px 22px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
[data-theme="dark"] .k-sidebar {
  background: var(--koyne-dark-bg);
  border-right-color: var(--koyne-dark-border);
}
.k-sidebar__brand { padding: 0 8px 28px; }
.k-sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.k-sidebar__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--fg-2);
  text-decoration: none;
  transition: all var(--dur-base) var(--ease-out);
}
.k-sidebar__item:hover { background: var(--surface-2); color: var(--fg); }
.k-sidebar__item--active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
[data-theme="dark"] .k-sidebar__item { color: var(--koyne-dark-muted); }
[data-theme="dark"] .k-sidebar__item:hover { color: #F4F2FF; background: rgba(139,92,246,0.10); }
[data-theme="dark"] .k-sidebar__item--active {
  background: rgba(139,92,246,0.18); color: var(--koyne-lavender-300);
}
/* ---- Sidebar "Add new" expandable section ------------------------------ */
.k-sidebar__add-section { list-style: none; }
.k-sidebar__add-toggle { list-style: none; }
.k-sidebar__add-toggle::-webkit-details-marker { display: none; }
/* Chevron starts pointing right (closed), rotates down when open */
.k-sidebar__add-toggle svg:last-child {
  margin-left: auto;
  transform: rotate(-90deg);
  transition: transform var(--dur-fast) var(--ease-out);
}
.k-sidebar__add-section[open] .k-sidebar__add-toggle svg:last-child {
  transform: rotate(0deg);
}
.k-sidebar__sub-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 4px 36px;
}
.k-sidebar__sub-item {
  background: transparent;
  border: 0;
  text-align: left;
  width: 100%;
  padding: 7px 12px;
  font: inherit;
  font-size: var(--fs-body-sm);
  color: var(--fg-3);
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.k-sidebar__sub-item:hover { background: var(--surface-2); color: var(--fg); }
[data-theme="dark"] .k-sidebar__sub-item:hover {
  background: rgba(139,92,246,0.10); color: #F4F2FF;
}

.k-sidebar__bottom { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.k-sidebar__user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px; border-radius: 10px;
}
.k-sidebar__avatar {
  width: 36px; height: 36px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.k-sidebar__user-name { font-size: 13px; font-weight: 600; color: var(--fg); }
.k-sidebar__user-sub  { font-size: 11px; color: var(--fg-3); }
.k-sidebar__divider {
  border-top: 1px solid var(--divider);
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px; font-size: 13px; color: var(--fg-2);
}
[data-theme="dark"] .k-sidebar__divider { border-top-color: var(--koyne-dark-border); }
.k-sidebar__theme-toggle {
  background: none; border: 0; padding: 0; cursor: pointer;
  width: 36px; height: 20px; border-radius: 999px;
  background: #CBD5E1; position: relative;
  transition: background var(--dur-base) var(--ease-out);
}
.k-sidebar__theme-toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 999px;
  background: #FFF; transition: left var(--dur-base) var(--ease-out);
}
[data-theme="dark"] .k-sidebar__theme-toggle { background: var(--accent); }
[data-theme="dark"] .k-sidebar__theme-toggle::after { left: 18px; }

@media (max-width: 1100px) {
  .k-sidebar { display: none; }
  .k-main { padding: 20px; }
}

/* ---- Collapsible sidebar ------------------------------------------------ */
.k-sidebar { transition: width var(--dur-base) var(--ease-out); }

.k-shell--nav-collapsed .k-sidebar {
  width: 72px;
  padding: 20px 10px;
  overflow: hidden;
}
/* Hide wordmark */
.k-shell--nav-collapsed .k-logo__word { display: none; }
/* Centre icons, hide text labels */
.k-shell--nav-collapsed .k-sidebar__item {
  justify-content: center;
  padding: 10px;
}
.k-shell--nav-collapsed .k-sidebar__item span,
.k-shell--nav-collapsed .k-sidebar__section { display: none; }
/* Hide "Add new" expandable entirely */
.k-shell--nav-collapsed .k-sidebar__add-section { display: none; }
/* Hide user block and all bottom rows except the collapse toggle */
.k-shell--nav-collapsed .k-sidebar__user { display: none; }
.k-shell--nav-collapsed .k-sidebar__divider:not(.k-sidebar__collapse-toggle) { display: none; }
/* Collapse toggle: panel-left icons swap, label hides */
.k-collapse-icon--collapsed { display: none; }
.k-shell--nav-collapsed .k-collapse-icon--expanded { display: none; }
.k-shell--nav-collapsed .k-collapse-icon--collapsed { display: block; }
.k-shell--nav-collapsed .k-collapse-label { display: none; }
/* Centre the toggle button when collapsed */
.k-shell--nav-collapsed .k-sidebar__collapse-toggle { justify-content: center; padding: 10px; }
