/* ===== 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: 390px; --h: 844px; --bezel: 12px;
  --radius-device: 64px; --radius-screen: 52px; --island-w: 120px; --island-h: 34px;
  --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 #35373d, 0 0 0 5px #0a0a0c, 0 40px 90px rgba(0, 0, 0, .55);
  transform: translate(-50%, -50%) scale(var(--scale));
  transform-origin: center;
}
.device[data-device="pixel8"] { --w: 412px; --h: 915px; --radius-device: 56px; --radius-screen: 44px; --island-w: 22px; --island-h: 22px; }
.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;
  contain: paint;
  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;
}
.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: #1C241E; opacity: .35; z-index: 95; pointer-events: none;
}
.device-screen[data-statusbar="light"] .home-indicator { background: #1C241E; opacity: .35; }

/* ----- Vùng router ----- */
.app-view { position: absolute; inset: 0; overflow: hidden; }
.screen {
  position: absolute; inset: 0;
  padding-top: 0; /* Header xanh tràn qua dynamic island & status bar */
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--color-bg, #fff);
  color: var(--color-text, #111);
}
.screen.has-tab { padding-bottom: var(--tabbar-height); }
.screen.has-tab .screen-content,
.screen.has-tab .screen-body {
  padding-bottom: 36px !important;
}
.screen-body, .screen-content {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.screen-body::-webkit-scrollbar, .screen-content::-webkit-scrollbar { width: 0; }
.screen-footer {
  flex-shrink: 0;
  position: relative;
  z-index: 30;
  background: #FFFFFF;
  padding-bottom: 28px !important;
}

/* Header tràn qua dynamic island & status bar lên đỉnh màn hình */
.screen > header,
.screen header {
  padding-top: calc(var(--statusbar-h) + 8px) !important;
  flex-shrink: 0;
}

/* Các màn hình không dùng thẻ header tiêu chuẩn */
.screen[data-screen="login"] .screen-body,
.screen[data-screen="_demo"] .screen-body {
  padding-top: calc(var(--statusbar-h) + 20px) !important;
}

.screen[data-screen="vital-hub"] {
  background: #082A1E !important;
}

.screen[data-screen="course-detail"] > div:first-child {
  height: 250px !important;
}

.screen[data-screen="lesson-player"] > div:first-child > div:first-child {
  padding-top: calc(var(--statusbar-h) + 6px) !important;
  position: relative;
  z-index: 100 !important;
}

/* ----- Tabbar chuẩn theo tài liệu đề án (active pill mint) ----- */
#tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--tabbar-height);
  display: flex; padding-bottom: 20px; z-index: 30;
  background: #FFFFFF; border-top: 1px solid #E8ECE9;
}
#tabbar[hidden] { display: none; }
#tabbar .tab {
  flex: 1; border: 0; background: none; cursor: pointer; font: inherit; font-size: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: #526058; font-weight: 500; transition: color 0.15s;
}
#tabbar .tab .tab-icon {
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 26px; border-radius: 13px; transition: background 0.15s;
}
#tabbar .tab.active {
  color: #0B3A29; font-weight: 700;
}
#tabbar .tab.active .tab-icon {
  background: #E8F5E9; color: #0B3A29;
}

/* ----- 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; } }
