/* Base & Global Styles - Lunari Pro Max Standard */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #EFE8DE;
  font-family: var(--font-family);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Outer Shell for Desktop & Tablet Centering */
#app-viewport-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #EFE8DE;
  overflow: hidden;
  overflow-x: hidden;
}

/* Mobile Frame Container - Prevent unwanted horizontal overflow */
#app,
.mobile-frame {
  width: 100%;
  max-width: var(--app-max-width);
  height: 100%;
  max-height: 920px;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  overflow-x: hidden;
  box-shadow: 0 16px 48px rgba(125, 110, 102, 0.18);
  border-radius: 36px;
  contain: paint;
}

@media (max-width: 768px) {
  html, body {
    height: 100dvh;
    height: 100vh;
    background-color: var(--bg-app);
  }
  #app-viewport-wrapper {
    width: 100vw;
    height: 100dvh;
    height: 100vh;
    background-color: var(--bg-app);
  }
  #app,
  .mobile-frame {
    width: 100vw;
    max-width: 100%;
    height: 100dvh;
    height: 100%;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    overflow-x: hidden;
  }
}

/* Top Mobile Status Bar - Removed per user request for authentic clean app UI */
.mobile-status-bar {
  display: none !important;
}

/* App Main Content Area - 60fps Smooth Momentum Touch Scrolling */
#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-y;
  will-change: scroll-position;
}

#main-content::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Universal Smooth Scrolling & Touch Momentum Utilities */
.scrollable-y,
[data-scrollable="y"] {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-y;
}

.scrollable-y::-webkit-scrollbar,
[data-scrollable="y"]::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.scrollable-x,
[data-scrollable="x"] {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-x pan-y;
}

.scrollable-x::-webkit-scrollbar,
[data-scrollable="x"]::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Bottom Navigation Bar (Lunari Native Style) */
.bottom-nav {
  height: auto;
  min-height: 58px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px)) 12px;
  box-shadow: var(--shadow-bottom-nav);
  z-index: 40;
  flex-shrink: 0;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex: 1;
  max-width: 90px;
}

.nav-tab svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  transition: transform 0.2s ease;
}

.nav-tab.active {
  color: var(--primary);
  font-weight: 700;
}

.nav-tab.active svg {
  transform: translateY(-2px);
  stroke: var(--primary);
}

.nav-tab:hover {
  color: var(--primary);
}

/* Screen Transitions */
.screen {
  display: none;
  width: 100%;
  min-height: 100%;
  animation: fadeIn 0.25s ease-out;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

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

/* ==========================================================================
   Global RTL & Arabic Localization (.is-rtl)
   ========================================================================== */
html[dir="rtl"],
body.is-rtl,
.is-rtl {
  direction: rtl;
  text-align: right;
  font-family: var(--font-arabic);
}

/* Global Language Switcher Pill in Mobile Status Bar */
.lang-switcher-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  font-size: 11px;
  font-weight: 600;
  user-select: none;
  z-index: 100;
  transition: all 0.2s ease;
}

.lang-pill-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.2s ease;
  line-height: 1.2;
}

.lang-pill-btn:hover {
  color: var(--primary);
}

.lang-pill-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.lang-pill-divider {
  color: var(--text-muted);
  font-size: 10px;
  opacity: 0.6;
}

/* Base RTL Overrides */
.is-rtl input,
.is-rtl textarea,
.is-rtl select {
  direction: rtl;
  text-align: right;
  font-family: var(--font-arabic);
}

.is-rtl .screen-header {
  flex-direction: row;
  text-align: right;
}

.is-rtl .input-group {
  text-align: right;
}

.is-rtl .input-label {
  text-align: right;
  line-height: 1.6;
}

.is-rtl .screen-header .header-title {
  text-align: right;
}

.is-rtl .bottom-nav {
  direction: rtl;
}

/* Mobile status bar stays ltr so notch-clock and icons are natural, pill centered */
.mobile-status-bar {
  direction: ltr !important;
}

