/**
 * MuscleCouple Native Mobile App Shell Styling
 * Mayhem-Style Native Mobile Architecture
 */

:root {
  --mc-safe-top: env(safe-area-inset-top, 0px);
  --mc-safe-bottom: env(safe-area-inset-bottom, 16px);
  --mc-nav-height: 66px;
  --mc-topbar-height: 56px;
}

/* 1. App Environment Global Rules & Touch Physics */
html.is-mobile-app {
  min-height: 100% !important;
  height: auto !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  background-color: #050b18 !important;
  -webkit-tap-highlight-color: transparent;
}

body.is-mobile-app {
  min-height: 100% !important;
  height: auto !important;
  display: block !important;
  overflow-y: visible !important;
  overflow-x: hidden !important;
  touch-action: pan-y !important;
  -webkit-overflow-scrolling: touch !important;
  user-select: auto !important;
  -webkit-user-select: auto !important;
  background-color: #050b18 !important;
  padding-top: calc(var(--mc-topbar-height) + max(var(--mc-safe-top), 14px)) !important;
  padding-bottom: calc(var(--mc-nav-height) + var(--mc-safe-bottom) + 16px) !important;
  box-sizing: border-box;
}

body.is-mobile-app * {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* 1b. View Transition API - Native Screen Navigation Animation (turned on by app-environment.js in app mode, which every
   page loads first: this stylesheet arrives too late for the browser to agree on the transition) */

::view-transition-old(root) {
  animation: 160ms cubic-bezier(0.16, 1, 0.3, 1) both mc-view-fade-out;
}

::view-transition-new(root) {
  animation: 240ms cubic-bezier(0.16, 1, 0.3, 1) both mc-view-slide-in;
}

@keyframes mc-view-fade-out {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.98); }
}

