/*
 * Community Hub design system — Warm & Friendly
 * Version 2.0
 *
 * This is the single active platform theme layer. The legacy Hub stylesheet
 * continues to provide feature-specific layout, while this file owns shared
 * tokens, typography, surfaces, controls, navigation, responsive behaviour
 * and dark mode. Page-specific assets should not redefine these foundations.
 */

:root {
  color-scheme: light;

  /* Platform palette. Tenant branding may override the two brand colours. */
  --green: #667d36;
  --forest: #52672b;
  --deep-forest: #36451f;
  --leaf: #98a963;
  --orange: #d96f32;
  --ink: #342d27;
  --muted: #77695f;

  /* Surfaces */
  --hub-page-bg: #f7e3d2;
  --hub-surface: #fffdf4;
  --hub-surface-subtle: #fffaf0;
  --hub-surface-tint: #f7f2e5;
  --hub-header-bg: #fff9f1;
  --hub-nav-bg: #fff9f1;
  --hub-border: #ded0bf;
  --hub-border-strong: #b9a58e;

  /* Geometry and rhythm */
  --hub-content-width: 1220px;
  --hub-radius-sm: 10px;
  --hub-radius: 16px;
  --hub-radius-lg: 22px;
  --hub-control-height: 44px;
  --hub-card-padding: 18px;
  --hub-page-gap: 18px;
  --hub-grid-gap: 14px;

  /* Elevation */
  --hub-shadow-soft: 0 4px 16px rgba(64, 52, 39, .055);
  --hub-shadow-raised: 0 10px 28px rgba(64, 52, 39, .09);
  --hub-shadow-overlay: 0 24px 70px rgba(24, 28, 23, .28);

  /* Compatibility aliases used by the legacy feature layouts. */
  --cream: var(--hub-page-bg);
  --white: var(--hub-surface);
  --line: var(--hub-border);
  --mint: var(--hub-surface-tint);
  --sage-pale: #f4efdd;
  --shadow: var(--hub-shadow-soft);
  --card: var(--hub-surface);
  --card-shadow: var(--hub-shadow-soft);
}

html {
  font-size: 16px;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--hub-page-bg);
}

body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--hub-page-bg) !important;
  color: var(--ink) !important;
  font: 16px/1.55 "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif !important;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3 {
  color: var(--ink);
  line-height: 1.15;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.85rem, 4vw, 2.65rem);
  letter-spacing: -.035em;
}

h2 {
  font-size: clamp(1.3rem, 2.5vw, 1.85rem);
  letter-spacing: -.025em;
}

h3 {
  font-size: 1.08rem;
}

p,
li,
dd {
  overflow-wrap: anywhere;
}

a {
  color: var(--forest);
  text-underline-offset: 3px;
}

.muted,
.field-help,
label small {
  color: var(--muted) !important;
}

.eyebrow {
  color: var(--forest) !important;
  font-size: .75rem !important;
  font-weight: 800 !important;
  letter-spacing: .08em !important;
  text-transform: uppercase;
}

.lead {
  max-width: 46rem;
  color: var(--muted) !important;
  font-size: 1rem;
  line-height: 1.5;
}

