/* ============================================================================ */
/* 제품 페이지 통합 레이아웃 CSS - Product Layout System */
/* ============================================================================ */
/* 
 * 모든 제품 페이지에서 공통으로 사용하는 레이아웃 스타일
 * 기존 namecard-compact.css를 기반으로 통합
 * 
 * 적용 제품: namecard, inserted, ncrflambeau, cadarok, envelope, 
 *           merchandisebond, msticker, sticker_new, littleprint
 * 
 * 주요 클래스:
 *   .product-container - 제품 페이지 메인 컨테이너
 *   .product-content - 2단 그리드 레이아웃 (갤러리 + 계산기)
 *   .product-calculator - 계산기 섹션
 *   .product-gallery - 갤러리 섹션
 * 
 * ⚠️ 주의: 계산 로직은 건드리지 않음 (JavaScript/PHP)
 */
/* ============================================================================ */

/* 명함 컴팩트 페이지 전용 스타일 - PROJECT_SUCCESS_REPORT.md 스펙 구현 */
/* Phase 1 Quick Win: 디자인 토큰 변수 적용 */

/* 디자인 토큰 자동 상속 (common-styles.css를 통해) */

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family-primary);
    background-color: var(--color-gray-100);
    color: var(--color-gray-900);
    line-height: var(--line-height-normal);
    overflow-x: hidden;  /* 모바일 좌우 스크롤 방지 */
    max-width: 100vw;
}

.product-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-5) var(--spacing-5) var(--spacing-5);
    background: var(--color-white);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

/* page-title 스타일은 common-styles.css에서 관리 (중복 제거) */

/* 컴팩트 2단 그리드 레이아웃 (50:50 비율로 개선) */
.product-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-8);
    min-height: 450px;
    max-width: 1200px;
    margin: 0 auto;
    align-items: start;
}

/* ============================================================================ */
/* 고급 이미지 갤러리 시스템 (적응형 이미지 분석 및 스마트 확대) */
/* ============================================================================ */

/* ============================================================================ */
/* 갤러리 배경 스타일은 common-styles.css 하단에서 최종 적용됨 */
/* ============================================================================ */

.product-gallery {
    display: flex;
    flex-direction: column;
    min-height: 500px;
    border-radius: 15px;
    padding: 14px;
    border: none; /* 외곽 테두리 완전 제거 - 통합된 레이아웃 */
}

.gallery-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.3rem;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #4a5568;
    padding-bottom: 10px;
}

/* 메인 이미지 표시 영역 - 고급 확대 기능 (GPU 가속, 450px 크기) */
.lightbox-viewer {
    width: 450px;
    height: 450px;
    max-width: 100%;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    margin: 0 auto 20px auto;
    cursor: crosshair;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: contain;
    will-change: background-position, background-size;
    transform: translateZ(0); /* GPU 레이어 강제 생성 */
}

/* 호버 효과는 zoom-active 클래스로 처리 */

/* 포스터 방식 호버링 확대 효과 */
.lightbox-viewer.zoom-active {
    background-size: 135%;
    transition: background-position 0.1s ease, background-size 0.3s ease;
}

/* 썸네일 영역 - 개선된 스타일 */
.thumbnail-strip {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    max-height: 120px;
    overflow-y: auto;
    padding: 5px;
}

.thumbnail {
    width: 80px;
    height: 80px;
    border: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    object-fit: cover;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
    will-change: transform, border-color, box-shadow;
}

.thumbnail.active {
    border-color: #4a5568;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transform: translateY(-2px) scale(1.05);
}

.thumbnail:hover {
    border-color: #4a5568;
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

/* ============================================================================ */
/* 실시간 가격 계산 시스템 */
/* ============================================================================ */

.product-calculator {
    display: flex;
    flex-direction: column;
    min-height: 500px;
    background: transparent;
    border-radius: 15px;
    padding: 25px;
    border: none; /* 외곽 테두리 완전 제거 - 통합된 레이아웃 */
    box-shadow: none;
}

.product-calculator > form {
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
}

/* 인라인 폼 컨테이너 - 고정 영역 */
.inline-form-container {
    flex-shrink: 0;
}

/* 추가 옵션 섹션 - 고정 영역 */
.leaflet-premium-options-section,
.premium-options-section {
    flex-shrink: 0;
    max-height: 150px;
    max-width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

/* 가격 표시 - 고정 영역 */
.price-display {
    flex-shrink: 0;
}

/* 가격 상세 정보 - 고정 영역 */
.price-breakdown {
    flex-shrink: 0;
}

/* 숨겨진 필드들 - 공간 차지하지 않도록 */
.product-calculator form input[type="hidden"] {
    display: none;
    height: 0;
    margin: 0;
    padding: 0;
}

.calculator-header {
    display: none;
}

.calculator-header h3 {
    display: none;
}

/* 옵션 선택 영역 - 개선된 그리드 레이아웃 */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.option-group {
    margin-bottom: 0;
}

.option-group.full-width {
    grid-column: 1 / -1;
}

.option-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
    font-size: 14px;
    text-align: center;
}

.option-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
    transition: all 0.3s ease;
    font-family: inherit;
    will-change: border-color, box-shadow;
}

