/*──────────────────────────────────────────────
  디바이스 종합 테스트 - 2025
  Design System based on 3EA
──────────────────────────────────────────────*/

:root {
  /* Brand Colors */
  --brand: #6366f1;
  --brand-hov: #4f46e5;
  --brand-light: #eef2ff;
  --brand-dark: #3730a3;

  /* Gray Scale */
  --g900: #18181b;
  --g700: #374151;
  --g500: #6b7280;
  --g300: #d4d4d8;
  --g200: #e5e7eb;
  --g100: #f3f4f6;
  --g50: #ffffff;

  /* Semantic Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* Typography */
  --fs-h1: 2rem;
  --fs-h2: 1.6rem;
  --fs-h3: 1.3rem;
  --fs-h4: 1.1rem;
  --fs-p: 1rem;
  --fs-meta: 0.9rem;

  /* Spacing */
  --sp1: 4px;
  --sp2: 8px;
  --sp3: 12px;
  --sp4: 16px;
  --sp5: 20px;
  --sp6: 24px;
  --sp8: 48px;

  /* Effects */
  --radius-card: 1.5rem;
  --shadow: 0 4px 32px rgba(0,0,0,.06), 0 2px 12px rgba(99,102,241,.10);
  --blur: 20px;
  --glass-bg: rgba(255,255,255,.8);
}

/*──────────────────────────────────────────────
  Reset & Base
──────────────────────────────────────────────*/
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font: 500 var(--fs-p)/1.6 Pretendard, system-ui, sans-serif;
  color: var(--g700);
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  position: relative;
  width: 100%;
  min-height: 100vh;
}

.screen {
  display: none;
  padding: var(--sp5);
  min-height: 100vh;
}

.screen.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/*──────────────────────────────────────────────
  Main Menu
──────────────────────────────────────────────*/
#main-menu {
  max-width: 1280px;
  margin: 0 auto;
}

.page-header {
  text-align: center;
  color: white;
  margin-bottom: var(--sp8);
  padding-top: var(--sp5);
}

.page-header h1 {
  font-size: var(--fs-h1);
  margin-bottom: var(--sp3);
  /*! text-shadow: 2px 2px 8px rgba(0,0,0,0.2); */
  font-weight: 700;
  color: black;
}

.subtitle {
  font-size: var(--fs-h4);
  opacity: 0.95;
  font-weight: 500;
}

.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--sp5);
  margin-bottom: var(--sp6);
}

.test-card {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur));
  border-radius: var(--radius-card);
  padding: var(--sp6);
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.8);
}

.test-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 40px rgba(0,0,0,.12), 0 4px 16px rgba(99,102,241,.15);
}

.test-card:active {
  transform: translateY(-2px);
}

.test-icon {
  font-size: 3em;
  margin-bottom: var(--sp4);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.test-card h3 {
  color: var(--g900);
  margin-bottom: var(--sp2);
  font-size: var(--fs-h3);
  font-weight: 700;
}

.test-card p {
  color: var(--g500);
  font-size: var(--fs-meta);
  margin-bottom: var(--sp3);
}

.test-badge {
  display: inline-block;
  padding: var(--sp1) var(--sp3);
  border-radius: 9999px;
  font-size: var(--fs-meta);
  font-weight: 600;
  background: var(--g200);
  color: var(--g700);
}

.test-badge.pass {
  background: color-mix(in srgb, var(--success) 20%, transparent);
  color: var(--success);
}

.test-badge.fail {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
  color: var(--danger);
}

/*──────────────────────────────────────────────
  Test Summary
──────────────────────────────────────────────*/
.test-summary {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur));
  border-radius: var(--radius-card);
  padding: var(--sp6);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.8);
}

.test-summary h3 {
  color: var(--g900);
  margin-bottom: var(--sp5);
  font-weight: 700;
  text-align: center;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--sp4);
}

.stat-item {
  text-align: center;
  padding: var(--sp4);
  background: white;
  border-radius: 12px;
  border: 2px solid var(--g200);
  transition: all 0.2s;
}

.stat-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-number {
  display: block;
  font-size: 2em;
  font-weight: 700;
  color: var(--g900);
  margin-bottom: var(--sp2);
}

.stat-label {
  display: block;
  font-size: var(--fs-meta);
  color: var(--g500);
}

.stat-item.stat-pass .stat-number {
  color: var(--success);
}

