/* index.html — 모바일 최적화 & 견적 도크/시트 */

@media (max-width: 960px) {
  body.has-estimate-dock {
    padding-bottom: calc(var(--dock-height) + var(--safe-bottom));
  }

  .app-shell {
    padding-left: calc(8px + var(--safe-left));
    padding-right: calc(8px + var(--safe-right));
    padding-bottom: 8px;
  }

  /* PC용 카드/단계 표시 제거 — 모바일은 탭·칩으로 구분 */
  .workspace {
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  .workspace-head {
    padding: 10px 8px 8px;
    border-bottom: 1px solid #f3f4f6;
  }

  .workspace-head::before {
    content: '광고상품 선택';
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
    padding: 0 2px;
    white-space: nowrap;
  }

  /* ── 1단계 상품: 회색 칩 → 선택 시 파란 채움, 좌우 스와이프 ── */
  .workspace-head .product-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: transparent;
    padding: 0 0 2px;
    gap: 6px;
    border-radius: 0;
  }

  .workspace-head .product-tabs::-webkit-scrollbar { display: none; }

  .workspace-head .product-tab {
    flex-shrink: 0;
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    background: #e8eaee;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
  }

  .workspace-head .product-tab-num {
    display: inline;
    font-size: 12px;
    font-weight: 700;
    opacity: 0.85;
    margin-right: 2px;
  }

  .workspace-head .product-tab.is-active .product-tab-num {
    opacity: 0.9;
  }

  .workspace-head .product-tab.is-active {
    background: var(--accent);
    color: #fff;
    box-shadow: none;
  }

  .workspace-head .product-tab:hover:not(.is-active) {
    background: #dfe2e8;
    color: #4b5563;
  }

  /* ── 2단계 보기: 텍스트만 — 미선택 회색 / 선택 파란 ── */
  .sub-nav {
    background: transparent;
    border-bottom: none;
    padding-top: 4px;
    flex-direction: column;
  }

  .sub-nav-head {
    display: none;
  }

  .sub-nav-primary {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
    padding: 4px 8px 8px;
    align-items: center;
    min-height: 0;
  }

  .sub-nav-primary::-webkit-scrollbar { display: none; }

  .sub-nav-extras {
    border-top: 1px solid #f3f4f6;
    margin-top: 2px;
    padding-top: 4px;
  }

  .sub-nav-extras-label {
    padding: 0 8px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.02em;
    text-transform: none;
    white-space: nowrap;
  }

  .sub-nav-extras-list {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
    padding: 0 8px 8px;
    align-items: center;
    min-height: 0;
  }

  .sub-nav-extras-list::-webkit-scrollbar { display: none; }

  .sub-nav .sub-nav-item {
    flex-shrink: 0;
    width: auto;
    min-height: 32px;
    padding: 4px 10px;
    border: none;
    border-radius: 0;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    color: #b0b8c4;
    box-shadow: none;
  }

  .sub-nav .sub-nav-item.is-active {
    background: transparent;
    color: var(--accent);
    font-weight: 700;
    box-shadow: none;
  }

  .sub-nav .sub-nav-item:hover {
    background: transparent;
    color: #9ca3af;
  }

  .sub-nav .sub-nav-item.is-active:hover {
    background: transparent;
    color: var(--accent);
  }

  .step-badge {
    display: none;
  }

  .preview-viewport {
    border: none;
    border-radius: 0;
  }

  .preview-viewport.extras-mockup {
    border: none;
    border-radius: 0;
  }

  /* 견적 시트 */
  .estimate-panel > .step-badge {
    display: none;
  }

  .estimate-head {
    display: none;
  }

  .estimate-body {
    padding: 0 12px 16px;
  }

  .date-range {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .date-range-sep {
    display: none;
  }

  .date-range-item,
  .date-range-item input[type="date"] {
    width: 100%;
    max-width: min(100%, 220px);
    min-width: 0;
  }

  .est-field input[type="date"] {
    font-size: 16px;
    width: 100%;
    max-width: min(100%, 220px);
    min-width: 0;
  }

  .est-field input[type="number"] {
    font-size: 16px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  :root {
    --vh-frac: 60dvh;
    --preview-max-h: min(500px, var(--vh-frac));
  }

  .app-shell {
    padding-left: calc(6px + var(--safe-left));
    padding-right: calc(6px + var(--safe-right));
  }

  .site-header {
    padding-left: calc(12px + var(--safe-left));
    padding-right: calc(12px + var(--safe-right));
  }

  .workspace-head {
    padding: 8px 4px 10px;
  }

  .workspace-title {
    display: none;
  }

  .workspace-body {
    min-height: 0;
  }

  .preview-area {
    padding: 4px 0 8px;
  }

  .preview-caption {
    font-size: 12px;
    margin-bottom: 6px;
    padding: 0 4px;
  }

  .preview-caption-desc {
    font-size: 11px;
    margin-top: 4px;
  }

  .preview-viewport {
    max-width: 100%;
  }

  .custom-select-trigger,
  .custom-select-option {
    min-height: 44px;
    font-size: 16px;
  }

  .estimate-price {
    font-size: 30px;
  }

  .estimate-price .won {
    font-size: 18px;
  }
}

/* 미리보기 뷰포트 — dvh */
.preview-viewport.is-map {
  height: var(--preview-max-h);
  max-height: var(--preview-max-h);
}

.preview-viewport.extras-mockup {
  height: var(--preview-max-h);
  max-height: var(--preview-max-h);
}

.preview-viewport.extras-mockup.is-fit {
  --fit-max-height: var(--preview-max-h);
  max-height: var(--preview-max-h);
}

.preview-viewport.extras-mockup.is-layout-pending,
.preview-viewport.extras-mockup.is-fit.is-layout-pending {
  height: var(--preview-max-h);
  max-height: var(--preview-max-h);
}

.preview-viewport.extras-mockup.is-spotlight.is-spotlight-auto {
  height: var(--preview-max-h);
  max-height: var(--preview-max-h);
}

/* ── 견적 도크 (모바일 하단 슬림 바) ── */
.estimate-dock {
  display: none;
}

@media (max-width: 960px) {
  .estimate-dock {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 940;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    padding-bottom: var(--safe-bottom);
    background: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 16px rgba(15, 23, 42, 0.1);
  }

  body.estimate-sheet-open .estimate-dock {
    display: none;
  }

  .estimate-dock__inner {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: var(--dock-height);
    padding: 8px 12px;
    border: none;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
  }

  .estimate-dock__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    flex-shrink: 0;
  }

  .estimate-dock__price {
    font-size: 17px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.02em;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .estimate-dock__price.is-empty {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
  }

  .estimate-dock__meta {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    flex-shrink: 0;
  }

  .estimate-dock__meta:empty { display: none; }

  .estimate-dock__cta {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
  }

  .estimate-dock__chevron {
    display: inline-block;
    font-size: 10px;
    margin-left: 2px;
  }

  /* ── 견적 바텀시트 ── */
  .estimate-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 950;
    max-height: min(75dvh, calc(100dvh - var(--safe-top) - 12px));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.14);
    margin: 0;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    padding-bottom: var(--safe-bottom);
  }

  body.estimate-sheet-open .estimate-panel {
    transform: translateY(0);
  }

  .estimate-sheet-handle {
    display: flex;
    justify-content: center;
    padding: 10px 0 4px;
    cursor: grab;
    touch-action: none;
  }

  .estimate-sheet-handle span {
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: #d1d5db;
  }

  .estimate-sheet-close {
    display: block;
    margin: 0 auto 4px;
    padding: 4px 12px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
  }

  .estimate-sheet-close:hover { color: var(--text); }

  .estimate-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 945;
    background: rgba(17, 24, 39, 0.4);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
  }

  .estimate-sheet-backdrop:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (min-width: 961px) {
  .estimate-sheet-handle,
  .estimate-sheet-close,
  .estimate-sheet-backdrop {
    display: none !important;
  }
}

/* 견적서 모달 모바일 */
.quote-modal-overlay {
  padding-top: calc(24px + var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
}

.quote-modal {
  max-height: calc(100vh - 48px - var(--safe-top) - var(--safe-bottom));
  max-height: calc(100dvh - 48px - var(--safe-top) - var(--safe-bottom));
}

@media (max-width: 640px) {
  .quote-document {
    padding: 8px 16px 24px;
  }

  .quote-recipient-form {
    padding: 0 16px 16px;
  }

  .quote-modal-actions {
    padding: 0 16px 24px;
  }

  .quote-title {
    font-size: 20px;
    letter-spacing: 0.2em;
  }

  .quote-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
  }

  .quote-table {
    min-width: 480px;
  }
}
