/* ═══════════════════════════════════════════
   Template Preview Overlay
   시안: 템플릿미리보기 (4).html 기준
   ═══════════════════════════════════════════ */

/* ─── Font ─── */
@import url('https://cdn.jsdelivr.net/gh/wanteddev/wanted-sans@v1.0.1/packages/wanted-sans/fonts/webfonts/variable/split/WantedSansVariable.min.css');

/* ─── Overlay Container ─── */
.tpl-preview-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  background: var(--tpl-bg, #f5f5f5);
  display: none;
  flex-direction: column;
  font-family: 'Wanted Sans Variable', 'Wanted Sans', -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.tpl-preview-overlay.active {
  display: flex;
}

/* ─── CSS Variables ─── */
.tpl-preview-overlay {
  --tpl-black: #000;
  --tpl-dark: #111;
  --tpl-white: #fff;
  --tpl-bg: #f5f5f5;
  --tpl-gray-100: #f2f2f2;
  --tpl-gray-200: #e5e5e5;
  --tpl-gray-300: #d4d4d4;
  --tpl-gray-500: #737373;
  --tpl-gray-600: #525252;
  --tpl-gray-700: #404040;
  --tpl-blue: #4285F4;
  --tpl-blue-light: #EAF0FE;
  --tpl-blue-dark: #3B78DC;
}

/* ─── Top Bar ─── */
.tpl-top-bar {
  height: 56px; min-height: 56px;
  background: var(--tpl-white);
  border-bottom: 1px solid var(--tpl-gray-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}
.tpl-tb-left { display: flex; align-items: center; gap: 16px; }
.tpl-tb-back {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 500; color: var(--tpl-gray-600);
  text-decoration: none; cursor: pointer;
  transition: color 0.2s; background: none; border: none;
  font-family: inherit;
}
.tpl-tb-back:hover { color: var(--tpl-black); }
.tpl-tb-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.tpl-tb-center { display: flex; align-items: center; gap: 8px; }
.tpl-tb-device-btn {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--tpl-gray-200); background: var(--tpl-white);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s; color: var(--tpl-gray-500);
}
.tpl-tb-device-btn:hover { border-color: var(--tpl-gray-300); color: var(--tpl-black); }
.tpl-tb-device-btn.active { border-color: var(--tpl-blue); color: var(--tpl-blue); background: var(--tpl-blue-light); }
.tpl-tb-device-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.tpl-tb-right { display: flex; align-items: center; gap: 12px; }
.tpl-tb-nav-btn {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--tpl-gray-200); background: var(--tpl-white);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s; color: var(--tpl-gray-500);
}
.tpl-tb-nav-btn:hover { border-color: var(--tpl-gray-300); color: var(--tpl-black); }
.tpl-tb-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.tpl-tb-nav-btn:disabled:hover { border-color: var(--tpl-gray-200); color: var(--tpl-gray-500); }
.tpl-tb-nav-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tpl-tb-sep { width: 1px; height: 20px; background: var(--tpl-gray-200); }

/* ─── Main Layout ─── */
.tpl-preview-layout {
  display: grid; grid-template-columns: 1fr 400px;
  flex: 1; min-height: 0;
}

/* ─── Preview Panel (Left) ─── */
.tpl-preview-panel {
  background: var(--tpl-bg);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 32px;
  overflow: hidden;
}
.tpl-preview-frame-wrap {
  width: 100%; max-width: 100%;
  background: var(--tpl-white);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  overflow: hidden;
  position: relative;
  transition: max-width 0.4s ease, border-radius 0.4s ease;
}
.tpl-preview-frame-wrap.mobile-view {
  max-width: 390px;
  border-radius: 24px;
}
.tpl-preview-frame-wrap.tablet-view {
  max-width: 768px;
}
.tpl-preview-iframe {
  width: 100%; height: calc(100vh - 56px - 64px);
  border: none; display: block;
}

/* ─── Info Panel (Right) ─── */
.tpl-info-panel {
  background: var(--tpl-white);
  border-left: 1px solid var(--tpl-gray-200);
  padding: 32px;
  overflow-y: auto;
  height: calc(100vh - 56px);
  display: flex; flex-direction: column;
}
.tpl-info-top { flex: 1; }
.tpl-info-bottom { margin-top: auto; }

.tpl-info-mini-stats {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px;
}
.tpl-mini-stat {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 500; color: #C8C8C8;
}

.tpl-info-title {
  font-size: 26px; font-weight: 800; letter-spacing: -0.8px;
  line-height: 1.35; margin-bottom: 16px;
  color: var(--tpl-black);
}

.tpl-info-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.tpl-info-tag {
  padding: 5px 12px; border-radius: 5px;
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--tpl-gray-200); color: var(--tpl-gray-600);
}

.tpl-info-price-row {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 24px;
}
.tpl-info-price {
  font-size: 28px; font-weight: 800; color: var(--tpl-black);
  letter-spacing: -0.8px;
}
.tpl-info-price-won { font-size: 18px; font-weight: 600; color: var(--tpl-black); }
.tpl-info-price.free { color: var(--tpl-black); }
.tpl-info-price-original {
  font-size: 15px; color: var(--tpl-gray-300);
  text-decoration: line-through; font-weight: 400;
}