/* Shell and navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--hub-header-bg) 96%, transparent) !important;
  border-bottom: 1px solid var(--hub-border) !important;
  box-shadow: 0 3px 16px rgba(94, 61, 37, .065) !important;
  backdrop-filter: blur(18px);
}

.header-inner {
  width: 100%;
  max-width: var(--hub-content-width) !important;
  min-height: 62px;
  margin: auto;
  padding: 9px 20px !important;
}

.brand-logo {
  width: auto !important;
  max-width: min(190px, 46vw) !important;
  max-height: 44px !important;
  object-fit: contain;
}

.nav {
  gap: 4px;
}

.nav a {
  min-height: 40px;
  padding: 9px 10px;
  border-radius: var(--hub-radius-sm) !important;
  font-size: .84rem;
  font-weight: 700;
  transition: background-color .15s ease, color .15s ease;
}

.nav a:hover,
.nav a:focus-visible,
.nav a.active,
.nav a[aria-current="page"] {
  color: var(--deep-forest);
  background: var(--sage-pale) !important;
}

.page {
  width: 100%;
  max-width: var(--hub-content-width) !important;
  margin: auto;
  padding: 20px 20px 68px !important;
}

.footer {
  color: var(--muted);
}

.section {
  margin: var(--hub-page-gap) 0 !important;
}

.section-heading,
.panel-heading,
.records-results-heading,
.document-category-heading,
.messages-inbox-heading,
.message-chat-heading,
.roster-role-heading {
  gap: 14px;
}

.section-heading h2,
.panel-heading h2,
.records-results-heading h2,
.document-category-heading h2,
.messages-inbox-heading h2,
.message-chat-heading h2 {
  color: var(--ink) !important;
}

/* Consistent page introductions: structure without another decorative card. */
.page-intro {
  align-items: flex-end !important;
  margin: 2px 0 20px !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.page-intro h1 {
  margin: 4px 0 6px !important;
  font-size: clamp(1.8rem, 4vw, 2.45rem) !important;
}

.page-intro .lead {
  margin: 0 !important;
}

/* Layout rhythm */
.action-grid,
.card-grid,
.split-grid,
.doc-grid,
.admin-grid,
.dashboard-overview,
.dashboard-lower,
.today-actions-list,
.my-shifts-list,
.settings-field-grid,
.logo-settings-grid {
  gap: var(--hub-grid-gap) !important;
}

/* Shared surfaces. Page-specific layouts can position these, but should not
   redefine their colour, border, radius or elevation. */
.card,
.action-card,
.success-card,
.auth-card,
.form-grid,
.filter-bar,
.table-wrap,
.settings-panel,
.training-card,
.shift-list-card,
.shift-calendar-card,
.messages-inbox,
.message-chat,
.message-chat-empty,
.record-mobile-card,
.admin-menu-card,
.form-catalogue-card,
.document-catalogue-card,
.settings-admin-card,
.notifications-card,
.dark-mode-card,
.settings-password-card,
.dashboard-message-tile,
.my-shifts-card,
.today-actions-empty,
.today-shift-group,
.training-empty {
  color: var(--ink);
  background: var(--hub-surface) !important;
  border: 1px solid var(--hub-border) !important;
  border-radius: var(--hub-radius) !important;
  box-shadow: var(--hub-shadow-soft) !important;
}

.card,
.action-card,
.settings-panel {
  padding: var(--hub-card-padding) !important;
}

.action-card {
  background: var(--hub-surface-subtle) !important;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.action-card:hover,
.action-card:focus-within,
.admin-menu-card:hover,
.admin-menu-card:focus-visible,
.form-catalogue-card:hover,
.document-catalogue-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--green) 28%, var(--hub-border)) !important;
  box-shadow: var(--hub-shadow-raised) !important;
}

/* Keep nested content quieter than its parent surface. */
.card .card,
.settings-panel .card,
.controlled-document-fields,
.assignment-panel,
.roster-role-panel {
  background: color-mix(in srgb, var(--hub-surface) 92%, var(--hub-surface-tint)) !important;
  border-color: var(--hub-border) !important;
  box-shadow: none !important;
}

/* Controls and actions */
.button {
  min-height: var(--hub-control-height) !important;
  padding: 9px 14px !important;
  border-radius: 11px !important;
  font-size: .9rem;
  font-weight: 760 !important;
  line-height: 1.25;
  text-align: center;
  transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
}

.button:focus-visible,
.nav a:focus-visible,
.text-link:focus-visible,
.back-link:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--orange) 42%, transparent);
  outline-offset: 2px;
}

.button.primary {
  color: #fff !important;
  background: var(--orange) !important;
  border-color: var(--orange) !important;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--orange) 17%, transparent) !important;
}

.button.ghost,
.button:not(.primary):not(.danger) {
  color: var(--ink) !important;
  background: var(--hub-surface) !important;
  border: 1px solid var(--hub-border) !important;
  box-shadow: none !important;
}

