/* ============================================
   PFL App — Base Styles
   Reset, body, typography, utilities
   ============================================ */

/* ---- Reset ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Prevent iOS/Telegram text autosizing */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}


/* ---- Bottom Fade (prevents content behind tab bar from being readable) ---- */
body::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 80px;
  pointer-events: none;
  z-index: 99; /* below .tabs (100) */
  background: linear-gradient(
    to bottom,
    rgba(var(--bg-rgb), 0) 0%,
    rgba(var(--bg-rgb), 0.55) 55%,
    rgba(var(--bg-rgb), 0.92) 78%,
    var(--bg) 100%
  );
}

/* ---- Top Fade (fullscreen mobile only — native TG header area) ---- */
body::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 40px;
  pointer-events: none;
  z-index: 99;
  opacity: 0;
  background: linear-gradient(
    to top,
    rgba(var(--bg-rgb), 0) 0%,
    rgba(var(--bg-rgb), 0.55) 45%,
    rgba(var(--bg-rgb), 0.92) 72%,
    var(--bg) 100%
  );
  transition: opacity 0.3s ease;
}

.fullscreen-active body::before,
body.fullscreen-active::before {
  opacity: 1;
}


/* ---- App Container (exactly like index_old.html) ---- */
#app-wrap {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: auto;
  overscroll-behavior-y: auto;
}

#app-content {
  /* This ensures content is always scrollable for bounce to work */
  min-height: calc(100% + 1px);
  padding: var(--app-top-pad, 20px) 18px 96px;
  max-width: var(--app-max-width);
  margin: 0 auto;
}

/* ---- Global Scrollbar Hiding (except tables) ---- */
*:not(.table-wrap)::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

*:not(.table-wrap) {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* ---- Table Scrollbar (visible, themed) ---- */
.table-wrap::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}

.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--bg);
  border-radius: 3px;
}

.table-wrap {
  scrollbar-width: thin;
  scrollbar-color: var(--bg) transparent;
}

/* ---- Typography ---- */
.page-title {
  margin: 0 0 var(--spacing-md);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
}

.page-subtitle {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

/* ---- Links ---- */
a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- Images ---- */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ---- Loading Text ---- */
.loading-text {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 15px;
  padding: 6px 0;
  text-align: center;
}

/* ---- Screen Reader Only ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Empty State ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--spacing-2xl) var(--spacing-md);
  min-height: calc(100vh - 280px);
}

.empty-state img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  margin-bottom: var(--spacing-md);
  animation: emptyFloat 3s ease-in-out infinite;
}

@keyframes emptyFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

@media (prefers-reduced-motion: reduce) {
  .empty-state img { animation: none; }
}

.empty-state__text {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
  color: var(--muted);
}

/* ============================================
   Toast Notification
   ============================================ */
.pfl-toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 200;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

:root[data-theme="dark"] .pfl-toast {
  background: rgba(255, 255, 255, 0.92);
  color: #0F130E;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.30);
}

.pfl-toast--visible {
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.pfl-toast--hiding {
  animation: toastOut 0.25s ease-in forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.92); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  to   { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.95); }
}

/* ============================================
   Content Fade-In (after skeleton)
   ============================================ */
.content-fade-in {
  animation: contentFadeIn 0.35s ease-out both;
}

@keyframes contentFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
