/* ==========================================================================
   ANDROID EMULATOR & MOBILE APP TESTING STUDIO (#view-emulator)
   Giao diện ngụy trang Studio phát triển / kiểm thử ứng dụng di động Android
   Tỷ lệ điện thoại dọc 9:16 với thanh Logcat và kịch bản test chuyên nghiệp
   ========================================================================== */

#view-emulator {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  background-color: #1e1f22;
  color: #bcbec4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "JetBrains Mono", Consolas, monospace;
  overflow: hidden;
  user-select: none;
}

/* 1. HEADER STUDIO */
.emu-header {
  height: 48px;
  background-color: #2b2d30;
  border-bottom: 1px solid #1e1f22;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 50;
}

.emu-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.emu-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #dfe1e5;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.emu-logo:hover {
  opacity: 0.8;
}

.emu-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(61, 220, 132, 0.12);
  border: 1px solid rgba(61, 220, 132, 0.3);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  color: #3ddc84;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.emu-status-dot {
  width: 7px;
  height: 7px;
  background-color: #3ddc84;
  border-radius: 50%;
  animation: emuPulse 1.8s infinite;
}

@keyframes emuPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(61, 220, 132, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); }
}

.emu-metrics-bar {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: #868a91;
}

.emu-metrics-bar b {
  color: #ced0d6;
}

.emu-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.emu-tool-btn {
  background: #393b40;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #dfe1e5;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.emu-tool-btn:hover {
  background: #43454a;
  color: #ffffff;
}

.emu-tool-btn.active {
  background: #2e436e;
  border-color: #3574f0;
  color: #70a5ff;
}

.emu-btn-panic {
  background: #b91c1c;
  color: #ffffff;
  border: none;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.emu-btn-panic:hover {
  background: #dc2626;
}

/* 2. WORKSPACE 3 CỘT */
.emu-workspace {
  flex: 1;
  display: flex;
  height: calc(100vh - 48px);
  overflow: hidden;
}

/* 2.1 CỘT TRÁI: TEST SCENARIOS */
.emu-suite-panel {
  width: 320px;
  background-color: #2b2d30;
  border-right: 1px solid #1e1f22;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.emu-panel-header {
  height: 38px;
  background-color: #26282b;
  border-bottom: 1px solid #1e1f22;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #8c9096;
}

.emu-badge-count {
  background: #393b40;
  color: #9aa0a6;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
}

.emu-search-box {
  padding: 10px 12px;
  display: flex;
  gap: 6px;
  border-bottom: 1px solid #1e1f22;
}

.emu-search-box input {
  flex: 1;
  background: #1e1f22;
  border: 1px solid #393b40;
  border-radius: 4px;
  padding: 6px 10px;
  color: #ffffff;
  font-size: 12px;
  outline: none;
}

.emu-search-box input:focus {
  border-color: #3574f0;
}

.emu-search-box button {
  background: #393b40;
  border: 1px solid #4e5157;
  color: #ffffff;
  border-radius: 4px;
  padding: 0 10px;
  cursor: pointer;
}

.emu-tags-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  border-bottom: 1px solid #1e1f22;
}

.emu-tag-btn {
  background: #1e1f22;
  border: 1px solid #393b40;
  color: #9aa0a6;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.emu-tag-btn:hover, .emu-tag-btn.active {
  background: #3574f0;
  color: #ffffff;
  border-color: #3574f0;
}

.emu-scenario-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: #3e4147 transparent;
}

/* Custom scrollbar thanh mảnh sang trọng cho emu-scenario-list */
.emu-scenario-list::-webkit-scrollbar {
  width: 5px;
}

.emu-scenario-list::-webkit-scrollbar-track {
  background: transparent;
}

.emu-scenario-list::-webkit-scrollbar-thumb {
  background: #393b40;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.emu-scenario-list::-webkit-scrollbar-thumb:hover {
  background: #3ddc84;
}

.emu-scenario-item {
  display: flex;
  gap: 10px;
  padding: 8px;
  background: #232428;
  border: 1px solid #33363b;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.emu-scenario-item:hover {
  background: #2d3036;
  border-color: #4b4e54;
}

.emu-scenario-item.active {
  background: #1f3358;
  border-color: #3574f0;
}

.emu-scenario-thumb {
  width: 44px;
  height: 78px;
  border-radius: 4px;
  object-fit: cover;
  background: #111;
  flex-shrink: 0;
}

.emu-scenario-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.emu-tc-code {
  font-size: 10px;
  color: #3ddc84;
  font-weight: 700;
  margin-bottom: 2px;
}

.emu-scenario-title {
  font-size: 12px;
  color: #dfe1e5;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.emu-scenario-stats {
  font-size: 10px;
  color: #8c9096;
}

.emu-btn-load-more {
  margin: 8px;
  padding: 8px;
  background: #393b40;
  border: 1px solid #4e5157;
  color: #dfe1e5;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.emu-btn-load-more:hover {
  background: #43454a;
}