.button.danger {
  color: #8d301f;
  background: color-mix(in srgb, #b65332 9%, var(--hub-surface)) !important;
  border: 1px solid color-mix(in srgb, #b65332 32%, var(--hub-border)) !important;
}

.button.small {
  min-height: 40px !important;
  padding: 7px 11px !important;
  font-size: .82rem !important;
}

.text-link,
.back-link {
  color: var(--forest) !important;
  font-weight: 750;
}

.text-link:hover,
.back-link:hover {
  color: var(--deep-forest) !important;
  text-decoration: underline;
}

label {
  color: var(--ink);
  font-size: .9rem;
  font-weight: 700 !important;
}

input,
select,
textarea {
  min-height: var(--hub-control-height);
  padding: 10px 12px !important;
  color: var(--ink) !important;
  background: var(--hub-surface-subtle) !important;
  border: 1px solid color-mix(in srgb, var(--hub-border) 72%, #9f978c) !important;
  border-radius: 11px !important;
  box-shadow: none !important;
}

textarea {
  min-height: 108px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none !important;
  border-color: var(--green) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent) !important;
}

/* Feedback and statuses */
.notice,
.alert {
  padding: 12px 14px !important;
  border-radius: 13px !important;
  box-shadow: none !important;
}

.notice {
  background: color-mix(in srgb, var(--green) 8%, var(--hub-surface)) !important;
  border-color: color-mix(in srgb, var(--green) 22%, var(--hub-border)) !important;
}

.alert {
  background: color-mix(in srgb, var(--orange) 9%, var(--hub-surface)) !important;
  border-color: color-mix(in srgb, var(--orange) 25%, var(--hub-border)) !important;
}

.status,
.tag,
.record-edited-badge {
  padding: 4px 9px !important;
  color: var(--forest) !important;
  background: var(--sage-pale) !important;
  border-radius: 999px !important;
  font-size: .78rem !important;
  font-weight: 780 !important;
}

/* Dashboard personality is limited to the welcome area. Operational content
   below it follows the same quiet surface hierarchy as every other page. */
.dashboard-hero {
  position: relative;
  isolation: isolate;
  min-height: 150px !important;
  margin: 4px 0 var(--hub-page-gap) !important;
  padding: 25px 28px !important;
  overflow: hidden;
  align-items: center !important;
  color: #342d27 !important;
  border: 1px solid #d7b58f !important;
  border-radius: var(--hub-radius-lg) !important;
  box-shadow: var(--hub-shadow-raised) !important;
  background:
    radial-gradient(circle at 82% 15%, rgba(217, 111, 50, .28) 0 17%, transparent 18%),
    radial-gradient(circle at 72% 78%, rgba(102, 125, 54, .19) 0 23%, transparent 24%),
    linear-gradient(135deg, #ffe3cb 0%, #efc9a7 51%, #dde2bd 100%) !important;
}

.dashboard-hero::after {
  content: "";
  position: absolute;
  right: -58px;
  bottom: -86px;
  width: 230px;
  height: 230px;
  border-radius: 48% 52% 56% 44%;
  background: color-mix(in srgb, var(--green) 17%, transparent);
  transform: rotate(18deg);
  pointer-events: none;
}

.dashboard-hero .hero-copy {
  position: relative;
  z-index: 2;
  max-width: 720px;
}

.dashboard-hero h1,
.dashboard-hero .lead {
  color: #342d27 !important;
  text-shadow: none !important;
}

.dashboard-hero .eyebrow {
  color: var(--forest) !important;
}

.dashboard-hero h1 {
  margin: 5px 0 8px !important;
  font-size: clamp(1.85rem, 4vw, 2.45rem) !important;
}

.dashboard-hero .lead {
  max-width: 42rem;
  margin-bottom: 0 !important;
  opacity: .86;
}

.dashboard-hero .hero-art {
  display: none !important;
}

/* Operational component polish */
.form-shell {
  max-width: 820px !important;
}

.form-heading {
  margin-bottom: 16px !important;
}

.form-grid {
  gap: 14px !important;
  padding: var(--hub-card-padding) !important;
}

.forms-catalogue .form-catalogue-tools,
.document-catalogue-tools,
.filter-bar {
  margin: 14px 0 18px !important;
  padding: 14px !important;
  background: color-mix(in srgb, var(--hub-surface) 96%, var(--sage-pale)) !important;
}

.form-catalogue-card,
.document-catalogue-card {
  padding: 15px 16px !important;
}

.training-card {
  overflow: hidden;
}

.training-document {
  min-height: 56px;
  padding: 13px 15px !important;
}

.shift-calendar-card,
.shift-list-card {
  padding: 17px !important;
}

.shift-week-calendar .shift-week-day-name {
  font-size: .84rem !important;
}

.shift-week-calendar .shift-week-status {
  font-size: .72rem !important;
}

.shift-week-calendar .shift-week-nav {
  min-width: 44px;
  min-height: 44px;
}

.messages-layout {
  gap: var(--hub-grid-gap) !important;
}

.messages-inbox,
.message-chat,
.message-chat-empty {
  overflow: hidden;
}

.message-bubble {
  font-size: .94rem;
}

.table-wrap,
.records-desktop-table {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

/* Bottom navigation. Active state must be explicit; Home is not assumed. */
.mobile-nav {
  background: color-mix(in srgb, var(--hub-nav-bg) 97%, transparent) !important;
  border-top: 1px solid var(--hub-border) !important;
  box-shadow: 0 -8px 24px rgba(94, 61, 37, .11) !important;
  backdrop-filter: blur(18px);
}

.mobile-nav.mobile-nav-six {
  grid-auto-flow: unset;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.mobile-nav.mobile-nav-five {
  grid-auto-flow: unset;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.mobile-nav a {
  display: grid;
  min-width: 0;
  min-height: 54px;
  align-content: center;
  justify-items: center;
  gap: 3px;
  padding: 4px 2px;
  color: var(--muted) !important;
  font-size: .72rem !important;
  line-height: 1.1;
}

.mobile-nav a > span:last-child {
  width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-nav-icon {
  font-size: 1.42rem !important;
}

.mobile-nav a:hover,
.mobile-nav a:focus-visible,
.mobile-nav a.active,
.mobile-nav a[aria-current="page"] {
  color: var(--forest) !important;
}

/* Dark mode changes colour only. Geometry and spacing remain shared. */
html.dark-mode {
  color-scheme: dark;
  --hub-page-bg: #2a1f19;
  --hub-surface: #342f28;
  --hub-surface-subtle: #3b352e;
  --hub-surface-tint: #3a342d;
  --hub-header-bg: #2b211b;
  --hub-nav-bg: #2f251e;
  --hub-border: #5a4c3d;
  --hub-border-strong: #806b55;
  --ink: #f4eee6;
  --muted: #c1b5a7;
  --sage-pale: #413a2f;
}

html.dark-mode body,
html.dark-mode .page {
  color: var(--ink) !important;
  background: var(--hub-page-bg) !important;
}

html.dark-mode .dashboard-hero {
  border-color: #65503b !important;
  background:
    radial-gradient(circle at 82% 15%, rgba(217, 111, 50, .23) 0 17%, transparent 18%),
    radial-gradient(circle at 72% 78%, rgba(133, 157, 83, .17) 0 23%, transparent 24%),
    linear-gradient(135deg, #3d2b21 0%, #452d20 51%, #343727 100%) !important;
}

html.dark-mode .dashboard-hero h1,
html.dark-mode .dashboard-hero .lead {
  color: #f6efe6 !important;
}

html.dark-mode .dashboard-hero .eyebrow {
  color: #c6cf98 !important;
}

html.dark-mode .document-viewer {
  background: #181713 !important;
}

html.dark-mode .button.danger {
  color: #ffd4ce;
}

/* Responsive rules */
@media (max-width: 980px) {
  .admin-grid,
  .dashboard-overview,
  .dashboard-lower {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .site-header {
    position: relative;
    min-height: 56px;
  }

  .header-inner {
    min-height: 56px;
    padding: 7px 14px !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
  }

  .brand {
    width: auto !important;
    max-width: 72vw;
  }

  .brand-logo {
    max-width: min(165px, 58vw) !important;
    max-height: 38px !important;
  }

  .brand-context,
  .nav {
    display: none !important;
  }

  .page {
    padding: 14px 14px 92px !important;
  }

  .mobile-nav {
    gap: 0;
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom)) !important;
  }

  .home-account-actions {
    gap: 10px;
    justify-content: center;
  }

  .home-account-actions .button {
    min-width: 104px;
  }

  .section {
    margin: 14px 0 !important;
  }

  .page-intro {
    margin-bottom: 16px !important;
  }

  .page-intro h1 {
    font-size: 1.75rem !important;
  }

  .page-intro .lead {
    font-size: .94rem !important;
  }

  .card,
  .action-card,
  .settings-panel {
    padding: 15px !important;
  }

  .dashboard-hero {
    min-height: 136px !important;
    margin-top: 0 !important;
    padding: 19px !important;
    border-radius: 18px !important;
  }

  .dashboard-hero h1 {
    font-size: 1.7rem !important;
  }

  .dashboard-hero .lead {
    font-size: .9rem !important;
  }

  .section-heading {
    margin-bottom: 10px !important;
  }

  .section-heading h2,
  .panel-heading h2 {
    margin-bottom: 4px !important;
  }

  .form-grid {
    gap: 12px !important;
    padding: 15px !important;
  }

  .form-actions {
    gap: 8px !important;
  }

  .form-actions .button {
    flex: 1 1 140px;
  }

  .button.small {
    min-height: 42px !important;
  }

  .records-page .records-desktop-table {
    display: none;
  }

  .records-mobile-list {
    display: grid;
  }
}

@media (max-width: 430px) {
  .section-heading,
  .panel-heading {
    align-items: flex-start;
  }

  .shift-week-calendar .shift-week-status,
  .shift-week-calendar .shift-week-count {
    font-size: .72rem !important;
  }
}

/* Accessibility: motion is optional and focus is never communicated by motion
   alone. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