.stat-item.stat-fail .stat-number {
  color: var(--danger);
}

.stat-item.stat-pending .stat-number {
  color: var(--warning);
}

/*──────────────────────────────────────────────
  Card Component
──────────────────────────────────────────────*/
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur));
  border-radius: var(--radius-card);
  padding: var(--sp6);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.8);
  margin-bottom: var(--sp5);
}

.card h4 {
  color: var(--brand);
  font-size: var(--fs-h4);
  font-weight: 600;
  margin-bottom: var(--sp4);
  border-bottom: 2px solid var(--brand-light);
  padding-bottom: var(--sp2);
}

/*──────────────────────────────────────────────
  Buttons
──────────────────────────────────────────────*/
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp3) var(--sp5);
  font: 500 var(--fs-p)/1 Pretendard, system-ui, sans-serif;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--g100);
  color: var(--g700);
  min-height: 44px;
  touch-action: manipulation;
  user-select: none;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--brand);
  color: white;
}

.btn-primary:hover {
  background: var(--brand-hov);
}

.btn-secondary {
  background: var(--g200);
  color: var(--g700);
}

.btn-secondary:hover {
  background: var(--g300);
}

.btn-outline {
  background: white;
  border: 2px solid var(--brand);
  color: var(--brand);
}

.btn-outline:hover {
  background: var(--brand);
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: var(--sp2) var(--sp4);
  font-size: var(--fs-meta);
  min-height: 36px;
}

.btn-block {
  width: 100%;
  margin-top: var(--sp4);
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp3);
  margin-top: var(--sp4);
}

/*──────────────────────────────────────────────
  Test Header & Navigation
──────────────────────────────────────────────*/
.test-header {
  display: flex;
  align-items: center;
  gap: var(--sp4);
  margin-bottom: var(--sp6);
}

.back-btn {
  background: rgba(255,255,255,0.9);
  color: var(--brand);
  border: none;
  padding: var(--sp3) var(--sp5);
  border-radius: 9999px;
  cursor: pointer;
  font-size: var(--fs-p);
  font-weight: 600;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.back-btn:hover {
  background: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.test-header h2 {
  color: white;
  font-size: var(--fs-h2);
  font-weight: 700;
  /*! text-shadow: 2px 2px 4px rgba(0,0,0,0.2); */
  color: black;
}

.test-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp3);
  margin-bottom: var(--sp5);
}

.test-actions {
  display: flex;
  gap: var(--sp3);
  margin-top: var(--sp6);
  justify-content: center;
}

/*──────────────────────────────────────────────
  Fullscreen Tests (Display & Touch)
──────────────────────────────────────────────*/
.fullscreen-test {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: black;
  padding: 0;
  margin: 0;
  z-index: 9999;
  overflow: hidden;
}

/* 전체화면 모드일 때 */
.fullscreen-test:fullscreen,
.fullscreen-test:-webkit-full-screen,
.fullscreen-test:-moz-full-screen,
.fullscreen-test:-ms-fullscreen {
  width: 100vw;
  height: 100vh;
}

.fullscreen-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.95);
  backdrop-filter: blur(10px);
  padding: var(--sp3);
  display: flex;
  align-items: center;
  gap: var(--sp3);
  z-index: 10000;
  flex-wrap: wrap;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.fullscreen-header.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.fullscreen-header h2 {
  color: white;
  font-size: var(--fs-h4);
  margin: 0;
  flex: 1;
  min-width: 150px;
}

.exit-btn {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 2px solid rgba(255,255,255,0.3);
  padding: var(--sp2) var(--sp3);
  border-radius: 8px;
  cursor: pointer;
  font-size: var(--fs-meta);
  font-weight: 600;
  transition: all 0.2s;
  min-width: 70px;
  white-space: nowrap;
}

.exit-btn:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.5);
}

.exit-btn:active {
  transform: scale(0.95);
}

.test-controls-inline {
  display: flex;
  gap: var(--sp2);
  flex-wrap: wrap;
}

.test-controls-inline .btn {
  font-size: var(--fs-meta);
  padding: var(--sp1) var(--sp3);
  min-height: 32px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
}

.test-controls-inline .btn:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.5);
}

.fullscreen-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.95);
  backdrop-filter: blur(10px);
  padding: var(--sp3);
  z-index: 10000;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.5);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.fullscreen-footer.hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

