/* Spec-driven UI polish for AG Grid + Offcanvas */

.trend-cell {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.trend-cell-value {
  flex: 1;
  min-width: 0;
}

.trend-icon {
  opacity: 0.55;
  cursor: pointer;
  user-select: none;
  line-height: 1;
  transition: opacity 200ms ease, transform 200ms ease;
}

.trend-arrow {
  font-weight: 800;
  letter-spacing: 0.02em;
  display: inline-block;
  min-width: 1.25rem;
  text-align: center;
}

.trend-up {
  color: var(--success-color, #28a745);
}

.trend-down {
  color: var(--danger-color, #dc3545);
}

.trend-flat {
  color: var(--text-secondary, #b0bec5);
}

/* Fallback UX: if the inline renderer doesn't display, still show a hover affordance.
   Clicking the numeric cell opens the trend panel via cellClicked callback. */
.ag-theme-alpine-dark .ag-cell.trendable-cell {
  cursor: pointer;
}

/* Draggable trends modal header */
.pe-trends-modal-header {
  cursor: move;
  user-select: none;
}

/* If the React renderer is active, it renders a real .trend-icon element.
   Hide it by default and reveal on hover/focus for the spec-like affordance. */
.ag-theme-alpine-dark .ag-cell.trendable-cell .trend-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ag-theme-alpine-dark .ag-cell.trendable-cell .trend-icon {
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
  user-select: none;
}

.ag-theme-alpine-dark .ag-cell.trendable-cell:hover .trend-icon,
.ag-theme-alpine-dark .ag-cell.trendable-cell .trend-icon:focus {
  opacity: 0.95;
  transform: translateY(-1px);
}

/* Mobile: there is no hover, so keep the trend affordance visible. */
@media (max-width: 768px) {
  .ag-theme-alpine-dark .ag-cell.trendable-cell .trend-icon {
    opacity: 0.95;
    transform: none;
    padding: 2px 6px;
    margin-left: 2px;
  }
}

/* IMPORTANT: do not show the pseudo-element icon when the renderer is active,
   otherwise users see two 📈 icons (one from renderer, one from ::after).
   We keep the click-to-open fallback via cellClicked without showing an extra icon. */
.ag-theme-alpine-dark .ag-cell.trendable-cell::after,
.ag-theme-alpine-dark .ag-cell.trendable-cell .ag-cell-value::after {
  content: "";
}

.ag-row-hover .trend-icon,
.trend-cell:hover .trend-icon {
  opacity: 0.95;
  transform: translateY(-1px);
}

/* Plus metric semantics */
.plus-good {
  color: var(--success-color, #28a745);
  font-weight: 600;
}

.plus-bad {
  color: var(--danger-color, #dc3545);
  font-weight: 600;
}

/* Roto+ emphasis */
.roto-strong {
  font-weight: 700;
}

/* Offcanvas subtle transition (browser dependent) */
.offcanvas {
  transition: transform 280ms ease, opacity 280ms ease;
}

/* Blog / Posts: readable Markdown on dark theme */
.post-content {
  line-height: 1.75;
  color: var(--text-primary, #ffffff);
}

/* Anchor targets: add some offset for the sticky navbar */
.post-anchor {
  display: block;
  position: relative;
  top: -88px;
  visibility: hidden;
}

.post-content p {
  margin: 0.85rem 0;
  color: var(--text-secondary, #a1a1aa);
}

.post-content h1,
.post-content h2,
.post-content h3 {
  margin: 1.75rem 0 0.75rem 0;
  color: var(--text-primary, #ffffff);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.post-content h2 {
  font-size: 1.5rem;
}

.post-content h3 {
  font-size: 1.25rem;
}

.post-content a {
  color: var(--accent-color, #7f9dbb);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-content ul,
.post-content ol {
  margin: 0.75rem 0 0.75rem 1.25rem;
}

.post-content li {
  margin: 0.25rem 0;
  color: var(--text-secondary, #a1a1aa);
}

.post-content code {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 0.35rem;
}

.post-content pre {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.9rem;
  border-radius: 0.75rem;
  overflow-x: auto;
}

/* Subtle page transition */
@keyframes pageFadeInUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-page-container.page-enter {
  animation: pageFadeInUp 180ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .app-page-container.page-enter {
    animation: none !important;
  }

  * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* AG Grid zebra striping + hover (FanGraphs-like) */
.ag-theme-alpine-dark .ag-row-odd {
  background-color: rgba(255, 255, 255, 0.02);
}

.ag-theme-alpine-dark .ag-row-hover {
  background-color: var(--hover-bg, rgba(255, 255, 255, 0.06)) !important;
}

.ag-theme-alpine-dark .ag-header {
  font-weight: 600;
}

/* Phone-width AG Grid pagination: the full desktop panel (page-size selector +
   "1 to 50 of 340" row summary + pager) wraps into an unreadable multi-line
   jumble that overflows the grid bounds. Keep ONLY the centered pager
   ("|< < Page 1 of 7 > >|") on small screens. */
@media (max-width: 640px) {
  .ag-theme-alpine-dark .ag-paging-panel {
    justify-content: center;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 0 6px;
    font-size: 0.74rem;
    overflow: hidden;
  }

  .ag-theme-alpine-dark .ag-paging-row-summary-panel,
  .ag-theme-alpine-dark .ag-paging-panel .ag-paging-page-size {
    display: none;
  }

  .ag-theme-alpine-dark .ag-paging-page-summary-panel {
    margin: 0;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
  }
}

/* --------------------------------------------------------------------------- */
/* Global footer                                                                 */
/* --------------------------------------------------------------------------- */

/* Keep the footer pinned to the bottom on short pages. */
.app-shell {
  display: flex;
  flex-direction: column;
}

.app-shell > .app-page-container {
  flex: 1 0 auto;
}

.app-footer {
  margin-top: 40px;
  border-top: 1px solid var(--border-color, #232830);
  background: rgba(255, 255, 255, 0.02);
  animation: app-footer-fade 0.35s ease;
}

/* Don't flash the footer at the top of the viewport while the page body is
   still routing/loading — keep it hidden until Dash renders page content. */
.app-shell:has(#_pages_content:empty) .app-footer {
  display: none;
}

@keyframes app-footer-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.app-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 16px 4px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px 24px;
}

/* Column placement: logos left, support centered, socials right. */
.app-footer-inner > .app-footer-powered { justify-self: start; }
.app-footer-inner > .app-footer-support { justify-self: center; min-width: 0; }
.app-footer-inner > .app-footer-socials { justify-self: end; }

/* "Powered By" label sits inline with the logo strip on one line. */
.app-footer-powered {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.app-footer-heading {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary, #9aa3af);
  white-space: nowrap;
}

.app-footer-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
}

.app-footer-logo {
  display: inline-flex;
  align-items: center;
  opacity: 0.85;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.app-footer-logo:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.app-footer-logo-img {
  height: 22px;
  width: auto;
  max-width: 130px;
  object-fit: contain;
}

.app-footer-support-btn {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--border-color, #232830);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary, #e8eaed);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.app-footer-support-btn:hover {
  background: rgba(var(--accent-rgb, 96, 165, 250), 0.12);
  border-color: rgba(var(--accent-rgb, 96, 165, 250), 0.45);
  color: var(--text-primary, #e8eaed);
}

/* Social icon links (X / LinkedIn / Discord — mirrors the About page) */
.app-footer-socials {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-footer-social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border-color, #232830);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary, #9aa3af);
  font-size: 0.9rem;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.app-footer-social:hover {
  background: rgba(var(--accent-rgb, 96, 165, 250), 0.12);
  border-color: rgba(var(--accent-rgb, 96, 165, 250), 0.45);
  color: var(--text-primary, #e8eaed);
}

.app-footer-copyright {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2px 16px 16px;
  font-size: 0.74rem;
  color: var(--text-secondary, #9aa3af);
  text-align: center;
}

/* Legal / policy document links (Terms, Privacy, etc.) */
.app-footer-legal {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 16px 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
}

.app-footer-legal-link {
  font-size: 0.74rem;
  color: var(--text-secondary, #9aa3af);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.app-footer-legal-link:hover {
  color: var(--text-primary, #e8eaed);
  text-decoration: underline;
}

/* Dot separators between legal links */
.app-footer-legal-link + .app-footer-legal-link::before {
  content: "·";
  margin-right: 10px;
  color: var(--text-secondary, #9aa3af);
  opacity: 0.6;
}

/* Tablet / narrow desktop: the 3-column grid gets cramped once the support
   pill plus logos plus socials can't share a row — stack them centered. */
@media (max-width: 900px) {
  .app-footer-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 14px;
    padding: 18px 16px 4px;
    text-align: center;
  }

  .app-footer-inner > .app-footer-powered,
  .app-footer-inner > .app-footer-support,
  .app-footer-inner > .app-footer-socials {
    justify-self: center;
  }

  .app-footer-logos {
    justify-content: center;
  }
}

/* Phone-sized screens: tighter spacing, smaller logos, wrap-friendly text. */
@media (max-width: 640px) {
  .app-footer-inner {
    padding: 18px 12px 2px;
    gap: 12px;
  }

  .app-footer-powered {
    flex-direction: column;
    gap: 8px;
  }

  .app-footer-logos {
    gap: 12px 18px;
  }

  .app-footer-logo-img {
    height: 20px;
    max-width: 110px;
  }

  .app-footer-support-btn {
    font-size: 0.76rem;
    padding: 7px 13px;
  }

  .app-footer-legal {
    padding: 6px 12px 4px;
    gap: 4px 8px;
  }

  .app-footer-legal-link + .app-footer-legal-link::before {
    margin-right: 8px;
  }

  .app-footer-copyright {
    padding: 2px 12px 14px;
  }
}

/* Very narrow phones (<=380px, e.g. iPhone SE/mini): let the support pill
   text truncate instead of overflowing, and shrink logos one more notch. */
@media (max-width: 380px) {
  .app-footer-logo-img {
    height: 18px;
    max-width: 96px;
  }

  .app-footer-support {
    width: 100%;
  }

  .app-footer-support-btn {
    width: 100%;
    justify-content: center;
  }
}
