/* ============================================================
   PORTAL — gateway + resident & staff dashboards
   ============================================================ */

/* ─────────────────────────────────────────────
   GATEWAY
   ───────────────────────────────────────────── */
.portal-gateway-body {
  background-color: var(--bc-panel-darker);
  min-height: 100svh;
}
.portal-gateway {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  gap: var(--sp-10);
}
.portal-gateway-logo img {
  height: 44px;
  width: auto;
}
.portal-gateway-heading {
  font-weight: 300;
  letter-spacing: var(--ls-display);
  color: #F8F5EE;
  text-align: center;
}
.portal-gateway-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 340px));
  gap: var(--sp-6);
}
@media (max-width: 720px) {
  .portal-gateway-cards { grid-template-columns: 1fr; width: 100%; max-width: 400px; }
}
.portal-gateway-card {
  background: rgba(248, 245, 238, 0.04);
  border: 1px solid var(--bc-border-dark);
  border-radius: var(--radius-md);
  padding: var(--sp-12) var(--sp-8);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-4);
  transition: border-color var(--duration-base) var(--ease-standard),
              transform var(--duration-base) var(--ease-standard);
}
.portal-gateway-card:hover {
  border-color: rgba(196, 169, 106, 0.5);
  transform: translateY(-3px);
}
.portal-gateway-card h2 {
  color: #F8F5EE;
  font-size: var(--t-h3);
}
.portal-gateway-card p {
  color: rgba(248, 245, 238, 0.7);
  font-size: var(--t-small);
}
.portal-gateway-icon {
  width: 48px;
  height: 48px;
}
.portal-gateway-icon--svg {
  color: #C4A96A;
}
.portal-gateway-demo {
  font-family: var(--font-label);
  font-size: var(--t-micro);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: rgba(248, 245, 238, 0.45) !important;
}
.portal-gateway-back .link-arrow {
  color: #C4A96A;
}

/* ─────────────────────────────────────────────
   APP SHELL
   ───────────────────────────────────────────── */
.portal-body {
  background-color: var(--bc-ivory);
}
.portal-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100svh;
}
.portal-sidebar {
  background-color: var(--bc-panel-darker);
  display: flex;
  flex-direction: column;
  padding: var(--sp-6) var(--sp-4);
  position: sticky;
  top: 0;
  height: 100svh;
}
.portal-sidebar-logo {
  display: block;
  padding: var(--sp-2) var(--sp-3) var(--sp-8);
}
.portal-sidebar-logo img {
  width: 36px;
  height: 36px;
}
.portal-nav {
  flex: 1;
}
.portal-nav ul {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.portal-nav a,
.portal-signout {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-label);
  font-size: var(--t-small);
  font-weight: 500;
  color: rgba(248, 245, 238, 0.65);
  transition: color var(--duration-fast) var(--ease-standard),
              background-color var(--duration-fast) var(--ease-standard);
}
.portal-nav a svg,
.portal-signout svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.portal-nav a:hover,
.portal-signout:hover {
  color: #F8F5EE;
  background-color: rgba(248, 245, 238, 0.06);
}
.portal-nav a.is-active {
  color: #C4A96A;
  background-color: rgba(196, 169, 106, 0.1);
}
.portal-signout {
  margin-top: var(--sp-4);
  border-top: 1px solid var(--bc-border-dark);
  border-radius: 0;
  padding-top: var(--sp-5);
}

.portal-main {
  padding: var(--sp-10) var(--sp-8) var(--sp-16);
  max-width: 1100px;
  width: 100%;
  min-width: 0;
  margin-inline: auto;
}