/* UI 토글 버튼 */
.ui-toggle-btn {
  position: fixed;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.2);
  color: white;
  border: 2px solid rgba(255,255,255,0.4);
  padding: var(--sp3) var(--sp2);
  border-radius: 8px;
  cursor: pointer;
  font-size: var(--fs-meta);
  font-weight: 700;
  z-index: 10001;
  transition: all 0.2s;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  white-space: nowrap;
  backdrop-filter: blur(5px);
}

.ui-toggle-btn:hover {
  background: rgba(255,255,255,0.3);
  border-color: rgba(255,255,255,0.6);
  right: 5px;
}

.ui-toggle-btn.hidden-ui {
  background: rgba(100,255,100,0.3);
  border-color: rgba(100,255,100,0.6);
}

.test-info-text {
  color: white;
  text-align: center;
  margin-bottom: var(--sp3);
  font-size: var(--fs-meta);
}

.fullscreen-canvas {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: white;
  z-index: 9998;
}

/*──────────────────────────────────────────────
  Touch Test Grid
──────────────────────────────────────────────*/
.touch-grid-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  grid-auto-rows: minmax(30px, 1fr);
  gap: 2px;
  padding: var(--sp2);
  background: #1a1a1a;
  overflow: hidden;
  z-index: 9998;
  padding-top: 70px;
  padding-bottom: 100px;
  transition: padding 0.3s ease;
}

.touch-grid-container.ui-hidden {
  padding-top: var(--sp2);
  padding-bottom: var(--sp2);
}

.touch-target {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-hov) 100%);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 10px;
  box-shadow: 0 1px 4px rgba(99,102,241,0.3);
  user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
}

.touch-target:hover {
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(99,102,241,0.5);
}

.touch-target:active {
  transform: scale(0.98);
}

.touch-target.touched {
  animation: touchFadeOut 0.3s ease forwards;
}

@keyframes touchFadeOut {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.5;
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

.touch-stats {
  display: flex;
  gap: var(--sp4);
  color: white;
  font-size: var(--fs-meta);
}

.touch-stats strong {
  color: var(--brand-light);
  font-size: var(--fs-p);
}

/*──────────────────────────────────────────────
  Sound Controls
──────────────────────────────────────────────*/
.sound-controls {
  margin-bottom: var(--sp5);
}

.control-group {
  margin-bottom: var(--sp6);
}

.control-group label {
  display: block;
  margin-bottom: var(--sp3);
  color: var(--g700);
  font-weight: 600;
}

.slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  outline: none;
  background: var(--g200);
  -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.frequency-group,
.channel-group {
  margin-top: var(--sp5);
}

/*──────────────────────────────────────────────
  Alert Component
──────────────────────────────────────────────*/
.alert {
  padding: var(--sp4);
  border-radius: 12px;
  border-left: 4px solid;
  margin-bottom: var(--sp4);
  animation: fadeIn 0.3s ease;
}

.alert-primary {
  background: var(--brand-light);
  color: var(--brand-dark);
  border-color: var(--brand);
}

/*──────────────────────────────────────────────
  Sensor Display
──────────────────────────────────────────────*/
.sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--sp5);
  margin-bottom: var(--sp5);
}

.sensor-card {
  min-height: 180px;
}

.sensor-values p {
  margin: var(--sp3) 0;
  font-size: var(--fs-p);
  color: var(--g700);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sensor-values span {
  color: var(--brand);
  font-weight: 700;
  font-size: var(--fs-h4);
}

/*──────────────────────────────────────────────
  Camera
──────────────────────────────────────────────*/
.camera-container {
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: black;
  border-radius: var(--radius-card);
  overflow: hidden;
}

#camera-video {
  width: 100%;
  max-width: 100%;
  display: block;
  border-radius: var(--radius-card);
}

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--sp3);
  margin-top: var(--sp4);
}

.photo-gallery img {
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform 0.2s;
}

.photo-gallery img:hover {
  transform: scale(1.05);
}

/*──────────────────────────────────────────────
  Battery Display
──────────────────────────────────────────────*/
.battery-display {
  text-align: center;
  padding: var(--sp8) var(--sp6);
}

.battery-icon {
  width: 200px;
  height: 100px;
  border: 4px solid var(--g700);
  border-radius: 8px;
  position: relative;
  margin: 0 auto var(--sp6);
  background: var(--g100);
}

