/* ===== Shell: khung điện thoại trên web ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: var(--font-sans, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  background: #0e1014;
  background-image: radial-gradient(1200px 600px at 50% 0%, #1b2030 0%, #0e1014 70%);
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ----- Thiết bị (preset) ----- */
.device {
  --w: 402px;
  --h: 874px;
  --bezel: 8px;
  --radius-device: 62px;
  --radius-screen: 54px;
  --island-w: 110px;
  --island-h: 30px;
  --scale: 1;
  position: absolute; left: 50%; top: 50%;
  width: calc(var(--w) + var(--bezel) * 2);
  height: calc(var(--h) + var(--bezel) * 2);
  padding: var(--bezel);
  border-radius: var(--radius-device);
  background: #17181b;
  box-shadow: 0 0 0 2px #3c3e44, 0 0 0 5px #0a0a0c, 0 40px 90px rgba(0, 0, 0, .55);
  transform: translate(-50%, -50%) scale(var(--scale));
  transform-origin: center;
}

/* Preset iPhone 18 */
.device[data-device="iphone18"] {
  --w: 402px;
  --h: 874px;
  --bezel: 8px;
  --radius-device: 62px;
  --radius-screen: 54px;
  --island-w: 110px;
  --island-h: 30px;
}

/* Preset iPhone 15 */
.device[data-device="iphone15"] {
  --w: 390px;
  --h: 844px;
  --bezel: 12px;
  --radius-device: 64px;
  --radius-screen: 52px;
  --island-w: 120px;
  --island-h: 34px;
}

/* Preset Pixel 8 */
.device[data-device="pixel8"] {
  --w: 412px;
  --h: 915px;
  --bezel: 12px;
  --radius-device: 56px;
  --radius-screen: 44px;
  --island-w: 22px;
  --island-h: 22px;
}

/* Preset SE */
.device[data-device="se"] {
  --w: 375px;
  --h: 667px;
  --bezel: 18px;
  --radius-device: 48px;
  --radius-screen: 28px;
  --island-w: 0px;
  --island-h: 0px;
}

.device[data-device="se"] .island {
  display: none;
}

/* Khi mở trên điện thoại thật: bỏ khung */
.device.bare {
  --w: 100vw;
  --h: 100dvh;
  --bezel: 0px;
  --radius-device: 0;
  --radius-screen: 0;
  box-shadow: none;
  background: none;
  left: 0;
  top: 0;
  transform: none;
}

.device.bare .island {
  display: none;
}

.device.bare .home-indicator {
  display: none;
}

/* ----- Màn hình ----- */
.device-screen {
  --statusbar-h: 54px;
  --tabbar-height: 84px;
  position: relative;
  width: var(--w);
  height: var(--h);
  border-radius: var(--radius-screen);
  overflow: hidden;
  background: var(--color-bg, #fff);
  color: var(--color-text, #111);
  isolation: isolate;
}

.device[data-device="se"] .device-screen {
  --statusbar-h: 24px;
  --tabbar-height: 56px;
}

.device[data-device="se"] .home-indicator {
  display: none;
}

.island {
  position: absolute;
  top: 11px;
  left: 50%;
  transform: translateX(-50%);
  width: var(--island-w);
  height: var(--island-h);
  border-radius: 999px;
  background: #000;
  z-index: 90;
  transition: width 0.3s ease, height 0.3s ease;
}

.statusbar {
  position: absolute;
  inset: 0 0 auto 0;
  height: var(--statusbar-h);
  padding: 18px 30px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  color: var(--color-text, #111);
  z-index: 80;
  pointer-events: none;
}

.device-screen[data-statusbar="light"] .statusbar {
  color: #fff;
}

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

.home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  border-radius: 3px;
  background: var(--color-text, #111);
  opacity: .8;
  z-index: 95;
  pointer-events: none;
}

.device-screen[data-statusbar="light"] .home-indicator {
  background: #fff;
}

/* ----- Vùng router ----- */
.app-view {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  padding-top: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-bg, #fff);
  color: var(--color-text, #111);
}

.screen.has-tab {
  padding-bottom: var(--tabbar-height);
}

.screen-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.screen-body::-webkit-scrollbar {
  width: 0;
}

/* ----- Tabbar (tối thiểu; component-library sẽ làm đẹp) ----- */
#tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--tabbar-height);
  display: flex;
  padding-bottom: 22px;
  z-index: 30;
  background: var(--color-surface, #fff);
  border-top: 1px solid var(--color-border, #e5e7eb);
}

#tabbar[hidden] {
  display: none;
}

#tabbar .tab {
  flex: 1;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--color-text-muted, #6b7280);
}

#tabbar .tab.active {
  color: var(--color-primary, #2563eb);
}

/* ----- Overlay (modal / sheet / toast gắn vào đây) ----- */
.overlay-root {
  position: absolute;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}

.overlay-root>* {
  pointer-events: auto;
}

/* ----- Animation chuyển màn ----- */
.screen.in-push {
  animation: inPush .30s cubic-bezier(.3, .7, .2, 1) both;
  z-index: 2;
}

.screen.out-push {
  animation: outPush .30s cubic-bezier(.3, .7, .2, 1) both;
  z-index: 1;
}

.screen.in-pop {
  animation: inPop .30s cubic-bezier(.3, .7, .2, 1) both;
  z-index: 1;
}

.screen.out-pop {
  animation: outPop .30s cubic-bezier(.3, .7, .2, 1) both;
  z-index: 2;
}

.screen.in-fade {
  animation: fadeIn .20s ease both;
}

.screen.out-fade {
  animation: fadeOut .20s ease both;
}

@keyframes inPush {
  from {
    transform: translateX(100%);
  }

  to {
    transform: none;
  }
}

@keyframes outPush {
  to {
    transform: translateX(-28%);
    opacity: .6;
  }
}

@keyframes inPop {
  from {
    transform: translateX(-28%);
    opacity: .6;
  }

  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes outPop {
  to {
    transform: translateX(100%);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen {
    animation-duration: .01s !important;
  }
}