/* ── Welcome / header row ── */
.portal-welcome {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-6);
  margin-bottom: var(--sp-8);
}
.portal-welcome h1 {
  font-size: var(--t-h2);
  font-weight: 400;
}
.portal-welcome-date {
  color: var(--bc-mid);
  font-size: var(--t-small);
  margin-top: var(--sp-2);
}
.portal-header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* ── Stat cards ── */
.portal-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-8);
}
@media (max-width: 800px) {
  .portal-stats { grid-template-columns: repeat(2, 1fr); }
}
.portal-stat {
  border-top: 2px solid var(--bc-gold);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  padding: var(--sp-5);
}
.portal-stat-value {
  font-family: var(--font-display);
  font-size: var(--t-h2);
  line-height: 1.1;
  color: var(--bc-ink);
}
.portal-stat-label {
  font-family: var(--font-label);
  font-size: var(--t-micro);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--bc-mid);
  margin-top: var(--sp-2);
}

/* ── Two-column rows ── */
.portal-two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--sp-4);
  margin-bottom: var(--sp-8);
  align-items: start;
}
@media (max-width: 900px) {
  .portal-two-col { grid-template-columns: 1fr; }
}
.portal-panel-card {
  padding: var(--sp-6);
  margin-bottom: var(--sp-4);
}
.portal-card-heading {
  font-size: var(--t-h4);
  margin-bottom: var(--sp-5);
}
.portal-hint {
  font-size: var(--t-label);
  color: var(--bc-muted);
  margin-bottom: var(--sp-4);
}

/* ── Appointments ── */
.portal-appt-list {
  display: flex;
  flex-direction: column;
}
.portal-appt-list li {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding-block: var(--sp-4);
  border-bottom: 1px solid var(--bc-border);
}
.portal-appt-list li:last-child { border-bottom: none; }
.portal-date-badge {
  flex-shrink: 0;
  width: 56px;
  text-align: center;
  font-family: var(--font-label);
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--bc-gold);
  border: 1px solid var(--bc-border-strong);
  border-radius: var(--radius-sm);
  padding: var(--sp-2);
  line-height: 1.5;
}
.portal-appt-info {
  flex: 1;
  font-size: var(--t-small);
  color: var(--bc-mid);
}
.portal-appt-info strong { color: var(--bc-ink); font-weight: 500; }

/* ── Key worker ── */
.portal-keyworker {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-block: var(--sp-4) var(--sp-5);
}
.portal-keyworker-name {
  font-weight: 500;
}
.portal-keyworker-meta {
  font-size: var(--t-small);
  color: var(--bc-mid);
}

/* ── Avatars ── */
.portal-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--bc-gold);
  color: var(--bc-panel-dark);
  font-family: var(--font-label);
  font-size: var(--t-small);
  font-weight: 600;
}
.portal-avatar--lg {
  width: 56px;
  height: 56px;
  font-size: var(--t-body);
}

/* ── Goals ── */
.portal-goals-section { margin-bottom: var(--sp-8); }
.portal-goals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}
@media (max-width: 900px) {
  .portal-goals { grid-template-columns: 1fr; }
}
.portal-goal { padding: var(--sp-6); }
.portal-goal h3 {
  font-size: var(--t-h4);
  margin-bottom: var(--sp-2);
}
.portal-goal p {
  font-size: var(--t-small);
  color: var(--bc-mid);
  margin-bottom: var(--sp-4);
}
.portal-progress {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bc-parchment);
  border: 1px solid var(--bc-border);
  overflow: hidden;
}
.portal-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--bc-gold), var(--bc-gold-light));
  border-radius: var(--radius-full);
}
.portal-progress-label {
  font-family: var(--font-label);
  font-size: var(--t-label);
  color: var(--bc-gold);
  margin-top: var(--sp-2);
}

/* ── Wellbeing ── */
.portal-wellbeing { margin-bottom: var(--sp-8); }
.portal-wellbeing-options {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.wellbeing-option {
  font-size: 1.75rem;
  line-height: 1;
  padding: var(--sp-3);
  border: 1px solid var(--bc-border);
  border-radius: var(--radius-md);
  background: var(--bc-ivory);
  transition: transform var(--duration-base) var(--ease-standard),
              border-color var(--duration-base) var(--ease-standard);
}
.wellbeing-option:hover {
  transform: scale(1.08);
}
.wellbeing-option.is-selected {
  border: 2px solid var(--bc-gold);
  transform: scale(1.12);
}
.portal-wellbeing-note {
  font-size: var(--t-label);
  color: var(--bc-muted);
  margin-top: var(--sp-4);
}

/* ── Quick actions ── */
.portal-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
}

