/* Happymood — Mobile App Shell (PWA + native-like UI) */

:root {
  --hm-tabbar-h: 64px;
  --hm-safe-bottom: env(safe-area-inset-bottom, 0px);
  --hm-safe-top: env(safe-area-inset-top, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(217, 26, 106, 0.12);
}

body {
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

/* ── Standalone / installed app mode ── */
html.hm-standalone,
body.hm-standalone {
  user-select: none;
  -webkit-user-select: none;
}

body.hm-standalone .topbar,
body.hm-standalone .bh-nav {
  padding-top: var(--hm-safe-top);
}

/* ── Bottom tab bar (dashboard) ── */
.hm-tabbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: calc(var(--hm-tabbar-h) + var(--hm-safe-bottom));
  padding-bottom: var(--hm-safe-bottom);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.06);
}

.hm-tabbar__inner {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: var(--hm-tabbar-h);
  max-width: 520px;
  margin: 0 auto;
  padding: 0 8px;
}

.hm-tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted, #64748B);
  font-size: 10px;
  font-weight: 600;
  border: none;
  background: transparent;
  cursor: pointer;
  min-width: 0;
  padding: 6px 4px;
  border-radius: 12px;
  transition: color 0.2s, background 0.2s;
  font-family: inherit;
}

.hm-tabbar__item i {
  font-size: 1.35rem;
  line-height: 1;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hm-tabbar__item.is-active {
  color: var(--hm-magenta, #D91A6A);
}

.hm-tabbar__item.is-active i {
  transform: scale(1.08);
}

.hm-tabbar__item:active {
  background: rgba(217, 26, 106, 0.08);
}

.hm-tabbar__item--menu.is-active {
  color: var(--hm-cyan, #0891B2);
}

/* ── Landing bottom bar ── */
.hm-landing-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  height: calc(var(--hm-tabbar-h) + var(--hm-safe-bottom));
  padding-bottom: var(--hm-safe-bottom);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.08);
}

.hm-landing-bar__inner {
  display: flex;
  height: var(--hm-tabbar-h);
  max-width: 520px;
  margin: 0 auto;
}

.hm-landing-bar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: #64748B;
  font-size: 10px;
  font-weight: 700;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.hm-landing-bar__item i { font-size: 1.3rem; }
.hm-landing-bar__item.is-active,
.hm-landing-bar__item--primary { color: #D91A6A; }
.hm-landing-bar__item--cta {
  flex: 1.2;
  margin: 8px 6px;
  border-radius: 14px;
  background: linear-gradient(135deg, #D91A6A 0%, #0891B2 55%, #F59E0B 100%);
  color: #fff !important;
  font-size: 11px;
  box-shadow: 0 4px 16px rgba(217, 26, 106, 0.35);
}

/* ── Install banner ── */
.hm-install-banner {
  position: fixed;
  bottom: calc(var(--hm-tabbar-h) + var(--hm-safe-bottom) + 12px);
  left: 12px;
  right: 12px;
  z-index: 250;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #D91A6A, #0891B2);
  color: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(217, 26, 106, 0.35);
  font-size: 13px;
  max-width: 480px;
  margin: 0 auto;
}

.hm-install-banner[hidden] { display: none !important; }

.hm-install-banner__btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  background: #fff;
  color: #D91A6A;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.hm-install-banner__close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Mobile layout adjustments ── */
@media (max-width: 991px) {
  body.hm-has-tabbar .hm-tabbar,
  body.bh-landing .hm-landing-bar {
    display: block;
  }

  body.hm-has-tabbar .content-area {
    padding-bottom: calc(var(--hm-tabbar-h) + var(--hm-safe-bottom) + 16px) !important;
    min-height: calc(100vh - var(--topbar-h) - var(--hm-tabbar-h) - var(--hm-safe-bottom));
  }

  body.hm-has-tabbar .main-content {
    min-height: 100dvh;
  }

  body.bh-landing {
    padding-bottom: calc(var(--hm-tabbar-h) + var(--hm-safe-bottom));
  }

  body.bh-landing .bh-footer {
    padding-bottom: calc(var(--hm-tabbar-h) + var(--hm-safe-bottom) + 1rem);
  }

  /* App-like topbar on mobile */
  .topbar {
    height: auto;
    min-height: var(--topbar-h);
    padding-top: max(8px, var(--hm-safe-top));
    border-bottom: none;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
  }

  .topbar .page-title {
    font-size: 1rem;
    font-weight: 800;
  }

  /* Cards feel native */
  .eh-card,
  .stat-card,
  .db-kpi,
  .db-hero {
    border-radius: 20px;
  }

  .content-area {
    padding: 12px !important;
  }

  /* Hide desktop sidebar toggle hint on mobile — use tabbar menu */
  .sidebar-toggle {
    display: none !important;
  }

  /* Full-screen sidebar drawer */
  .sidebar {
    width: min(100vw, 360px);
    padding-top: var(--hm-safe-top);
  }

  /* Guest / auth pages */
  body.hm-guest-page {
    padding-bottom: var(--hm-safe-bottom);
  }

  .login-shell,
  .register-shell {
    min-height: 100dvh;
    padding-bottom: calc(24px + var(--hm-safe-bottom));
  }
}

@media (max-width: 991px) and (display-mode: standalone) {
  .topbar {
    background: rgba(255, 255, 255, 0.98);
  }
}

/* Touch feedback */
@media (hover: none) {
  .btn-gold:active,
  .btn-hm:active,
  .bh-btn--primary:active {
    transform: scale(0.97);
  }

  .eh-card:active,
  .event-card:active {
    transform: scale(0.99);
  }
}

/* Pull-to-top spacing for alerts */
@media (max-width: 991px) {
  .alert-float {
    top: calc(12px + var(--hm-safe-top));
  }
}