.option-select:focus {
    outline: none;
    border-color: #4a5568;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.option-select:hover {
    border-color: #ced4da;
}

/* ============================================================================ */
/* 가격 표시 스타일은 common-styles.css에서 통합 관리됨 */
/* 제품별 특수 스타일만 여기에 추가 */
/* ============================================================================ */

.price-label {
    font-size: 1rem;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: 500;
}

.price-amount {
    font-size: 1.8rem;
    font-weight: 700;
    color: #28a745;
    margin-bottom: 10px;
    text-shadow: none;
}

.price-details {
    font-size: 0.85rem;
    color: #6c757d;
    line-height: 1.5;

    /* 한 줄 표시 - 스크롤 없이 */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 4px 8px;
    margin: 0;
}

/* 업로드 주문 버튼 - 프리미엄 스타일 */
.upload-order-button {
    margin-top: auto;
    text-align: center;
}

/* .btn-upload-order 스타일은 common-styles.css에서 통합 관리 (SSOT) */

/* ============================================================================ */
/* 파일 업로드 모달 시스템 (드래그 앤 드롭 및 고급 애니메이션) */
/* ============================================================================ */

.upload-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    animation: fadeInOverlay 0.3s ease-out;
}

@keyframes fadeInOverlay {
    from { background: rgba(0, 0, 0, 0); }
    to { background: rgba(0, 0, 0, 0.6); }
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    max-width: 1000px;
    max-height: 90vh;
    width: 95%;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
}

/* 모바일 모달 반응형 */
@media (max-width: 768px) {
    .modal-content {
        width: 98%;
        max-width: none;
        border-radius: 12px;
        margin: 10px;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 2px solid #dc3545;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 20px 20px 0 0;
}

.modal-title {
    color: #495057;
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    padding: 5px;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #dc3545;
    color: #333;
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 25px 30px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 20px;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 0 0 20px 20px;
}

.modal-btn {
    flex: 1;
    max-width: 350px;
    padding: 18px 30px;
    border: none;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.3);
    position: relative;
    overflow: hidden;
}

.upload-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 25px;
}

.upload-label {
    display: block;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    font-size: 1rem;
}

