/* ==========================================================================
   PM TECH — Unified Application Window Stylesheet
   Modern, ultra-clean, mobile-first design matching the Home Page launcher
   ========================================================================== */

:root {
  --pmw-bg: #fbfcfa;
  --pmw-card-bg: #ffffff;
  --pmw-ink: #08284f;
  --pmw-ink-light: #173a70;
  --pmw-blue: #076bdc;
  --pmw-blue-hover: #0559b7;
  --pmw-blue-light: #eaf3fd;
  --pmw-green: #78b92c;
  --pmw-green-light: #f0f8e6;
  --pmw-muted: #60728a;
  --pmw-border: #e2e8f0;
  --pmw-border-hover: #9ec9ee;
  --pmw-shadow: 0 8px 24px rgba(8, 40, 79, 0.05);
  --pmw-shadow-lg: 0 16px 36px rgba(8, 40, 79, 0.09);
  --pmw-radius: 20px;
  --pmw-radius-sm: 12px;
}

/* Ensure Native Smooth Scrolling Everywhere */
html,
body,
html:has(body),
body.pm-landing-body,
body.tool-phone,
body.phone-shell,
body.creator-shell,
body.solar-determiner-body,
body.pump-lab-body,
body.dvs-body,
body.products-page-body,
body.quote-page-body,
body.offers-page-body,
body.page-scroll {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  height: auto !important;
  min-height: 100% !important;
  min-height: 100dvh !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
  overscroll-behavior-y: auto !important;
}

/* Base Body Override for App Windows */
body.tool-phone,
body.creator-shell,
body.solar-determiner-body,
body.pump-lab-body,
body.dvs-body,
body.products-page-body,
body.quote-page-body,
body.offers-page-body {
  background-color: var(--pmw-bg) !important;
  color: var(--pmw-ink) !important;
  font-family: 'Cairo', 'Plus Jakarta Sans', system-ui, sans-serif !important;
  margin: 0 !important;
  padding: 0 !important;
  -webkit-font-smoothing: antialiased;
}

/* Containers must not trap or lock scrolling */
.sd-shell,
.pl-shell,
.dvs-shell,
.pm-app-shell,
.quote-container,
.offers-container,
.pma-page,
.dash-layout-container,
.sales-app-wrapper {
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
}

/* Hide desktop navbar & mobile app bottom nav in app window mode to keep it 100% focused on single Back button */
body.tool-phone .pm-desktop-navbar,
body.creator-shell .pm-desktop-navbar,
body.solar-determiner-body .pm-desktop-navbar,
body.pump-lab-body .pm-desktop-navbar,
body.dvs-body .pm-desktop-navbar,
body.products-page-body .pm-desktop-navbar,
body.quote-page-body .pm-desktop-navbar,
body.offers-page-body .pm-desktop-navbar,
body.tool-phone .mobile-app-bottom-nav,
body.solar-determiner-body .mobile-app-bottom-nav,
body.pump-lab-body .mobile-app-bottom-nav,
body.dvs-body .mobile-app-bottom-nav,
body.products-page-body .mobile-app-bottom-nav,
body.tool-phone .mobile-app-header:not(.pm-app-topbar),
body.tool-phone .hub-desktop-only,
body.tool-phone .hub-mobile-only:not(.pm-app-topbar) {
  display: none !important;
}

/* App Shell Container */
.pm-app-shell {
  width: min(100%, 1080px);
  margin-inline: auto;
  padding: 0 16px 40px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* Unified Top App Header: Direction RTL with Back Button on Far Right */
.pm-app-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 18px;
  background: rgba(251, 252, 250, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(8, 40, 79, 0.08);
  box-sizing: border-box;
  width: 100%;
  direction: rtl !important;
}

.pm-app-topbar-inner {
  width: min(100%, 1080px);
  margin-inline: auto;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px;
  direction: rtl !important;
}

/* Back Button: Pinned to Right in RTL */
.pm-app-back-btn {
  order: 1 !important;
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--pmw-border);
  color: var(--pmw-ink);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(8, 40, 79, 0.04);
  transition: all 0.2s ease;
  flex-shrink: 0;
  cursor: pointer;
}

.pm-app-back-btn:hover {
  background: var(--pmw-blue-light);
  color: var(--pmw-blue);
  border-color: var(--pmw-border-hover);
  transform: translateX(-2px);
}

.pm-app-back-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Title & Subtitle in Center */
.pm-app-topbar-title {
  order: 2 !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  min-width: 0;
}

.pm-app-topbar-title h1 {
  margin: 0;
  font-size: clamp(15px, 2vw, 18px);
  font-weight: 900;
  color: var(--pmw-ink);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pm-app-topbar-title span {
  font-size: 11px;
  font-weight: 700;
  color: var(--pmw-muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Logo Mark on Far Left in RTL */
.pm-app-topbar-logo {
  order: 3 !important;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.pm-app-topbar-logo img {
  height: 30px;
  width: auto;
  display: block;
}

/* App Card Standard */
.pm-app-card {
  background: var(--pmw-card-bg);
  border: 1px solid var(--pmw-border);
  border-radius: var(--pmw-radius);
  box-shadow: var(--pmw-shadow);
  padding: 24px;
  margin-bottom: 20px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.pm-app-card:hover {
  border-color: var(--pmw-border-hover);
}

/* Mobile Adjustments */
@media (max-width: 640px) {
  .pm-app-shell {
    padding: 0 12px 32px;
  }

  .pm-app-topbar {
    padding: 10px 12px;
    margin-bottom: 14px;
  }

  .pm-app-back-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .pm-app-topbar-title h1 {
    font-size: 14px;
  }

  .pm-app-topbar-title span {
    display: none;
  }

  .pm-app-topbar-logo img {
    height: 24px;
  }

  .pm-app-card {
    padding: 16px;
    border-radius: 16px;
  }
}