/* ── Staff: resident list ── */
.portal-resident-list li,
.portal-message-list li,
.portal-alert-list li {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding-block: var(--sp-4);
  border-bottom: 1px solid var(--bc-border);
}
.portal-resident-list li:last-child,
.portal-message-list li:last-child,
.portal-alert-list li:last-child { border-bottom: none; }
.portal-resident-info,
.portal-message-info,
.portal-alert-info {
  flex: 1;
  font-size: var(--t-small);
  color: var(--bc-mid);
}
.portal-resident-info strong,
.portal-message-info strong,
.portal-alert-info strong {
  color: var(--bc-ink);
  font-weight: 500;
}
.portal-resident-meta {
  font-size: var(--t-label);
  color: var(--bc-muted);
  text-align: right;
}
@media (max-width: 640px) {
  .portal-resident-meta { display: none; }
}

/* ── Staff: tasks ── */
.portal-task-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding-block: var(--sp-4);
  border-bottom: 1px solid var(--bc-border);
}
.portal-task-list li:last-child { border-bottom: none; }
.portal-task-info {
  font-size: var(--t-small);
  color: var(--bc-mid);
}
.portal-task-info strong { color: var(--bc-ink); font-weight: 500; }
.task-status-toggle { flex-shrink: 0; }

/* ── Staff: rota table ── */
.portal-table-wrap {
  overflow-x: auto;
}
.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-small);
}
.portal-table th {
  font-family: var(--font-label);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--bc-mid);
  text-align: left;
  padding: var(--sp-3);
  border-bottom: 1px solid var(--bc-border-strong);
}
.portal-table td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--bc-border);
  white-space: nowrap;
}

/* ── Staff: alerts ── */
.portal-alert-list li > svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--bc-gold);
}

/* ── Staff: occupancy ── */
.portal-occupancy {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.portal-occupancy-label {
  display: block;
  font-family: var(--font-label);
  font-size: var(--t-label);
  color: var(--bc-mid);
  margin-bottom: var(--sp-2);
}
.portal-occupancy-bar {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--bc-parchment);
  border: 1px solid var(--bc-border);
  overflow: hidden;
}
.portal-occupancy-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--bc-gold), var(--bc-gold-light));
}

/* ── Messages ── */
.portal-unread-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--bc-gold);
}

/* ─────────────────────────────────────────────
   MOBILE
   ───────────────────────────────────────────── */

/* Resident: bottom tab bar */
.portal-tabbar {
  display: none;
}
@media (max-width: 720px) {
  .portal-shell { grid-template-columns: 1fr; }
  .portal-sidebar { display: none; }
  .portal-main { padding: var(--sp-6) var(--sp-4) calc(var(--sp-16) + 56px); }

  .portal-tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-nav);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 56px;
    background: var(--bc-panel-darker);
    border-top: 1px solid var(--bc-border-dark);
  }
  .portal-tabbar a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: rgba(248, 245, 238, 0.6);
  }
  .portal-tabbar a.is-active { color: #C4A96A; }
  .portal-tabbar svg { width: 22px; height: 22px; }
}

/* Staff: drawer toggle */
.portal-drawer-toggle {
  display: none;
}
@media (max-width: 720px) {
  .portal-drawer-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: var(--sp-4);
    right: var(--sp-4);
    z-index: calc(var(--z-nav) + 2);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--bc-panel-darker);
    color: #F8F5EE;
    box-shadow: var(--shadow-md);
  }
  .portal-drawer-toggle svg { width: 22px; height: 22px; }

  /* Staff sidebar becomes a drawer */
  #staff-sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    z-index: calc(var(--z-nav) + 1);
    transform: translateX(-100%);
    transition: transform var(--duration-base) var(--ease-standard);
  }
  #staff-sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
}
