/* ==========================================================================
 * panduh Outer Hub Shell Styles (/css/hub-shell.css)
 * Lightweight, zero-dependency desktop 66px rail + mobile 56px bottom dock
 * ========================================================================== */

:root {
  --hub-font: "InterVariable", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --hub-font-mono: ui-monospace, SFMono-Regular, "Menlo", "Monaco", "Consolas", monospace;

  --hub-bg-rail: #111214;
  --hub-bg-stage: #111214;
  --hub-bg-surface: #1e1f22;
  --hub-bg-elevated: #2b2d31;
  --hub-bg-active: #35373c;
  --hub-border: rgba(255, 255, 255, 0.08);
  --hub-text: #f2f3f5;
  --hub-text-muted: #949ba4;
  --hub-brand: #5865f2;
  --hub-brand-hover: #4752c4;
  --hub-green: #23a55a;
  --hub-yellow: #f0b232;
  --hub-red: #f23f43;

  --rail-w: 66px;
  --dock-h: 56px;
  --preview-h: 0px;

  --squircle-42: path("M 21.0000 0 L 21.0000 0.0000 c 6.5232 0.0000 9.7848 0.0000 12.3576 1.0657 a 14.0000 14.0000 0 0 1 7.5767 7.5767 c 1.0657 2.5728 1.0657 5.8344 1.0657 12.3576 L 42.0000 21.0000 c 0.0000 6.5232 0.0000 9.7848 -1.0657 12.3576 a 14.0000 14.0000 0 0 1 -7.5767 7.5767 c -2.5728 1.0657 -5.8344 1.0657 -12.3576 1.0657 L 21.0000 42.0000 c -6.5232 0.0000 -9.7848 0.0000 -12.3576 -1.0657 a 14.0000 14.0000 0 0 1 -7.5767 -7.5767 c -1.0657 -2.5728 -1.0657 -5.8344 -1.0657 -12.3576 L 0.0000 21.0000 c 0.0000 -6.5232 0.0000 -9.7848 1.0657 -12.3576 a 14.0000 14.0000 0 0 1 7.5767 -7.5767 c 2.5728 -1.0657 5.8344 -1.0657 12.3576 -1.0657 Z");
  --squircle-42-active: path("M 16.5000 0 L 25.5000 0 c 6.0730 0 9.1095 0 11.3862 1.2750 a 10.0000 10.0000 0 0 1 3.8387 3.8387 c 1.2750 2.2767 1.2750 5.3132 1.2750 11.3862 L 42.0000 16.5000 L 42.0000 25.5000 c 0 6.0730 0 9.1095 -1.2750 11.3862 a 10.0000 10.0000 0 0 1 -3.8387 3.8387 c -2.2767 1.2750 -5.3132 1.2750 -11.3862 1.2750 L 25.5000 42.0000 L 16.5000 42.0000 c -6.0730 0 -9.1095 0 -11.3862 -1.2750 a 10.0000 10.0000 0 0 1 -3.8387 -3.8387 c -1.2750 -2.2767 -1.2750 -5.3132 -1.2750 -11.3862 L 0 25.5000 L 0 16.5000 c 0 -6.0730 0 -9.1095 1.2750 -11.3862 a 10.0000 10.0000 0 0 1 3.8387 -3.8387 c 2.2767 -1.2750 5.3132 -1.2750 11.3862 -1.2750 Z");
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--hub-bg-stage);
  color: var(--hub-text);
  font-family: var(--hub-font);
  -webkit-font-smoothing: antialiased;
}

body.has-preview-banner {
  --preview-h: 38px;
}

/* ── Shell Layout ──────────────────────────────────────────────────────── */
#hub-shell {
  display: flex;
  width: 100vw;
  height: calc(100dvh - var(--preview-h));
  margin-top: var(--preview-h);
  overflow: hidden;
  background: var(--hub-bg-stage);
}

body.unauthed #hub-rail,
body.unauthed #hub-mobile-dock {
  display: none !important;
}

/* ── Desktop 66px Left Rail ────────────────────────────────────────────── */
#hub-rail {
  width: var(--rail-w);
  min-width: var(--rail-w);
  height: 100%;
  background: var(--hub-bg-rail);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  z-index: 40;
  user-select: none;
}

.rail-scroll {
  flex: 1 1 auto;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  scrollbar-width: none;
}
.rail-scroll::-webkit-scrollbar {
  display: none;
}

.rail-bottom {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
}

.rail-divider {
  width: 30px;
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 2px 0;
  flex-shrink: 0;
}

.rail-item {
  position: relative;
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Discord-style left active/unread indicator pill */
.rail-pill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 0;
  border-radius: 0 4px 4px 0;
  background: #ffffff;
  opacity: 0;
  transition: height 0.16s cubic-bezier(0.2, 0, 0, 1), opacity 0.16s ease;
  pointer-events: none;
}

.rail-item.has-unread .rail-pill {
  height: 8px;
  opacity: 1;
}
.rail-item:hover .rail-pill {
  height: 20px;
  opacity: 1;
}
.rail-item.active .rail-pill {
  height: 36px;
  opacity: 1;
}