/* 2.2 KHU VỰC TRUNG TÂM: THIẾT BỊ ẢO (VIRTUAL DEVICE CHASSIS) */
.emu-device-stage {
  flex: 1;
  background: radial-gradient(circle at center, #26282d 0%, #17181a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

/* Khung điện thoại Pixel chuẩn kim loại */
.emu-phone-chassis {
  position: relative;
  width: 380px;
  height: 800px;
  max-height: 90vh;
  background-color: #121316;
  border-radius: 44px;
  border: 12px solid #2f3237;
  box-shadow: 0 30px 80px rgba(0,0,0,0.8), 0 0 0 2px rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  overflow: visible; /* Để hiển thị nút phần cứng ở cạnh */
}

/* Camera nốt ruồi */
.emu-notch-camera {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  background: #000;
  border: 1px solid #222;
  border-radius: 50%;
  z-index: 40;
}

/* Màn hình cảm ứng */
.emu-touch-screen {
  flex: 1;
  position: relative;
  border-radius: 32px;
  overflow: hidden;
  background-color: #000000;
  display: flex;
  flex-direction: column;
}

/* Status bar */
.emu-phone-status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  font-size: 11px;
  color: #ffffff;
  z-index: 30;
  pointer-events: none;
}

.emu-clock {
  font-weight: 600;
}

.emu-test-watermark {
  display: none !important;
}

.emu-phone-icons {
  display: flex;
  gap: 6px;
  font-size: 10px;
  opacity: 0.85;
}

/* Trình phát Shorts tràn viền toàn bộ màn hình */
.emu-player-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
}

.emu-video-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #000000;
  pointer-events: none;
}

/* Lớp kính bắt tương tác vuốt và cuộn chuột wheel đè lên trên iframe */
.emu-touch-gesture-layer {
  position: absolute;
  inset: 0;
  z-index: 25;
  cursor: grab;
}

.emu-touch-gesture-layer:active {
  cursor: grabbing;
}

/* Ẩn hoàn toàn lớp phủ text đè lên màn hình điện thoại theo yêu cầu người dùng */
.emu-overlay-info {
  display: none !important;
}

.emu-overlay-info .emu-scenario-title {
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.emu-scenario-sub {
  color: #93c5fd;
  font-size: 11px;
}

/* Loading */
.emu-screen-loading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 35;
}

.emu-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #3ddc84;
  border-radius: 50%;
  animation: emuSpin 0.75s linear infinite;
}

@keyframes emuSpin {
  to { transform: rotate(360deg); }
}

/* Thanh điều hướng 3 nút ảo Android dưới đáy mỏng trong suốt không che video */
.emu-android-nav-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-around;
  color: #ffffff;
  opacity: 0.35;
  font-size: 11px;
  z-index: 30;
  border-top: none;
  pointer-events: none;
}

.emu-android-nav-bar span {
  pointer-events: auto;
  cursor: pointer;
  padding: 2px 16px;
  transition: opacity 0.15s ease;
}

.emu-android-nav-bar span:hover {
  opacity: 1;
  color: #3ddc84;
}

/* Phím cứng mô phỏng bên hông máy */
.emu-hardware-key {
  position: absolute;
  background: #393b40;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.1s ease;
}

.emu-hardware-key:hover {
  background: #3ddc84;
}

.key-vol-up {
  left: -16px;
  top: 140px;
  width: 4px;
  height: 48px;
}

.key-vol-down {
  left: -16px;
  top: 200px;
  width: 4px;
  height: 48px;
}

.key-power {
  right: -16px;
  top: 160px;
  width: 4px;
  height: 60px;
}

/* 2.3 CỘT PHẢI: LOGCAT CONSOLE & DEVICE METRICS */
.emu-logcat-panel {
  width: 340px;
  background-color: #2b2d30;
  border-left: 1px solid #1e1f22;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.emu-btn-mini {
  background: #393b40;
  border: 1px solid #4e5157;
  color: #ced0d6;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.emu-logcat-console {
  flex: 1;
  background: #1e1f22;
  padding: 10px;
  font-family: "JetBrains Mono", Consolas, "Courier New", monospace;
  font-size: 11px;
  line-height: 1.5;
  overflow-y: auto;
  color: #abb2bf;
}

.emu-log-line {
  margin-bottom: 4px;
  word-break: break-all;
}

.emu-log-info { color: #61afef; }
.emu-log-success { color: #98c379; }
.emu-log-warn { color: #e5c07b; }
.emu-log-debug { color: #7f848e; }

.emu-device-specs {
  background: #26282b;
  border-top: 1px solid #1e1f22;
  padding: 12px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.emu-spec-row {
  display: flex;
  justify-content: space-between;
}

.emu-spec-row span {
  color: #8c9096;
}

.emu-spec-row b {
  color: #dfe1e5;
}

/* Responsive */
@media (max-width: 1024px) {
  .emu-logcat-panel { display: none; }
}

@media (max-width: 768px) {
  .emu-suite-panel { display: none; }
  .emu-phone-chassis {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
}