@keyframes mc-view-slide-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 1c. Global Native Apple/Nike Touch Spring Physics */
body.is-mobile-app button:active,
body.is-mobile-app .btn:active,
body.is-mobile-app .mc-bottom-nav-item:active,
body.is-mobile-app .mc-btn-primary-app:active,
body.is-mobile-app [role="button"]:active,
body.is-mobile-app .action-pill:active {
  transform: scale(0.94) !important;
  transition: transform 0.1s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* 2. Hide bulky web elements inside the native mobile app */
body.is-mobile-app .site-footer,
body.is-mobile-app .home-footer,
body.is-mobile-app .preview-footer,
body.is-mobile-app footer,
body.is-mobile-app .official-enamad-wrap,
body.is-mobile-app .web-only,
body.is-mobile-app .pwa-install-banner,
body.is-mobile-app .desktop-landing,
body.is-mobile-app .mc-language-switch,
body.is-mobile-app .pm1-comparison,
body.is-mobile-app .preview-final,
body.is-mobile-app .drag-hint,
body.is-mobile-app header.site-header .web-nav-links {
  display: none !important;
}

/* Fail-safe: In native mobile app or mobile screen, ALWAYS render mobile-landing-shell on Home */
body.is-mobile-app .mobile-landing-shell,
html.is-mobile-app .mobile-landing-shell {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

@media (max-width: 768px) {
  body.has-mobile-landing .desktop-landing {
    display: none !important;
  }
  body.has-mobile-landing .mobile-landing-shell {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
}

/* Hide desktop web headers on subpages in native app (eliminates double-header & cut-off icons) */
body.is-mobile-app:not(.is-home-page) > header:not(.mc-app-topbar):not(.studio-header),
body.is-mobile-app:not(.is-home-page) .coach-app-header,
body.is-mobile-app:not(.is-home-page) .dashboard-header,
body.is-mobile-app:not(.is-home-page) .ops-header,
body.is-mobile-app:not(.is-home-page) header.site-header,
body.is-mobile-app:not(.is-home-page) header.bento-nav,
body.is-mobile-app:not(.is-home-page) header.fixed:not(.mc-app-topbar) {
  display: none !important;
}

/* Studio container smooth native scroll in app */
body.is-mobile-app .studio-container,
body.is-mobile-app .explorer-panel,
body.is-mobile-app .builder-sidebar {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
  flex: none !important;
}

body.is-mobile-app header.studio-header {
  position: relative !important;
  top: auto !important;
  z-index: 40 !important;
}

body.is-mobile-app header.studio-header:has(.studio-tools-menu[open]),
body.is-mobile-app header.studio-header.has-open-tools,
body.is-mobile-app header.studio-header:has(details[open]) {
  z-index: 250 !important;
}

body.is-mobile-app .mobile-studio-tabs {
  position: sticky !important;
  top: calc(var(--mc-topbar-height) + max(var(--mc-safe-top), 14px)) !important;
  z-index: 50 !important;
}

/* Adjust main container spacing in native app - eliminate double top padding */
body.is-mobile-app main:not(.explorer-panel) {
  padding-top: 8px !important;
  padding-bottom: 16px !important;
}

body.is-mobile-app .dashboard-main,
body.is-mobile-app .requests-page-container,
body.is-mobile-app .ops-main {
  padding-top: 10px !important;
  padding-bottom: 24px !important;
}

body.is-mobile-app .dashboard-shell,
body.is-mobile-app .ops-shell {
  width: 100% !important;
  max-width: 100% !important;
  padding-inline: 14px !important;
  box-sizing: border-box !important;
}

/* Hide bottom nav when dialog/modal is open to prevent overlapping action buttons */
body:has(dialog[open]) .mc-bottom-nav,
body:has(.modal.is-open) .mc-bottom-nav,
body.has-modal-open .mc-bottom-nav {
  display: none !important;
}

/* 3. Universal Native App Top Bar (Back Button + Title + Home Button) */
.mc-app-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9998;
  background: rgba(5, 11, 24, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: max(var(--mc-safe-top), 14px);
  padding-left: 12px;
  padding-right: 12px;
  height: calc(var(--mc-topbar-height) + max(var(--mc-safe-top), 14px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  direction: rtl;
}

html[dir="ltr"] .mc-app-topbar,
html[lang="en"] .mc-app-topbar,
html[dir="ltr"] .mc-bottom-nav,
html[lang="en"] .mc-bottom-nav {
  direction: ltr !important;
}

html[dir="ltr"] .mc-app-back-btn svg,
html[lang="en"] .mc-app-back-btn svg {
  transform: rotate(180deg);
}

.mc-app-nav-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #ffffff;
  height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  transition: all 0.2s ease;
  user-select: none;
  flex-shrink: 0;
}

.mc-app-nav-btn:active {
  background: rgba(199, 250, 40, 0.15);
  border-color: #c7fa28;
  color: #c7fa28;
  transform: scale(0.96);
}

.mc-app-nav-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.mc-app-topbar-title {
  font-size: 15px;
  font-weight: 900;
  color: #ffffff;
  margin: 0;
  text-align: center;
  flex: 1;
  padding: 0 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.mc-app-topbar-end {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mc-app-topbar-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  opacity: 0.95;
}

.mc-app-topbar .mc-session-actions,
.mc-app-topbar .notification-bell-wrap,
.mc-app-topbar .mc-session-logout {
  display: none !important;
}

/* 4. Native Bottom Navigation Bar */
.mc-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--mc-nav-height) + var(--mc-safe-bottom));
  padding-bottom: var(--mc-safe-bottom);
  background: rgba(5, 11, 24, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 99999;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.7);
  direction: rtl;
}

.mc-bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #8896ab;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  min-height: 48px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  cursor: pointer;
  background: transparent;
  border: none;
  outline: none;
  padding: 4px 0;
}

.mc-bottom-nav-item .nav-svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
}

.mc-bottom-nav-item.is-active {
  color: #c7fa28;
}

.mc-bottom-nav-item.is-active .nav-svg {
  fill: #c7fa28;
  transform: translateY(-2px);
  filter: drop-shadow(0 0 8px rgba(199, 250, 40, 0.6));
}

