/* ---------------------------------------------------
   GLOBAL STYLES
--------------------------------------------------- */
body {
  margin: 0;
  font-family: "Montserrat", sans-serif;
  background: radial-gradient(
    circle at center top,
    var(--theme-bg-page-start) 0%,
    var(--theme-bg-page-end) 100%
  );
  color: var(--theme-text-body);
  min-height: 100%;
  min-height: -webkit-fill-available;
}

body.light-mode {
  background: var(--theme-bg-page-solid);
  color: var(--theme-text-body);
}

body.font-large {
  font-size: 16px;
}

body.font-xlarge {
  font-size: 18px;
}

body.high-contrast:not(.light-mode) {
  background: var(--theme-bg-page-solid);
  color: var(--theme-text-body);
}

body.light-mode.high-contrast {
  background: var(--theme-bg-page-solid);
  color: var(--theme-text-body);
}

body.reduce-motion *, 
body.reduce-motion *::before, 
body.reduce-motion *::after {
  animation-duration: 0.001s !important;
  transition-duration: 0.001s !important;
}

html {
  height: 100%;
  height: -webkit-fill-available;
}

html, body {
  margin: 0;
  padding: 0;
  overflow: hidden; /* Prevent body scroll, use #main-content */
}

/* ---------------------------------------------------
   CUSTOM SCROLLBARS
--------------------------------------------------- */
/* Apply to #main-content and other scrollable areas */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--theme-scrollbar-track);
  border-left: 1px solid var(--theme-scrollbar-track-border);
}

::-webkit-scrollbar-thumb {
  background: var(--theme-scrollbar-thumb);
  border-radius: 5px;
  border: 2px solid var(--theme-scrollbar-thumb-border);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--theme-scrollbar-thumb-hover);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--theme-scrollbar-thumb) var(--theme-scrollbar-track);
}

/* ---------------------------------------------------
   APP CONTAINER
--------------------------------------------------- */
:root {
  /* Updated by app.js from visualViewport (mobile URL bar show/hide); fallback for first paint */
  --app-visual-height: 100dvh;
}

#app {
  display: flex;
  flex-direction: column; /* stack header, content, nav vertically */
  height: 100vh; /* legacy */
  height: var(--app-visual-height, 100dvh);
  max-height: var(--app-visual-height, 100dvh);
  min-height: 0;
  overflow: hidden;       /* No internal scroll on app itself */
}

#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  /* Reserve space for the vertical scrollbar so content width doesn’t jump when it appears */
  scrollbar-gutter: stable;
  /* Scrollbar will appear on this element, below the header */
}

@media (max-width: 767.98px) {
  button,
  .nav-item,
  [role="button"] {
    touch-action: manipulation;
  }

  .tab-content {
    min-width: 0;
  }
}

/* ---------------------------------------------------
   LOADING SPINNER
--------------------------------------------------- */
.tab-loading-spinner-inline {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
}

.spinner {
  border: 4px solid var(--theme-spinner-track);
  border-left-color: var(--theme-spinner-accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

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