.battery-icon::after {
  content: '';
  position: absolute;
  right: -15px;
  top: 30px;
  width: 10px;
  height: 40px;
  background: var(--g700);
  border-radius: 0 4px 4px 0;
}

.battery-level {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #34d399);
  border-radius: 4px;
  transition: width 0.5s ease, background 0.5s ease;
}

.battery-info p {
  margin: var(--sp4) 0;
  font-size: var(--fs-h4);
  color: var(--g700);
}

.battery-info strong {
  color: var(--brand);
  font-weight: 700;
}

/*──────────────────────────────────────────────
  Network Info
──────────────────────────────────────────────*/
.network-info {
  padding: var(--sp6);
}

.network-info p {
  margin: var(--sp4) 0;
  font-size: var(--fs-h4);
  color: var(--g700);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.network-info strong {
  color: var(--brand);
  font-weight: 700;
}

/*──────────────────────────────────────────────
  Responsive Design
──────────────────────────────────────────────*/
@media (max-width: 768px) {
  :root {
    --fs-h1: 1.8rem;
    --fs-h2: 1.5rem;
    --fs-h3: 1.2rem;
    --fs-h4: 1rem;
  }

  .screen {
    padding: var(--sp4);
  }

  .test-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--sp4);
  }

  .test-card {
    padding: var(--sp4);
  }

  .test-icon {
    font-size: 2.5em;
  }

  .btn-grid {
    grid-template-columns: 1fr;
  }

  .fullscreen-header {
    padding: var(--sp2);
    gap: var(--sp2);
  }

  .fullscreen-header h2 {
    font-size: var(--fs-meta);
    min-width: 100px;
  }

  .exit-btn {
    font-size: 0.8rem;
    padding: var(--sp1) var(--sp2);
    min-width: 60px;
  }

  .test-controls-inline {
    width: 100%;
    gap: var(--sp1);
  }

  .test-controls-inline .btn {
    font-size: 0.75rem;
    padding: var(--sp1) var(--sp2);
    min-height: 28px;
  }

  .touch-grid-container {
    top: 50px;
    bottom: 80px;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    grid-auto-rows: minmax(50px, 1fr);
    gap: 2px;
    padding: var(--sp1);
  }

  .fullscreen-footer {
    padding: var(--sp2);
  }

  .test-info-text {
    font-size: 0.8rem;
    margin-bottom: var(--sp2);
  }

  .summary-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .touch-stats {
    font-size: 0.8rem;
    gap: var(--sp2);
  }

  .touch-stats strong {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .fullscreen-header h2 {
    font-size: 0.75rem;
  }

  .exit-btn {
    font-size: 0.7rem;
    min-width: 50px;
  }

  .touch-grid-container {
    top: 45px;
    bottom: 70px;
    grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
    grid-auto-rows: minmax(45px, 1fr);
  }

  .touch-target {
    font-size: 0.7rem;
  }

  .test-controls-inline .btn {
    font-size: 0.65rem;
    padding: 4px 8px;
    min-height: 24px;
  }
}

/* 가로 모드 (랜드스케이프) */
@media (max-height: 500px) and (orientation: landscape) {
  .fullscreen-header {
    padding: var(--sp1) var(--sp2);
  }

  .fullscreen-header h2 {
    font-size: 0.8rem;
  }

  .fullscreen-footer {
    padding: var(--sp1) var(--sp2);
  }

  .touch-grid-container {
    top: 40px;
    bottom: 60px;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    grid-auto-rows: minmax(40px, 1fr);
    gap: 1px;
  }

  .test-actions .btn {
    padding: var(--sp1) var(--sp3);
    min-height: 32px;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .page-header h1 {
    font-size: 1.5rem;
  }

  .test-card h3 {
    font-size: 1.1rem;
  }

  .stat-number {
    font-size: 1.8em;
  }
}

/*──────────────────────────────────────────────
  Animations
──────────────────────────────────────────────*/
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeInUp 0.4s ease;
}

/*──────────────────────────────────────────────
  Utilities
──────────────────────────────────────────────*/
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: var(--sp3); }
.mb-4 { margin-bottom: var(--sp4); }
.mb-5 { margin-bottom: var(--sp5); }

.text-center { text-align: center; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-3 { gap: var(--sp3); }
.gap-4 { gap: var(--sp4); }