.upload-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.btn-upload-method {
    padding: 10px 18px;
    border: 2px solid #28a745;
    background: white;
    color: #28a745;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-upload-method.active {
    background: #28a745;
    color: white;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.btn-upload-method:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upload-area {
    margin-bottom: 20px;
}

/* 드래그 앤 드롭 존 - 고급 스타일 */
.upload-dropzone {
    border: 3px dashed #ccc;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    position: relative;
    overflow: hidden;
}

.upload-dropzone::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, rgba(220, 53, 69, 0.05) 0%, rgba(220, 53, 69, 0.02) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-dropzone:hover {
    border-color: #dc3545;
    background: #fff5f5;
    transform: scale(1.02);
}

.upload-dropzone:hover::before {
    opacity: 1;
}

.upload-dropzone.dragover {
    border-color: #dc3545;
    background: #fff5f5;
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(220, 53, 69, 0.2);
}

.upload-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 15px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.upload-text {
    color: #6c757d;
    font-size: 1rem;
    font-weight: 500;
}

.upload-info {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 12px;
    line-height: 1.5;
}

.memo-textarea {
    width: 100%;
    height: 140px;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9rem;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color 0.3s ease;
}

.memo-textarea:focus {
    outline: none;
    border-color: #4a5568;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.upload-notice {
    margin-top: 20px;
    padding: 15px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    border-left: 4px solid #ffc107;
}

.notice-item {
    font-size: 0.9rem;
    color: #856404;
    margin-bottom: 8px;
    font-weight: 500;
}

.notice-item:last-child {
    margin-bottom: 0;
}

/* 업로드된 파일 목록 */
.uploaded-files {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.uploaded-files h5 {
    color: #495057;
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.file-item:hover {
    border-color: #4a5568;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon {
    font-size: 1.4rem;
}

.file-details {
    font-size: 0.9rem;
}

.file-name {
    font-weight: 500;
    color: #495057;
    margin-bottom: 2px;
}

.file-size {
    color: #6c757d;
    font-size: 0.8rem;
}

.file-remove {
    background: #dc3545;
    color: #333;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.file-remove:hover {
    background: #c82333;
    transform: scale(1.05);
}

/* 주문 버튼들 */
.btn-cart {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

.btn-cart::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn-cart:hover::before {
    left: 100%;
}

.btn-cart:hover {
    background: linear-gradient(135deg, #20c997 0%, #17a2b8 100%);
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(40, 167, 69, 0.4);
}

/* 로딩 및 에러 상태 */
.loading, .error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 350px;
    font-size: 1.1rem;
    color: #6c757d;
    background: #f8f9fa;
    border-radius: 12px;
    font-weight: 500;
}

.error {
    color: #dc3545;
}

/* ============================================================================ */
/* 반응형 디자인 (모바일 퍼스트) */
/* ============================================================================ */

@media (max-width: 1024px) {
    .product-content {
        grid-template-columns: 1fr;
        gap: 25px;
        max-width: 100%;
    }
    
    .options-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .upload-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

@media (max-width: 768px) {
    /* 모바일 전체 오버플로우 방지 */
    *, *::before, *::after {
        max-width: 100vw;
        box-sizing: border-box;
    }

    .product-container {
        padding: 10px;
        border-radius: 10px;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        margin: 0;
        overflow-x: hidden;
    }

    /* 모바일 갤러리-계산기 간격 최적화 - 자연스럽게 이어지도록 */
    .product-content {
        gap: 0;
    }

    .page-title {
        padding: 20px 15px;
        border-radius: 10px;
        max-width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .page-title h1 {
        font-size: 1.8rem;
        text-align: center;
    }

    /* 모바일에서 재질보기 버튼 숨김 - 제목 중앙 정렬 */
    .page-title h1 .btn-texture-view {
        display: none;
    }

    .product-gallery {
        padding: 10px;
        padding-bottom: 0;
        margin-bottom: 0;
        border-radius: 10px;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
        min-height: auto;  /* 500px 제거 - 내용에 맞게 자동 조절 */
    }

    .product-calculator {
        padding: 15px;
        padding-top: 5px;
        border-radius: 10px;
        margin: 0 auto;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .lightbox-viewer {
        width: 350px;
        height: 350px;
    }
    
    .thumbnail {
        width: 60px;
        height: 60px;
    }
    
    .price-amount {
        font-size: 1.6rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
        border-radius: 15px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 20px;
    }
    
    .upload-dropzone {
        padding: 30px 20px;
    }
}

@media (max-width: 480px) {
    .product-content {
        gap: 20px;
    }
    
    .lightbox-viewer {
        width: 280px;
        height: 280px;
    }
    
    .options-grid {
        gap: 10px;
    }
    
    /* 모바일 셀렉트 통일 - 전단지 기준 */
    .inline-select,
    .option-select,
    .calculator-section select,
    .product-calculator select {
        flex: 1;
        min-width: 0;
        width: 100%;
        max-width: 100%;
        height: 36px;
        padding: 6px 10px;
        font-size: 0.85rem;
        box-sizing: border-box;
    }

    .inline-form-row {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .inline-label {
        width: 55px;
        min-width: 55px;
        flex-shrink: 0;
        font-size: 0.85rem;
    }
    
    .price-display {
        padding: 15px;
    }
    
    .btn-upload-order {
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    .thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .modal-btn {
        padding: 15px 20px;
        font-size: 1rem;
    }
}

/* ============================================================================ */
/* 성능 최적화 및 GPU 가속 */
/* ============================================================================ */

/* ============================================================================ */
/* GPU 가속 설정은 common-styles.css에서 통합 관리됨 */
/* ============================================================================ */

/* 샘플 더보기 버튼 스타일 */
.btn-more-samples {
    background: linear-gradient(135deg, #e0e0e0 0%, #d0d0d0 100%);
    color: #333;
    border: none;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    min-width: 140px;
}

.btn-more-samples:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a6fd8 0%, #6b3fa0 100%);
}

.btn-more-samples:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

/* 애니메이션 최적화 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms;
        animation-iteration-count: 1;
        transition-duration: 0.01ms;
    }
}
/* ============================================================================ */
/* 버튼 영역 - 갤러리 하단과 높이 맞춤 */
/* ============================================================================ */

.product-action-buttons {
    grid-column: 1 / -1; /* 양쪽 컬럼 모두 차지 */
    display: flex;
    gap: 15px;
    margin-top: 20px;
    align-items: flex-start;
}

.product-action-buttons .btn-upload-order {
    flex: 1;
    min-height: 60px;
}