.mc-bottom-nav-item.is-active::after {
  content: '';
  position: absolute;
  bottom: calc(var(--mc-safe-bottom) + 3px);
  width: 16px;
  height: 3px;
  border-radius: 9999px;
  background: #c7fa28;
  box-shadow: 0 0 10px #c7fa28;
}

/* Center Highlight Tab (Workout Studio FAB) */
.mc-bottom-nav-item.is-center-fab {
  position: relative;
  top: -12px;
}

.mc-bottom-nav-item.is-center-fab .nav-icon-bubble {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3e7bff, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(62, 123, 255, 0.45), 0 0 0 4px #050b18;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mc-bottom-nav-item.is-center-fab .nav-icon-bubble .nav-svg {
  fill: #ffffff;
}

.mc-bottom-nav-item.is-center-fab:active .nav-icon-bubble {
  transform: scale(0.92);
}

/* 5. Mayhem-Style Empty State Card */
.program-view-empty-card {
  margin: 36px auto;
  max-width: 440px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 32px 20px;
  text-align: center;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  direction: rtl;
}

.empty-icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: rgba(199, 250, 40, 0.12);
  border: 1px solid rgba(199, 250, 40, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: #c7fa28;
}

/* 6. Mayhem-Style VIP Paywall Modal */
.mc-vip-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  direction: rtl;
  animation: mcFadeIn 0.25s ease-out;
}

