/* ==========================================================================
   PWMP MIS — desktop shell: ribbon, sidebar, footer
   Ribbon and footer are fixed; only the main column scrolls.
   ========================================================================== */

:root {
  --ribbon-h: 92px;
  --footer-h: 34px;
}

/* ==========================================================================
   Top ribbon
   ========================================================================== */
.ribbon {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  height: var(--ribbon-h);
  display: flex; align-items: stretch;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.ribbon::before {
  /* Brand rule along the very top, drawn from the emblem's own gradient. */
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--brand-gradient);
}

.ribbon-brand {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-5) 0 var(--sp-4);
  flex: none; border-right: 1px solid var(--divider);
  color: var(--text);
  min-width: var(--sidebar-w);
  transition: background var(--dur-fast);
}
.ribbon-brand:hover { background: var(--surface-2); color: var(--text); }
.ribbon-brand img {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: #fff; padding: 2px; box-shadow: var(--shadow-xs);
}
.ribbon-brand-text { min-width: 0; }
.ribbon-brand-text b {
  display: block; font-family: var(--font-display);
  font-size: var(--fs-md); line-height: 1.25; white-space: nowrap;
}
.ribbon-brand-text span {
  display: block; font-size: var(--fs-2xs); color: var(--text-subtle);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}

/* ---- Icon groups -------------------------------------------------------- */
.ribbon-groups {
  flex: 1; min-width: 0;
  display: flex; align-items: stretch;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
}
.ribbon-groups::-webkit-scrollbar { display: none; }

.ribbon-group {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: var(--sp-2) var(--sp-3) 3px;
  border-right: 1px solid var(--divider);
  flex: none;
}
.ribbon-group:last-child { border-right: 0; }
.ribbon-group-items { display: flex; gap: 2px; }
.ribbon-group-label {
  text-align: center; font-size: 10px; font-weight: 600;
  color: var(--text-subtle); letter-spacing: .03em;
  padding-top: 3px; white-space: nowrap;
}

.ribbon-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-width: 66px; padding: 6px 8px;
  border-radius: var(--r-sm); color: var(--text-muted);
  font-size: var(--fs-2xs); font-weight: 500; text-align: center;
  position: relative; overflow: hidden;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}
.ribbon-item:hover {
  background: var(--surface-3); color: var(--text); transform: translateY(-1px);
}
.ribbon-item:active { transform: translateY(0) scale(.96); }
.ribbon-item .ic {
  width: 24px; height: 24px; stroke-width: 1.6;
  transition: transform var(--dur-base) var(--ease-spring), color var(--dur-fast);
}
.ribbon-item:hover .ic { transform: scale(1.12); }
.ribbon-item span {
  max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.3;
}
.ribbon-item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.ribbon-item.is-active .ic { color: var(--primary); }
.ribbon-item.is-active::after {
  content: ''; position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%);
  width: 20px; height: 2px; border-radius: 2px; background: var(--primary);
  animation: ribbon-underline .3s var(--ease-out);
}
@keyframes ribbon-underline { from { width: 0; opacity: 0; } }

.ribbon-badge {
  position: absolute; top: 3px; right: 8px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-full);
  background: var(--red-500); color: #fff;
  font-size: 9px; font-weight: 700; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}

/* Colour the module icons so the ribbon reads as a map, not a wall of grey. */
.ribbon-item[data-tone="green"]  .ic { color: var(--green-500); }
.ribbon-item[data-tone="blue"]   .ic { color: var(--blue-500); }
.ribbon-item[data-tone="navy"]   .ic { color: var(--navy-500); }
.ribbon-item[data-tone="teal"]   .ic { color: var(--teal-500); }
.ribbon-item[data-tone="amber"]  .ic { color: var(--amber-500); }
.ribbon-item[data-tone="red"]    .ic { color: var(--red-500); }
.ribbon-item[data-tone="violet"] .ic { color: var(--violet-500); }
.ribbon-item[data-tone="grey"]   .ic { color: var(--text-subtle); }

/* ---- Right-hand controls ----------------------------------------------- */
.ribbon-tools {
  display: flex; align-items: center; gap: var(--sp-1);
  padding: 0 var(--sp-4); flex: none;
  border-left: 1px solid var(--divider);
}
.ribbon-user {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px 10px 6px 6px; border-radius: var(--r-full);
  color: var(--text); transition: background var(--dur-fast);
}
.ribbon-user:hover { background: var(--surface-3); color: var(--text); }
.ribbon-user-info { text-align: right; min-width: 0; }
.ribbon-user-info b { display: block; font-size: var(--fs-sm); line-height: 1.25; white-space: nowrap; }
.ribbon-user-info span { display: block; font-size: var(--fs-2xs); color: var(--text-subtle); white-space: nowrap; }

/* ==========================================================================
   Layout with the ribbon and footer in place
   ========================================================================== */
@media (min-width: 1024px) {
  /* Scoped to the app shell — the sign-in page loads this sheet for the vendor
     footer but has no ribbon to make room for. */
  body.has-shell { padding-top: var(--ribbon-h); padding-bottom: var(--footer-h); }

  .app { min-height: calc(100dvh - var(--ribbon-h) - var(--footer-h)); }

  .sidebar {
    top: var(--ribbon-h);
    height: calc(100dvh - var(--ribbon-h) - var(--footer-h));
  }
  .topbar { top: var(--ribbon-h); }

  /* The sidebar brand block is redundant once the ribbon carries it. */
  .sidebar-brand { display: none; }
  .sidebar-nav { padding-top: var(--sp-4); }
}

