/* Base Reset & Mobile Simulator Layout */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

/* Desktop Simulator Shell */
.app-viewport-wrapper {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, #151D2F 0%, #080C14 100%);
  position: relative;
  overflow: hidden;
}

/* Ambient glow in background */
.app-viewport-wrapper::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  filter: blur(60px);
}

/* Top Simulator Control Bar (Desktop Controls) */
.simulator-controls {
  position: fixed;
  top: 16px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition-normal);
}

.sim-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text-primary);
  padding-right: 12px;
  border-right: 1px solid var(--border-color);
}

.sim-logo-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.sim-btn-group {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-full);
  padding: 2px;
  border: 1px solid var(--border-color);
}

.sim-control-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.sim-control-btn:hover {
  color: var(--text-primary);
}

.sim-control-btn.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(var(--accent-primary-rgb), 0.4);
}

.sim-persona-select {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.sim-user-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}


/* Phone Device Frame (iPhone 16 Pro styling) */
.mobile-device-frame {
  width: var(--phone-width);
  height: var(--phone-height);
  max-height: 92vh;
  border-radius: var(--phone-radius);
  background: var(--bg-app);
  border: 10px solid #1E232E;
  outline: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 25px 70px -10px rgba(0, 0, 0, 0.75), 0 0 0 1px #0A0D14;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: center;
}

/* Mode: Fullscreen responsive (toggleable) */
.app-viewport-wrapper.mode-fullscreen .mobile-device-frame {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  border: none;
  outline: none;
  box-shadow: none;
}

.app-viewport-wrapper.mode-fullscreen .simulator-controls {
  top: 10px;
  right: 16px;
  left: auto;
  transform: none;
}

/* Phone Notch / Dynamic Island */
.dynamic-island {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 32px;
  background: #000000;
  border-radius: 20px;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.camera-lens {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #080D1A;
  border: 1.5px solid #141A28;
}

.speaker-sensor {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle, #0F172A 40%, #000 90%);
}

/* Mobile Status Bar */
.mobile-status-bar {
  height: var(--status-bar-height);
  width: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  z-index: 990;
  user-select: none;
  flex-shrink: 0;
  padding-top: 6px;
}

.status-time {
  letter-spacing: -0.2px;
  font-weight: 600;
  font-size: 14px;
}

.status-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-icons svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

/* Main Mobile App Container */
.mobile-app-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-app);
}

/* Mobile Screens Host */
.screens-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Screen Page Container */
.screen-page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-height) + 24px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.99);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  scrollbar-width: none;
}

.screen-page::-webkit-scrollbar {
  display: none;
}

.screen-page.active-screen {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  z-index: 10;
}

/* Safe Home Indicator at Bottom */
.phone-home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 100px;
  z-index: 999;
  pointer-events: none;
  transition: background 0.2s ease;
}

[data-app-theme="light"] .phone-home-indicator {
  background: rgba(0, 0, 0, 0.3);
}

/* Screen Content Wrapper */
.screen-content {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Global Typography Helpers */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

p {
  color: var(--text-secondary);
}

a {
  color: var(--accent-primary);
  text-decoration: none;
}

button {
  font-family: var(--font-sans);
}

/* ==========================================================================
   Real phone / small screen: drop the phone-frame simulator, use full screen
   ========================================================================== */
@media (max-width: 640px), (pointer: coarse) and (max-width: 1100px) {
  /* Chari pashe faka. 1.5cm chaile niche 1cm ke 1.5cm kore dao */
  :root { --screen-gap: 1cm; }

  html, body { height: 100%; }

  .app-viewport-wrapper,
  .app-viewport-wrapper.mode-fullscreen {
    width: 100%;
    height: 100vh;
    height: 100dvh;            /* correct height with Chrome/Safari address bar */
    justify-content: flex-start;
    align-items: stretch;
    padding-top: max(var(--screen-gap), env(safe-area-inset-top, 0px));
    padding-bottom: max(var(--screen-gap), env(safe-area-inset-bottom, 0px));
    padding-left: max(var(--screen-gap), env(safe-area-inset-left, 0px));
    padding-right: max(var(--screen-gap), env(safe-area-inset-right, 0px));
  }
  .app-viewport-wrapper::before { display: none; }

  /* Top bar becomes a slim strip in normal flow (no longer covers content) */
  .app-viewport-wrapper .simulator-controls,
  .app-viewport-wrapper.mode-fullscreen .simulator-controls {
    position: static;
    top: auto; left: auto; right: auto;
    transform: none;
    width: 100%;
    flex-shrink: 0;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 0;
    box-shadow: none;
  }
  .sim-brand,
  .sim-btn-group { display: none; }

  .sim-user-indicator {
    flex: 1;
    min-width: 0;
  }
  .sim-auth-status {
    display: block !important;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #sim-btn-logout, #sim-theme-toggle { flex-shrink: 0; white-space: nowrap; }

  /* App fills the rest of the screen, no fake phone around it */
  .app-viewport-wrapper .mobile-device-frame,
  .app-viewport-wrapper.mode-fullscreen .mobile-device-frame {
    width: 100%;
    height: auto;
    flex: 1;
    min-height: 0;
    max-height: none;
    border: none;
    outline: none;
    border-radius: 0;
    box-shadow: none;
  }

  /* Phone already has its own notch / status bar / home bar */
  .dynamic-island,
  .mobile-status-bar,
  .phone-home-indicator { display: none; }

  .mobile-bottom-nav { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
}