.mc-vip-modal {
  background: radial-gradient(circle at 50% 0%, #17284f 0%, #050b18 100%);
  border: 1px solid rgba(199, 250, 40, 0.35);
  border-radius: 28px;
  padding: 32px 24px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(199, 250, 40, 0.15);
  box-sizing: border-box;
  animation: mcSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mc-vip-icon-ring {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(199, 250, 40, 0.2), rgba(62, 123, 255, 0.25));
  border: 2px solid #c7fa28;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 0 25px rgba(199, 250, 40, 0.4);
}

.mc-vip-modal-title {
  font-size: 19px;
  font-weight: 900;
  color: #ffffff;
  margin: 0 0 8px;
}

.mc-vip-modal-desc {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.65;
  margin: 0 0 24px;
}

.mc-vip-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@keyframes mcFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes mcSlideUp {
  from { transform: translateY(24px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Hide bottom nav during first-time welcome gate */
body.has-welcome-gate .mc-bottom-nav {
  display: none !important;
}

.mc-app-welcome-gate {
  display: none !important;
}

.mc-app-welcome-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 8px;
}

.mc-app-welcome-logo {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(62, 123, 255, 0.35);
  margin-bottom: 12px;
}

.mc-app-welcome-title {
  font-size: 24px;
  font-weight: 900;
  color: #ffffff;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.mc-app-welcome-sub {
  font-size: 13px;
  color: #94a3b8;
  max-width: 290px;
  line-height: 1.6;
  margin: 0;
}

/* Cards Carousel */
.mc-app-slider {
  margin: 20px 0;
  position: relative;
}

.mc-app-slide-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 24px;
  padding: 24px 20px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.mc-slide-icon-box {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(62, 123, 255, 0.2), rgba(199, 250, 40, 0.2));
  border: 1px solid rgba(199, 250, 40, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: #c7fa28;
}

.mc-slide-icon-box svg {
  width: 28px;
  height: 28px;
  fill: #c7fa28;
}

.mc-app-slide-title {
  font-size: 17px;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 8px;
}

.mc-app-slide-desc {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.65;
  margin: 0;
}

.mc-app-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.mc-app-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
  cursor: pointer;
}

.mc-app-dot.is-active {
  width: 24px;
  background: #c7fa28;
  box-shadow: 0 0 10px rgba(199, 250, 40, 0.5);
}

/* Actions Section */
.mc-app-welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.mc-btn-primary-app {
  width: 100%;
  padding: 15px;
  border-radius: 16px;
  background: #c7fa28;
  color: #050b18;
  font-size: 15px;
  font-weight: 900;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(199, 250, 40, 0.35);
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}

.mc-btn-secondary-app {
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}

.mc-btn-guest-app {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.mc-btn-guest-app:active {
  color: #c7fa28;
}

/* -------------------------------------------------------------
   7. Auth Page Luxury Dark Theme & Prominent Toast Notifications
------------------------------------------------------------- */
body.is-mobile-app.auth-luxury-page,
body.is-mobile-app .auth-shell,
html.dark .auth-luxury-page {
  background-color: #050b18 !important;
}

body.is-mobile-app .auth-stage,
html.dark .auth-stage {
  background: #0b1528 !important;
  border: 1px solid rgba(154, 181, 229, 0.18) !important;
  border-radius: 24px !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6) !important;
  isolation: auto !important; /* Prevents Android Chromium GPU tile black-out bug on text selection */
}

body.is-mobile-app .auth-form-pane,
html.dark .auth-form-pane {
  background: #0b1528 !important;
  color: #f8fafc !important;
}

body.is-mobile-app .auth-form-heading h1,
html.dark .auth-form-heading h1 {
  color: #ffffff !important;
}

body.is-mobile-app .auth-form-heading p,
html.dark .auth-form-heading p {
  color: #94a3b8 !important;
}

body.is-mobile-app .auth-role-label,
html.dark .auth-role-label {
  color: #94a3b8 !important;
}

body.is-mobile-app .auth-mode-toggle,
html.dark .auth-mode-toggle {
  background: #050b18 !important;
  border: 1px solid rgba(154, 181, 229, 0.2) !important;
  border-radius: 14px !important;
  padding: 5px !important;
}

body.is-mobile-app .auth-mode-toggle button,
html.dark .auth-mode-toggle button {
  color: #94a3b8 !important;
  font-weight: 700 !important;
  border-radius: 10px !important;
  transition: all 0.2s ease !important;
}

body.is-mobile-app .auth-mode-toggle button.text-primary,
html.dark .auth-mode-toggle button.text-primary {
  background: rgba(199, 250, 40, 0.15) !important;
  color: #c7fa28 !important;
  font-weight: 900 !important;
  border: none !important;
}

body.is-mobile-app input,
html.dark .auth-form-pane input,
.auth-luxury-page input {
  background: #050b18 !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  border: 1px solid rgba(154, 181, 229, 0.25) !important;
  border-radius: 12px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  -webkit-user-select: text !important;
  user-select: text !important;
}

body.is-mobile-app input:focus,
html.dark .auth-form-pane input:focus,
.auth-luxury-page input:focus {
  border-color: #c7fa28 !important;
  box-shadow: 0 0 12px rgba(199, 250, 40, 0.25) !important;
}

/* High-contrast submit button text */
#submitAuthBtn,
#submitAuthBtn span {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  font-weight: 800 !important;
}

.auth-role-grid {
  background: #050b18 !important;
  border: 1px solid rgba(154, 181, 229, 0.2) !important;
}

/* Fix Toast Notifications: Positioned safely ABOVE the native bottom nav bar */
.toast-container {
  position: fixed !important;
  z-index: 100002 !important;
  bottom: calc(var(--mc-nav-height, 64px) + var(--mc-safe-bottom, 0px) + 20px) !important;
  right: 16px !important;
  left: 16px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  pointer-events: none !important;
}

.toast {
  pointer-events: auto !important;
  width: 100% !important;
  max-width: 420px !important;
  border-radius: 14px !important;
  background: rgba(11, 21, 40, 0.98) !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7) !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  padding: 14px 18px !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.toast.show {
  transform: translateY(0) !important;
  opacity: 1 !important;
}

.toast.error {
  border-right: 4px solid #ef4444 !important;
  color: #fca5a5 !important;
}

.toast.success {
  border-right: 4px solid #10b981 !important;
  color: #6ee7b7 !important;
}

/* High-contrast text selection preventing invisible text on Android */
::selection {
  background: #c7fa28 !important;
  color: #050b18 !important;
}

::-moz-selection {
  background: #c7fa28 !important;
  color: #050b18 !important;
}

/* «مشاهده جدول کامل برنامه» on the athlete dashboard: in app mode the bottom bar's «برنامه‌ام» goes there already */
html.is-mobile-app .student-program-table-link { display: none !important; }