.tpl-info-actions { display: flex; gap: 10px; margin-bottom: 28px; }
.tpl-btn-like {
  width: 52px; height: 52px; border-radius: 12px;
  border: 1px solid var(--tpl-gray-200); background: var(--tpl-white);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s; color: #A3A3A3;
  flex-shrink: 0;
}
.tpl-btn-like:hover { color: #FF4B6E; }
.tpl-btn-like.liked { color: #FF4B6E; background: #FFF0F3; }
.tpl-btn-like svg { width: 18px; height: 18px; fill: currentColor; }
.tpl-btn-apply {
  flex: 1; height: 52px; border-radius: 12px;
  border: none; background: var(--tpl-dark); color: var(--tpl-white);
  font-size: 16px; font-weight: 700; cursor: pointer;
  font-family: inherit; transition: background 0.2s;
}
.tpl-btn-apply:hover { background: var(--tpl-black); }

/* ─── Creator ─── */
.tpl-creator-card {
  background: #FAFAFB; border-radius: 14px;
  padding: 24px; margin-bottom: 24px;
}
.tpl-creator-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.tpl-creator-left { display: flex; align-items: center; gap: 12px; }
.tpl-creator-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--tpl-blue), #64B5FF);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: var(--tpl-white);
}
.tpl-creator-name { font-size: 16px; font-weight: 700; color: var(--tpl-black); }
.tpl-creator-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--tpl-blue);
}
.tpl-creator-badge svg { width: 14px; height: 14px; }
.tpl-creator-link {
  font-size: 13px; color: var(--tpl-gray-500); text-decoration: none;
  display: flex; align-items: center; gap: 4px;
  border: 1px solid var(--tpl-gray-200); border-radius: 6px;
  padding: 6px 12px; transition: all 0.2s;
}
.tpl-creator-link:hover { border-color: var(--tpl-gray-300); color: var(--tpl-black); }
.tpl-creator-link svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tpl-creator-desc {
  font-size: 14px; color: var(--tpl-gray-500); line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Spec List ─── */
.tpl-spec-title {
  font-size: 15px; font-weight: 700; margin-bottom: 14px;
  color: var(--tpl-black);
}
.tpl-spec-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 28px; }
.tpl-spec-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px;
}
.tpl-spec-label { color: var(--tpl-gray-500); }
.tpl-spec-value { font-weight: 600; color: var(--tpl-black); }

/* ─── License ─── */
.tpl-license-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--tpl-gray-300);
  margin-bottom: 0;
}
.tpl-license-sep { color: var(--tpl-gray-200); }

/* ─── Mobile Handle (hidden on desktop) ─── */
.tpl-mobile-handle { display: none; }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .tpl-preview-layout { grid-template-columns: 1fr 340px; }
  .tpl-info-title { font-size: 22px; }
}

@media (max-width: 768px) {
  /* Layout: iframe 전체화면 */
  .tpl-preview-layout {
    display: block;
    position: relative;
    height: calc(100vh - 56px);
  }
  .tpl-preview-panel {
    height: 100%;
    padding: 0;
  }
  .tpl-preview-iframe {
    height: 100%;
  }
  .tpl-preview-frame-wrap {
    border-radius: 0;
    box-shadow: none;
    height: 100%;
  }

  /* Top bar: 디바이스 전환 숨김 */
  .tpl-tb-center { display: none; }
  .tpl-top-bar { padding: 0 16px; }

  /* ── 바텀시트: 기본 (접힌 상태) ── */
  .tpl-info-panel {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: auto;
    max-height: 200px;
    border-left: none;
    border-top: none;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.12);
    padding: 0 24px 24px;
    z-index: 10;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                border-radius 0.35s ease;
    overflow: hidden;
    display: block;
  }

  /* 드래그 핸들 */
  .tpl-mobile-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .tpl-mobile-handle span {
    display: block;
    width: 36px; height: 4px;
    background: var(--tpl-gray-300);
    border-radius: 4px;
    transition: background 0.2s;
  }
  .tpl-mobile-handle:active span { background: var(--tpl-gray-500); }

  /* 접힌 상태: 핵심 정보만 표시 */
  .tpl-info-panel:not(.tpl-info-expanded) .tpl-info-mini-stats,
  .tpl-info-panel:not(.tpl-info-expanded) .tpl-info-tags,
  .tpl-info-panel:not(.tpl-info-expanded) .tpl-creator-card,
  .tpl-info-panel:not(.tpl-info-expanded) .tpl-info-bottom { display: none; }

  .tpl-info-panel:not(.tpl-info-expanded) .tpl-info-title {
    font-size: 18px; font-weight: 700;
    margin-bottom: 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .tpl-info-panel:not(.tpl-info-expanded) .tpl-info-price-row {
    margin-bottom: 14px;
  }
  .tpl-info-panel:not(.tpl-info-expanded) .tpl-info-price {
    font-size: 22px;
  }
  .tpl-info-panel:not(.tpl-info-expanded) .tpl-btn-apply {
    height: 46px; font-size: 15px; border-radius: 10px;
  }
  .tpl-info-panel:not(.tpl-info-expanded) .tpl-btn-like {
    width: 46px; height: 46px; border-radius: 10px;
  }
  .tpl-info-panel:not(.tpl-info-expanded) .tpl-info-actions {
    margin-bottom: 0;
  }

  /* ── 바텀시트: 펼친 상태 ── */
  .tpl-info-panel.tpl-info-expanded {
    max-height: calc(100vh - 56px);
    border-radius: 0;
    padding: 0 24px 32px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tpl-info-panel.tpl-info-expanded .tpl-info-top {
    padding-top: 0;
  }
  .tpl-info-panel.tpl-info-expanded .tpl-info-title {
    font-size: 22px;
  }
  .tpl-info-panel.tpl-info-expanded .tpl-btn-apply {
    height: 48px; font-size: 15px;
  }
  .tpl-info-panel.tpl-info-expanded .tpl-btn-like {
    width: 48px; height: 48px;
  }
}
