/* ==========================================================================
   APP SHELL & VIEWPORT STYLES (FLUID SCROLLING & PRODUCTION READY)
   ========================================================================== */

/* 1. App Root Layout */
.app-root-layout {
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  background-color: var(--primary-950);
  background-image: radial-gradient(circle at 50% 20%, #132238 0%, #060e1a 100%);
}

/* 2. Main Application Viewport */
.app-viewport {
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: 500px;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
}

@media (min-width: 501px) {
  .app-root-layout {
    align-items: center;
    padding: 1rem 0;
  }
  .app-viewport {
    height: 94vh;
    height: 94dvh;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(228, 156, 12, 0.18);
  }
}

/* 3. Top Mobile App Header */
.app-header {
  min-height: 54px;
  background: var(--primary-900);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(0.4rem, env(safe-area-inset-top)) 0.85rem 0.4rem 0.85rem;
  box-shadow: var(--shadow-sm);
  z-index: 40;
  position: relative;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1;
}

.header-brand-icon {
  color: var(--accent-gold-400);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-title-box {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.header-chamber-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-chamber-name span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-chamber-sub {
  font-size: 0.66rem;
  color: var(--accent-gold-400);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.header-icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: #cbd5e1;
  position: relative;
  transition: all var(--transition-fast);
}

.header-icon-btn:hover, .header-icon-btn:active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  background: var(--status-urgent);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--primary-900);
}

.header-avatar-btn {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-gold-500), var(--accent-gold-700));
  color: var(--primary-900);
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.2rem;
  box-shadow: 0 2px 6px rgba(228, 156, 12, 0.3);
}

/* 4. Screen Scroll Container (GUARANTEED FLUID TOUCH SCROLL) */
.screen-scroll-container {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: auto;
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
  padding: 0.75rem 0.75rem 6.5rem 0.75rem;
  position: relative;
}

/* View Loading Spinner */
.view-loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.legal-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-gold-500);
  border-right-color: var(--primary-900);
  border-radius: var(--radius-full);
  animation: legalSpin 0.75s linear infinite;
}

@keyframes legalSpin {
  to { transform: rotate(360deg); }
}

/* 5. Fixed Bottom Navigation Bar */
.bottom-nav-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(58px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #ffffff;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  z-index: 45;
  box-shadow: 0 -4px 16px rgba(10, 25, 47, 0.05);
}

.nav-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
  height: 100%;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  position: relative;
  padding: 0.3rem 0;
}

.nav-tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-normal);
}

.nav-tab-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 92%;
}

.nav-tab-item.active {
  color: var(--primary-900);
}

.nav-tab-item.active .nav-tab-icon {
  transform: translateY(-1px);
  color: var(--accent-gold-500);
}

.nav-tab-item.active::after {
  content: "";
  position: absolute;
  top: 0;
  width: 20px;
  height: 3px;
  background: var(--accent-gold-500);
  border-radius: 0 0 3px 3px;
}

/* 6. Quick Action FAB */
.quick-action-fab {
  position: absolute;
  bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  right: 14px;
  z-index: 46;
}

.fab-main-btn {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-900), var(--primary-800));
  color: var(--accent-gold-400);
  border: 1.5px solid var(--accent-gold-500);
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-normal), background var(--transition-fast);
}

.fab-main-btn:hover, .fab-main-btn:active {
  transform: scale(1.06);
  box-shadow: 0 8px 24px rgba(228, 156, 12, 0.4);
}

.fab-main-btn.open {
  transform: rotate(45deg);
  background: var(--status-urgent);
  border-color: var(--status-urgent);
  color: #ffffff;
}

.fab-menu-options {
  position: absolute;
  bottom: 60px;
  right: 0;
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
  pointer-events: none;
}

.fab-menu-options.open {
  display: flex;
  pointer-events: auto;
}

.fab-option-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: #ffffff;
  padding: 0.4rem 0.75rem 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.fab-option-item:hover {
  background: var(--primary-50);
  border-color: var(--accent-gold-500);
}

.fab-option-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--primary-900);
  color: var(--accent-gold-400);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 7. Bottom Sheet System (Zero Touch Blocking When Inactive) */
.bottom-sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 14, 26, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 60;
  display: none;
  visibility: hidden;
  pointer-events: none;
  flex-direction: column;
  justify-content: flex-end;
}

.bottom-sheet-overlay.active {
  display: flex;
  visibility: visible;
  pointer-events: auto;
}

.bottom-sheet-container {
  width: 100%;
  max-height: 90%;
  background: #ffffff;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  margin: 10px auto 4px auto;
  flex-shrink: 0;
}

.bottom-sheet-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0.85rem 1rem 1.5rem 1rem;
}

/* 8. Global Modal Overlay (Zero Touch Blocking When Inactive) */
.global-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 14, 26, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 70;
  display: none;
  visibility: hidden;
  pointer-events: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.global-modal-overlay.active {
  display: flex;
  visibility: visible;
  pointer-events: auto;
}

.global-modal-dialog {
  width: 100%;
  max-width: 440px;
  max-height: 85%;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* 9. Toast Notification Hub */
.toast-hub {
  position: absolute;
  top: max(60px, calc(54px + env(safe-area-inset-top)));
  left: 10px;
  right: 10px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  pointer-events: none;
}

.toast-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--primary-900);
  color: #ffffff;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--accent-gold-500);
  font-size: 0.82rem;
  font-weight: 500;
  pointer-events: auto;
}

.toast-item.success { border-left-color: var(--status-success); }
.toast-item.urgent  { border-left-color: var(--status-urgent); }

.toast-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-gold-400);
  flex-shrink: 0;
}
