/* Jury Marketing - application shell layout: desktop sidebar + header, mobile bottom nav, responsive behavior. */

/* ============================================================
   App root / view switching
   ============================================================ */

#jm-app {
  min-height: 100vh;
  background: var(--jm-bg);
}

.jm-view {
  display: none;
}
.jm-view.jm-view-active {
  display: block;
}

/* ============================================================
   Splash
   ============================================================ */

#jm-splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--jm-navy-950);
  transition: opacity 300ms ease;
}
#jm-splash.jm-splash-hidden {
  opacity: 0;
  pointer-events: none;
}
.jm-splash-logo {
  width: min(64vw, 320px);
  animation: jm-splash-in 500ms ease both;
}
@keyframes jm-splash-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* ============================================================
   Login
   ============================================================ */

#jm-login.jm-view-active {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--jm-space-6);
  background: var(--jm-bg);
}

.jm-login-card {
  width: 100%;
  max-width: 400px;
  background: var(--jm-surface);
  border: 1px solid var(--jm-border);
  border-radius: var(--jm-radius-lg);
  box-shadow: var(--jm-shadow-lg);
  padding: var(--jm-space-8);
  display: flex;
  flex-direction: column;
  gap: var(--jm-space-5);
}

.jm-login-logo {
  width: 120px;
  margin: 0 auto var(--jm-space-2);
}

.jm-login-heading {
  text-align: center;
}
.jm-login-heading h1 {
  font-size: var(--jm-fs-lg);
  font-weight: var(--jm-fw-bold);
  color: var(--jm-text);
}
.jm-login-heading p {
  margin-top: var(--jm-space-1);
  font-size: var(--jm-fs-sm);
  color: var(--jm-text-muted);
}

/* ============================================================
   Shell: sidebar (desktop) + header + content
   ============================================================ */

#jm-shell.jm-view-active {
  display: flex;
  min-height: 100vh;
}

.jm-sidebar {
  width: var(--jm-sidebar-width);
  flex-shrink: 0;
  background: var(--jm-navy-950);
  color: var(--jm-text-inverse);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.jm-sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--jm-space-3);
  padding: var(--jm-space-5) var(--jm-space-5) var(--jm-space-4);
}

.jm-sidebar-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--jm-radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--jm-navy-950);
}
.jm-sidebar-brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 14%;
  transform: scale(2.5);
}

.jm-sidebar-brand-word {
  line-height: 1.15;
}
.jm-sidebar-brand-word strong {
  display: block;
  font-size: var(--jm-fs-md);
  font-weight: var(--jm-fw-bold);
  letter-spacing: 0.02em;
}
.jm-sidebar-brand-word span {
  display: block;
  font-size: var(--jm-fs-xs);
  color: var(--jm-gold);
  font-weight: var(--jm-fw-semibold);
  letter-spacing: 0.08em;
}

.jm-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--jm-space-2) var(--jm-space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.jm-nav-item {
  display: flex;
  align-items: center;
  gap: var(--jm-space-3);
  padding: 10px var(--jm-space-3);
  border-radius: var(--jm-radius-sm);
  color: rgba(255, 255, 255, 0.68);
  font-size: var(--jm-fs-sm);
  font-weight: var(--jm-fw-medium);
  transition: background-color 120ms ease, color 120ms ease;
}
.jm-nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--jm-text-inverse);
}
.jm-nav-item.jm-nav-item-active {
  background: rgba(218, 171, 75, 0.14);
  color: var(--jm-text-inverse);
}
.jm-nav-item.jm-nav-item-active .jm-nav-icon {
  color: var(--jm-gold);
}
.jm-nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.jm-sidebar-footer {
  padding: var(--jm-space-4) var(--jm-space-5);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.jm-jarvis-teaser {
  display: flex;
  align-items: center;
  gap: var(--jm-space-3);
  padding: var(--jm-space-3);
  border-radius: var(--jm-radius-md);
  border: 1px dashed rgba(218, 171, 75, 0.4);
  color: rgba(255, 255, 255, 0.75);
  font-size: var(--jm-fs-xs);
}
.jm-jarvis-teaser strong {
  display: block;
  color: var(--jm-text-inverse);
  font-size: var(--jm-fs-sm);
  margin-bottom: 2px;
}

/* --- Main column --- */

.jm-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.jm-header {
  height: var(--jm-header-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--jm-space-4);
  padding: 0 var(--jm-space-6);
  background: var(--jm-surface);
  border-bottom: 1px solid var(--jm-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.jm-header-title-group {
  display: flex;
  align-items: center;
  gap: var(--jm-space-3);
  min-width: 0;
}

.jm-header-menu-btn {
  display: none;
}

.jm-page-title {
  font-size: var(--jm-fs-lg);
  font-weight: var(--jm-fw-bold);
  color: var(--jm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.jm-header-actions {
  display: flex;
  align-items: center;
  gap: var(--jm-space-2);
  flex-shrink: 0;
}

.jm-header-search {
  width: 240px;
}

.jm-notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--jm-danger);
  border: 2px solid var(--jm-surface);
}

.jm-account-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--jm-space-2);
  padding: 6px var(--jm-space-2) 6px 6px;
  border-radius: var(--jm-radius-full);
  border: 1px solid var(--jm-border);
  background: var(--jm-surface);
}
.jm-account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--jm-navy);
  color: var(--jm-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--jm-fw-bold);
  font-size: var(--jm-fs-sm);
}