@media (max-width: 1023px) {
  .ribbon, .app-footer { display: none; }
}

/* ==========================================================================
   Fixed footer status bar
   ========================================================================== */
.app-footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 55;
  height: var(--footer-h);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-4);
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: var(--fs-2xs); color: var(--text-muted);
  white-space: nowrap;
}

.foot-seg { display: flex; align-items: center; gap: 6px; flex: none; }
.foot-seg + .foot-seg::before {
  content: ''; width: 1px; height: 14px; background: var(--divider);
  margin-right: var(--sp-3); margin-left: calc(-1 * var(--sp-2));
}
.foot-seg .ic { width: 13px; height: 13px; }

.foot-status-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: none;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 60%, transparent);
  animation: foot-pulse 2.4s ease-out infinite;
}
.foot-status-dot.is-offline { background: var(--danger); animation: none; }
@keyframes foot-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 55%, transparent); }
  70%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Live counters — the "hooks" strip */
.foot-hooks { display: flex; align-items: center; gap: var(--sp-3); flex: 1; min-width: 0; overflow: hidden; }
.foot-hook {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text-muted);
  font-size: var(--fs-2xs); flex: none;
  transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
}
.foot-hook:hover { background: var(--primary-soft); color: var(--primary); transform: translateY(-1px); }
.foot-hook b { font-variant-numeric: tabular-nums; font-weight: 700; }
.foot-hook .ic { width: 12px; height: 12px; }
.foot-hook.is-alert { background: var(--danger-soft); color: var(--danger-text); }
.foot-hook.is-alert:hover { background: var(--danger-soft); }
.foot-hook.is-warn { background: var(--warning-soft); color: var(--warning-text); }
.foot-hook.is-warn:hover { background: var(--warning-soft); }
.foot-hook.is-new { animation: hook-bump .5s var(--ease-spring); }
@keyframes hook-bump { 0% { transform: scale(1); } 45% { transform: scale(1.16); } 100% { transform: scale(1); } }

/* Progress sliver — the project at a glance, always visible */
.foot-progress {
  display: flex; align-items: center; gap: 7px; flex: none;
}
.foot-progress-track {
  width: 84px; height: 5px; border-radius: var(--r-full);
  background: var(--surface-3); overflow: hidden; position: relative;
}
.foot-progress-fill {
  height: 100%; border-radius: var(--r-full); background: var(--brand-gradient);
  transition: width 1s var(--ease-out);
}
.foot-progress-marker {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: var(--text); opacity: .45; border-radius: 1px;
}

/* One Miracle branding */
.foot-brand {
  display: flex; align-items: center; gap: 7px; flex: none;
  margin-left: auto; color: var(--text-subtle);
}
.foot-brand img { height: 17px; width: auto; flex: none; opacity: .9; }
.foot-brand a { color: var(--text-muted); font-weight: 600; }
.foot-brand a:hover { color: var(--primary); }
.foot-brand .wa {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-full);
  background: #25d36618; color: #1da851; font-weight: 600;
  transition: background var(--dur-fast);
}
.foot-brand .wa:hover { background: #25d36630; color: #1da851; }
:root[data-theme="dark"] .foot-brand .wa { color: #5ce08e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .foot-brand .wa { color: #5ce08e; }
}

.foot-clock { font-variant-numeric: tabular-nums; flex: none; }

@media (max-width: 1400px) {
  .foot-hooks .foot-hook:nth-child(n+4) { display: none; }
  .foot-brand span.tagline { display: none; }
}
@media (max-width: 1180px) {
  .foot-hooks .foot-hook:nth-child(n+3) { display: none; }
  .foot-progress { display: none; }
}

/* ==========================================================================
   Sign-in page footer (static variant)
   ========================================================================== */
.auth-credit {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-3);
  flex-wrap: wrap; margin-top: var(--sp-5);
  padding-top: var(--sp-4); border-top: 1px solid var(--divider);
  font-size: var(--fs-2xs); color: var(--text-subtle);
}
.auth-credit img { height: 26px; width: auto; opacity: .9; }
.auth-credit b { color: var(--text-muted); }
.auth-credit a { color: var(--text-muted); font-weight: 600; }
.auth-credit a:hover { color: var(--primary); }

/* ==========================================================================
   Print — the shell chrome never belongs on paper
   ========================================================================== */
@media print {
  .ribbon, .app-footer { display: none !important; }
  body { padding: 0 !important; }
}

/* Installed desktop app with the title bar hidden (window-controls-overlay): the
   ribbon becomes the title bar — draggable, and clear of the window buttons. */
@media (display-mode: window-controls-overlay) {
  .ribbon {
    padding-left: env(titlebar-area-x, 0px);
    padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw));
    -webkit-app-region: drag; app-region: drag;
  }
  .ribbon a, .ribbon button, .ribbon input, .ribbon select, .ribbon [role="button"] {
    -webkit-app-region: no-drag; app-region: no-drag;
  }
}