.rail-btn {
  width: 42px;
  height: 42px;
  border: none;
  padding: 0;
  background: #1e1f22;
  color: #b5bac1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  clip-path: var(--squircle-42);
  transition: background-color 0.16s ease, color 0.16s ease, clip-path 0.2s cubic-bezier(0.2, 0, 0, 1), transform 0.12s ease;
  outline: none;
}

.rail-btn:hover,
.rail-item.active .rail-btn {
  background: var(--hub-brand);
  color: #ffffff;
  clip-path: var(--squircle-42-active);
}

.rail-btn:active {
  transform: translateY(1px);
}

.rail-btn.subtle {
  background: rgba(255, 255, 255, 0.04);
}
.rail-btn.subtle:hover {
  background: var(--hub-bg-elevated);
  color: #ffffff;
}

.rail-badge {
  position: absolute;
  right: 8px;
  bottom: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--hub-red);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid var(--hub-bg-rail);
  pointer-events: none;
  z-index: 3;
}

.rail-badge.warning {
  background: var(--hub-yellow);
  color: #111214;
}

.rail-badge.zero {
  background: #2b2d31;
  color: #949ba4;
  font-weight: 700;
}

/* Floating tooltip on desktop rail */
#hub-tooltip {
  position: fixed;
  left: 74px;
  top: 0;
  transform: translateY(-50%) scale(0.96);
  background: #111214;
  color: #f2f3f5;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  padding: 6px 11px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 9999;
}
#hub-tooltip.visible {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* ── Main App Stage ────────────────────────────────────────────────────── */
#hub-stage {
  flex: 1 1 0%;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--hub-bg-stage);
}

.hub-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: var(--hub-bg-stage);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

.hub-frame.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

/* Smooth Loading Skeleton Overlay */
#hub-stage-loader {
  position: absolute;
  inset: 0;
  background: var(--hub-bg-stage);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 25;
}
#hub-stage-loader.visible {
  display: flex;
}

.hub-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(88, 101, 242, 0.2);
  border-top-color: var(--hub-brand);
  animation: hubSpin 0.72s linear infinite;
}
@keyframes hubSpin {
  to { transform: rotate(360deg); }
}

.hub-loader-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--hub-text-muted);
}

/* App Error Boundary */
#hub-stage-error {
  position: absolute;
  inset: 0;
  background: var(--hub-bg-stage);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 30;
}
#hub-stage-error.visible {
  display: flex;
}

.hub-error-card {
  max-width: 420px;
  width: 100%;
  background: var(--hub-bg-surface);
  border: 1px solid var(--hub-border);
  border-radius: 14px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* ── Mobile 56px Bottom Navigation Dock (<= 750px) ─────────────────────── */
#hub-mobile-dock {
  display: none;
}

#hub-mobile-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 90;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
#hub-mobile-sheet-backdrop.visible {
  display: flex;
}

.hub-mobile-sheet {
  width: 100%;
  max-width: 500px;
  background: var(--hub-bg-surface);
  border-top: 1px solid var(--hub-border);
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hub-sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--hub-bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--hub-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

@media (max-width: 750px) {
  #hub-rail,
  #hub-tooltip {
    display: none !important;
  }

  #hub-shell {
    flex-direction: column;
  }

  #hub-stage {
    height: calc(100% - var(--dock-h) - env(safe-area-inset-bottom, 0px));
  }

  #hub-mobile-dock {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    width: 100%;
    height: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #141518;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 50;
    flex-shrink: 0;
    user-select: none;
  }

  .dock-btn {
    flex: 1 1 0%;
    background: none;
    border: none;
    color: var(--hub-text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    font-family: var(--hub-font);
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }

  .dock-btn.active {
    color: #ffffff;
  }

  .dock-btn.active .dock-icon-wrap {
    background: rgba(88, 101, 242, 0.22);
    color: #8c97ff;
  }

  .dock-icon-wrap {
    position: relative;
    width: 38px;
    height: 26px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease;
  }

  .dock-badge {
    position: absolute;
    top: -4px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--hub-red);
    color: #ffffff;
    font-size: 9.5px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #141518;
  }

  .dock-badge.zero {
    background: #2b2d31;
    color: #949ba4;
    font-weight: 700;
  }
}

/* ── Preview Mode Top Banner ───────────────────────────────────────────── */
#hub-preview-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 38px;
  background: var(--hub-bg-surface);
  border-bottom: 1px solid rgba(88, 101, 242, 0.4);
  color: var(--hub-text);
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 12.5px;
  font-weight: 500;
}
body.has-preview-banner #hub-preview-banner {
  display: flex;
}

/* ── Modals (Walled Garden & View Server As) ───────────────────────────── */
.hub-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 13, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.hub-modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--hub-bg-surface);
  border: 1px solid var(--hub-border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
  padding: 26px 24px;
  color: var(--hub-text);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hub-primary-btn {
  background: var(--hub-brand);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-family: var(--hub-font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.15s ease;
}
.hub-primary-btn:hover {
  background: var(--hub-brand-hover);
}

.hub-secondary-btn {
  background: var(--hub-bg-elevated);
  color: var(--hub-text);
  border: 1px solid var(--hub-border);
  border-radius: 8px;
  padding: 9px 16px;
  font-family: var(--hub-font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