.jm-content {
  flex: 1;
  padding: var(--jm-space-6);
  max-width: 1280px;
  width: 100%;
}

.jm-page-heading {
  margin-bottom: var(--jm-space-6);
}
.jm-page-heading h2 {
  font-size: var(--jm-fs-xl);
  font-weight: var(--jm-fw-bold);
  color: var(--jm-text);
}
.jm-page-heading p {
  margin-top: 2px;
  font-size: var(--jm-fs-sm);
  color: var(--jm-text-muted);
}

/* ============================================================
   Mobile bottom navigation (hidden on desktop by default)
   ============================================================ */

.jm-mobile-nav {
  display: none;
}

/* ============================================================
   More menu (mobile sheet)
   ============================================================ */

#jm-more-sheet {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
}
#jm-more-sheet.jm-more-open {
  display: block;
}
.jm-more-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 30, 61, 0.4);
}
.jm-more-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--jm-surface);
  border-radius: var(--jm-radius-lg) var(--jm-radius-lg) 0 0;
  padding: var(--jm-space-5);
  padding-bottom: calc(var(--jm-space-6) + env(safe-area-inset-bottom));
  max-height: 80vh;
  overflow-y: auto;
}
.jm-more-panel .jm-nav-item {
  color: var(--jm-text);
}
.jm-more-panel .jm-nav-item:hover,
.jm-more-panel .jm-nav-item.jm-nav-item-active {
  background: var(--jm-bg);
  color: var(--jm-navy);
}
.jm-more-panel .jm-nav-item.jm-nav-item-active .jm-nav-icon {
  color: var(--jm-gold-600);
}

/* ============================================================
   Responsive breakpoints
   ============================================================ */

/* Tablet and below: collapse the sidebar into a bottom nav + off-canvas drawer isn't needed -
   we go straight to the mobile pattern below 900px, matching "no desktop UI squeezed onto a phone." */

@media (max-width: 1024px) {
  :root {
    --jm-sidebar-width: 220px;
  }
  .jm-content {
    padding: var(--jm-space-5);
  }
}

@media (max-width: 900px) {
  .jm-sidebar {
    display: none;
  }

  .jm-header {
    padding: 0 var(--jm-space-4);
    height: 56px;
    padding-top: env(safe-area-inset-top);
    height: calc(56px + env(safe-area-inset-top));
  }

  .jm-header-menu-btn {
    display: none; /* nav lives in the bottom bar on mobile, not a hamburger */
  }

  .jm-header-search {
    display: none;
  }

  .jm-content {
    padding: var(--jm-space-4);
    padding-bottom: calc(var(--jm-mobile-nav-height) + env(safe-area-inset-bottom) + var(--jm-space-4));
  }

  .jm-mobile-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    height: calc(var(--jm-mobile-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--jm-surface);
    border-top: 1px solid var(--jm-border);
  }

  .jm-mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--jm-text-muted);
    font-size: 10px;
    font-weight: var(--jm-fw-semibold);
    min-height: var(--jm-touch-target);
  }
  .jm-mobile-nav-item.jm-nav-item-active {
    color: var(--jm-navy);
  }
  .jm-mobile-nav-item .jm-nav-icon {
    width: 22px;
    height: 22px;
  }

  .jm-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--jm-space-3);
  }

  .jm-card {
    padding: var(--jm-space-4);
  }
}

@media (max-width: 420px) {
  .jm-kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .jm-card-value {
    font-size: var(--jm-fs-xl);
  }
}
