/* ═══════════════════════════════════════════
   Geniego-ROI 모바일 PWA 최적화 CSS
   - Android/iPhone 완벽 지원
   - 설치 배너 / iOS 가이드 / 스플래시
   - 모바일 반응형 화면 표시 개선
   ═══════════════════════════════════════════ */

/* ── iOS/Android PWA safe area 변수 ──────── */
:root {
  --safe-t: env(safe-area-inset-top,    0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left,   0px);
  --safe-r: env(safe-area-inset-right,  0px);
}

/* ── PWA standalone 모드 ─────────────────── */
@media (display-mode: standalone), (display-mode: fullscreen) {
  body {
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

/* ── 공통 모바일 스타일 ──────────────────── */
@media (max-width: 768px) {
  /* 전체 폭 스크롤 방지 */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* iOS 입력 줌 방지 */
  input, select, textarea {
    font-size: 16px !important;
    -webkit-appearance: none;
    border-radius: 0;
  }

  /* 터치 피드백 개선 */
  * { -webkit-tap-highlight-color: transparent; }

  /* 테이블 가로 스크롤 래퍼 */
  .table-responsive-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* 차트 컨테이너 너비 제한 */
  svg { max-width: 100%; }

  /* 탭 가로 스크롤 */
  [role="tablist"] {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  [role="tablist"]::-webkit-scrollbar { display: none; }
}

/* ── PWA 설치 배너 ─────────────────────────── */
#pwa-install-banner {
  position: fixed;
  bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  left: 12px;
  right: 12px;
  background: linear-gradient(135deg, #1a2744, #0d1829);
  border: 1px solid rgba(79, 142, 247, 0.3);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(79, 142, 247, 0.1);
  z-index: 10000;
  animation: banner-slide-up 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes banner-slide-up {
  from { transform: translateY(80px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

#pwa-install-banner img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}

#pwa-install-banner .banner-text { flex: 1; min-width: 0; }
#pwa-install-banner .banner-title { font-weight: 800; font-size: 13px; color: #e8edf5; margin-bottom: 2px; }
#pwa-install-banner .banner-desc  { font-size: 10px; color: #4d6580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#pwa-install-btn {
  background: linear-gradient(135deg, #4f8ef7, #6366f1);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 9px 16px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  min-height: 44px;
}

#pwa-install-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.3);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  flex-shrink: 0;
  min-width: 32px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── iOS "홈 화면에 추가" 안내 ─────────────── */
#ios-install-guide {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(7, 15, 26, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px 20px 0 0;
  padding: 20px 24px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 10000;
  animation: slide-from-bottom 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slide-from-bottom {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.ios-guide-title  { font-size: 16px; font-weight: 800; color: #e8edf5; margin-bottom: 16px; text-align: center; }
.ios-guide-steps  { display: flex; flex-direction: column; gap: 12px; }
.ios-guide-step   { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #8fa3c0; }
.ios-guide-step-icon { font-size: 22px; flex-shrink: 0; }

#ios-install-close-btn {
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  color: #8fa3c0;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
}

/* ── 스플래시 스크린 ───────────────────────── */
#pwa-splash {
  position: fixed;
  inset: 0;
  background: #070f1a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.5s ease 1.5s, visibility 0.5s ease 1.5s;
}

#pwa-splash.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#pwa-splash img {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  box-shadow: 0 0 60px rgba(79, 142, 247, 0.4);
  animation: splash-pulse 1.5s ease-in-out infinite;
}

@keyframes splash-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 40px rgba(79,142,247,0.3); }
  50%       { transform: scale(1.05); box-shadow: 0 0 80px rgba(79,142,247,0.5); }
}

.splash-title {
  margin-top: 22px;
  font-size: 24px;
  font-weight: 900;
  background: linear-gradient(135deg, #4f8ef7, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.splash-sub {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.25);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
