/* ============================================================
   LAYOUT — Navigation, page structure, responsive grid
   ============================================================ */

/* ── Page shell ── */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Login screen (full-page overlay) ── */
#login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
  z-index: var(--z-modal);
  gap: var(--sp-8);
  padding: var(--sp-8);
}

#login-screen .login-hero-img {
  width: 100%;
  max-width: 600px;
  height: auto;
}

#login-screen .login-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  text-align: center;
}

#login-screen .login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-10) var(--sp-8);
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-6);
  box-shadow: var(--shadow-card);
}

/* ── Numo logo — login page top-left ── */
.login-numo-logo {
  position: absolute;
  top: var(--sp-6);
  left: var(--sp-6);
  max-width: 300px;
  width: auto;
  height: auto;
}

@media (max-width: 639px) {
  .login-numo-logo {
    max-width: 160px;
    top: var(--sp-4);
    left: var(--sp-4);
  }
}

/* ── Numo watermark — app pages bottom-right ── */
.app-numo-watermark {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  max-width: 200px;
  width: auto;
  height: auto;
  z-index: 10; /* below nav (100) and banner (90) */
  pointer-events: none;
  opacity: 0.6;
}

@media (max-width: 639px) {
  .app-numo-watermark {
    max-width: 130px;
    bottom: calc(var(--bottom-nav-height) + var(--sp-4));
    right: var(--sp-4);
  }
}

/* ── Top navigation bar (desktop) ── */
#top-nav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  height: var(--nav-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-6);
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--gold);
  letter-spacing: 1px;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.nav-link.active {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.nav-link.admin-link {
  color: var(--gold);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-left: auto;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
}

.nav-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  flex-shrink: 0;
}

.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }

.nav-username {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Prediction window banner ── */
#phase-banner {
  position: sticky;
  top: var(--nav-height);
  z-index: var(--z-banner);
  height: var(--banner-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
}

.banner-phase {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.banner-multiplier {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.75rem;
  font-weight: 700;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-pill);
  color: #000;
}

.banner-countdown {
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gold);
}

.banner-countdown-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ── Main content area ── */
#main-content {
  flex: 1;
  padding: var(--sp-6);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ── Page section header ── */
.page-header {
  margin-bottom: var(--sp-6);
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: var(--sp-1);
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ── Sub-navigation tabs ── */
.sub-nav {
  display: flex;
  gap: var(--sp-1);
  margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.sub-nav::-webkit-scrollbar { display: none; }

.sub-nav-link {
  padding: var(--sp-3) var(--sp-4);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: all var(--transition);
}

.sub-nav-link:hover { color: var(--text-primary); }
.sub-nav-link.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ── Mobile bottom nav ── */
#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-nav);
  height: var(--bottom-nav-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: env(safe-area-inset-bottom, 0);
}

.bottom-nav-items {
  display: flex;
  height: var(--bottom-nav-height);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-secondary);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: color var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  padding: var(--sp-2);
}

.bottom-nav-item svg { flex-shrink: 0; }
.bottom-nav-item.active { color: var(--gold); }
.bottom-nav-item:hover { color: var(--text-primary); }

/* ── Responsive breakpoints ── */

/* Tablet (640px+) */
@media (min-width: 640px) {
  #main-content { padding: var(--sp-6) var(--sp-8); }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  #main-content { padding: var(--sp-8) var(--sp-6); }
}

/* Mobile (< 640px) */
@media (max-width: 639px) {
  #top-nav .nav-links { display: none; }
  #top-nav .nav-right .nav-username { display: none; }
  #bottom-nav { display: block; }
  #main-content {
    padding: var(--sp-4);
    padding-bottom: calc(var(--bottom-nav-height) + var(--sp-4));
  }
  #phase-banner { padding: 0 var(--sp-4); }
  .banner-phase { font-size: 0.75rem; }
}

/* Loading spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  min-height: 300px;
  color: var(--text-secondary);
  text-align: center;
}

.empty-state svg { opacity: 0.4; }
