/* AdminLTE-style frame for shared/layout.js.

   The sidebar and top bar share one theme colour (--chrome, text --chrome-ink)
   and the content area behind the cards is a light tint of it. Communities
   use their main colour; the admin console sets a pastel blue (admin.css). */

:root { --sidebar-w: 250px; --navbar-h: 57px; }

body.app-layout {
  min-height: 100vh;
  --chrome: var(--brand);
  --chrome-ink: var(--brand-ink);
  --tint: 10%;   /* how much of --chrome colours the content area */
  --side-text: color-mix(in srgb, var(--chrome-ink) 85%, var(--chrome));
  --side-line: color-mix(in srgb, var(--chrome-ink) 15%, transparent);
  --bg: color-mix(in srgb, var(--chrome) var(--tint), #ffffff);
}
/* In dark mode the theme colour is deepened so it doesn't glare. */
@media (prefers-color-scheme: dark) {
  body.app-layout {
    --chrome: color-mix(in srgb, var(--brand) 55%, #15181b);
    --chrome-ink: #ffffff;
    --bg: color-mix(in srgb, var(--chrome) 18%, #16191c);
  }
}

/* ---------- sidebar ---------- */
.app-sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w); z-index: 40;
  background: var(--chrome); color: var(--side-text);
  box-shadow: 0 14px 28px rgba(0,0,0,.25), 0 10px 10px rgba(0,0,0,.22);
  display: flex; flex-direction: column; overflow-y: auto;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-height: var(--navbar-h);
  border-bottom: 1px solid var(--side-line); color: var(--chrome-ink); text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; color: var(--chrome-ink); }
.brand-logo img, .brand-mark {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: block; flex: none;
  box-shadow: 0 3px 6px rgba(0,0,0,.16), 0 3px 6px rgba(0,0,0,.23); background: #fff;
}
.brand-mark { display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--chrome-ink) 22%, var(--chrome)); color: var(--chrome-ink); font-weight: 700; font-size: 17px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 17px; font-weight: 300; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.brand-sub { font-size: 12px; color: var(--side-text); opacity: .8; }

.sidebar-nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-header { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: color-mix(in srgb, var(--chrome-ink) 60%, var(--chrome)); padding: 14px 10px 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius);
  color: var(--side-text); text-decoration: none; font-size: 15px;
}
.nav-link:hover { background: color-mix(in srgb, var(--chrome-ink) 10%, transparent); color: var(--chrome-ink); text-decoration: none; }
.nav-link { border-radius: 8px; }
.nav-link.active {
  background: color-mix(in srgb, var(--chrome-ink) 16%, transparent); color: var(--chrome-ink); font-weight: 600;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chrome-ink) 10%, transparent);
}
@media (prefers-color-scheme: dark) { .app-sidebar .nav-link { color: var(--side-text); } .app-sidebar .nav-link.active, .sidebar-brand { color: var(--chrome-ink); } }

/* ---------- main column ---------- */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .25s ease; }
.app-navbar {
  position: sticky; top: 0; z-index: 30; height: var(--navbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--chrome); color: var(--chrome-ink); border-bottom: 1px solid var(--side-line);
}
.nav-toggle { display: none; border: 0; background: none; color: var(--chrome-ink); padding: 6px; min-height: 0; }
.navbar-title { font-size: 15px; color: var(--side-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.breadcrumb svg { flex: none; opacity: .75; }
.breadcrumb .crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--side-text); }
.breadcrumb a.crumb:hover { color: var(--chrome-ink); text-decoration: underline; }
.breadcrumb .crumb.current { color: var(--chrome-ink); font-weight: 600; }
.breadcrumb svg:first-child { color: var(--chrome-ink); opacity: 1; }
/* Phones: only the current page. */
@media (max-width: 600px) { .breadcrumb > :not(.current) { display: none; } }
.navbar-right { margin-left: auto; position: relative; }

.user-toggle { border: 0; background: none; padding: 4px 6px; min-height: 0; gap: 8px; color: var(--chrome-ink); }
.user-toggle .avatar { background: color-mix(in srgb, var(--chrome-ink) 22%, var(--chrome)); color: var(--chrome-ink); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 13px; flex: none;
}
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 260px; z-index: 50; padding: 6px;
  background: var(--card); color: var(--text); border: 1px solid var(--card-line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
.user-head { padding: 10px 12px 12px; }
.user-name { font-size: 16px; font-weight: 600; }
.user-email { font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }
.role-badge {
  display: inline-block; margin-top: 8px; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600;
  color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent);
}
.user-links { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; border-top: 1px solid var(--line); }
.user-links a, .user-signout {
  display: flex; gap: 12px; align-items: center; padding: 8px 12px; border-radius: 8px; font-size: 15px;
  color: var(--text); text-decoration: none;
}
.user-links a svg { color: var(--muted); }
.user-links a:hover, .user-links a:focus-visible { background: color-mix(in srgb, var(--text) 7%, transparent); text-decoration: none; }
.user-links a:focus-visible, .user-signout:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--brand) 60%, #8fb8ff); }
.user-sep { height: 1px; background: var(--line); margin: 6px 0; }
.user-menu .app-version { padding: 6px 12px 4px; font-size: 12px; color: var(--muted); }
button.user-signout { width: 100%; justify-content: flex-start; border: 0; background: none; min-height: 0; color: var(--danger); }
button.user-signout:hover { background: color-mix(in srgb, var(--danger) 9%, transparent); filter: none; }

.app-banner:empty { display: none; }
.app-content { padding: 20px; flex: 1; width: 100%; max-width: 1400px; }

/* ---------- phones and small tablets: sidebar slides in ---------- */
.sidebar-overlay { display: none; }
@media (max-width: 991px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-main { margin-left: 0; }
  .nav-toggle { display: inline-flex; }
  body.sidebar-open .app-sidebar { transform: none; }
  body.sidebar-open .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.4); }
  .app-content { padding: 14px; }
}
@media (max-width: 520px) {
  .user-toggle-name { display: none; }
  .user-menu { width: min(280px, calc(100vw - 24px)); }
}

/* ---------- page grids used by several consoles ---------- */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.dash-grid > .card, .dash-grid > div > .card:last-child { margin-bottom: 16px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .cal-layout { grid-template-columns: 1fr; } }
.day-panel h2 { font-size: 17px; }
/* a whole list row that's a button */
button.link-row { display: block; text-align: left; border: 0; background: none; padding: 0; min-height: 0; color: inherit; width: 100%; }
button.link-row:hover .title { color: var(--brand); text-decoration: underline; }
a.sidebar-brand, a.sidebar-brand:hover { color: var(--chrome-ink); }
.user-links a, .user-links a:hover { color: var(--text); }
/* The side panel next to the calendar is narrow: one field per row. */
.day-panel .grid-2 { grid-template-columns: minmax(0, 1fr); }
/* Date + time pair (event form) */
.field.date-time { margin-bottom: 14px; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.date-time-inputs { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 8px; }
.date-time-inputs input[hidden] { display: none; }
.date-time-inputs:has(input[type=time][hidden]) { grid-template-columns: minmax(0, 1fr); }
.date-time .hint { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
