/* ============================================================
   estimate_styles.css
   andy_estimate_system.html / rev_estimate_system.html 공유 스타일
   브랜드 색상(--primary, --primary-hover)은 각 HTML <style>에서 정의
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --border: #d2d2d7;
    --shadow: rgba(0, 0, 0, 0.08);
    --radius: 18px;
    --radius-sm: 12px;
}

body {
    font-family:
        "Pretendard Variable",
        "Pretendard",
        -apple-system,
        BlinkMacSystemFont,
        sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 40px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.cart-badge {
    position: relative;
    padding: 8px 20px;
    background: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.cart-badge:hover {
    background: var(--primary-hover);
}

.cart-count {
    background: white;
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    margin-left: 8px;
}

.estimate-layout {
    max-width: 1400px;
    margin: 90px auto 0;
    padding: 40px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 30px;
}

.search-section {
    grid-column: 1 / -1;
    margin-bottom: 20px;
}

.products-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.search-box {
    background: white;
    border-radius: var(--radius);
    padding: 16px 24px;
    box-shadow: 0 2px 16px var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-input {
    width: 100%;
    border: none;
    font-size: 17px;
    color: var(--text-primary);
    outline: none;
    background: transparent;
    flex: 1;
}

.view-toggle-btn {
    border: 1px solid var(--border);
    background: white;
    color: var(--text-primary);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.view-toggle-btn:hover {
    background: var(--bg-secondary);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.products-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.products-grid.grouped-view {
    grid-template-columns: repeat(3, 1fr);
}

.products-grid.grouped-view .product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.products-grid.grouped-view .product-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 14px;
}

.products-grid.grouped-view .add-btn {
    margin-top: auto;
}

.product-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: 0 2px 8px var(--shadow);
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.product-image {
    width: 100%;
    height: 180px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.products-grid.grouped-view .product-image {
    height: 150px;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

.no-image {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f5f7 0%, #e8e8ed 100%);
    color: var(--text-secondary);
    font-size: 48px;
}

.products-grid.grouped-view .no-image {
    height: 150px;
}

.product-info {
    padding: 20px;
}

.product-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.product-number {
    background: var(--bg-secondary);
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 600;
}

.product-number.product-link {
    color: var(--primary);
    text-decoration: none;
}

.product-number.product-link:hover {
    text-decoration: underline;
}

.product-name {
    font-size: 19px;
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.3;
    letter-spacing: -0.3px;
}

.price-section {
    display: grid;
    gap: 8px;
    margin-bottom: 20px;
}

.price-item {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
}

.price-label {
    color: var(--text-secondary);
}

.price-value {
    font-weight: 600;
}

.price-main {
    font-size: 21px;
    color: var(--primary);
}

.price-discount {
    color: #ff3b30;
}

.add-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

.add-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.add-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}

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

.product-url-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 14px;
    padding: 5px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    transition: all 0.2s;
}

.product-url-btn:hover {
    border-color: var(--primary);
    background: #f0f7ff;
}

/* 장바구니 패널 */
.cart-panel {
    background: white;
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 2px 16px var(--shadow);
    position: sticky;
    top: 110px;
    align-self: start;
    transition: top 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 110px);
}

/* navbar가 headroom으로 숨겨졌을 때 상단 여백 제거 */
main:has(.headroom--unpinned) + .estimate-layout .cart-panel {
    top: 20px;
}

.cart-header {
    font-size: 21px;
    font-weight: 700;
    margin-bottom: 14px;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cart-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-count-inline {
    background: var(--bg-secondary);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
}

.cart-items {
    flex: 0 1 auto;
    overflow-y: auto;
    margin-bottom: 12px;
    max-height: 380px;
}

.cart-item {
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.cart-item-name {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.cart-item-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.cart-item-price {
    font-size: 17px;
    font-weight: 600;
    color: var(--primary);
}

.cart-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.quantity-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

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

.qty-value {
    min-width: 18px;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
}

.remove-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.remove-btn:hover {
    background: var(--bg-secondary);
    color: #ff3b30;
}

.cart-options {
    background: var(--bg-secondary);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.option-item {
    display: flex;
    align-items: center;
    padding: 4px 0;
}

.option-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: var(--primary);
}

.option-item label {
    font-size: 15px;
    cursor: pointer;
    user-select: none;
}

/* 할인코드 스타일 */
.discount-code-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.discount-code-input-wrapper {
    display: flex;
    gap: 6px;
}

.discount-code-input {
    flex: 1;
    padding: 7px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.discount-code-input:focus {
    border-color: var(--primary);
}

.apply-code-btn {
    padding: 7px 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.apply-code-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

.apply-code-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.discount-code-message {
    margin-top: 5px;
    font-size: 12px;
    min-height: 16px;
}

.discount-code-message.success {
    color: #34c759;
}

.discount-code-message.error {
    color: #ff3b30;
}

.discount-code-applied {
    margin-top: 8px;
    padding: 7px 10px;
    background: linear-gradient(135deg, #34c759 0%, #30d158 100%);
    color: white;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
}

.remove-code-btn {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.remove-code-btn:hover {
    background: rgba(255, 255, 255, 0.5);
}

.cart-summary {
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}

.summary-row.total {
    font-size: 18px;
    font-weight: 700;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 2px solid var(--text-primary);
}

.cart-notice {
    margin-top: 10px;
    padding: 10px 14px;
    background: #fff8e6;
    border: 1px solid #ffd666;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: #7a4f00;
    text-align: center;
    flex-shrink: 0;
}

.cart-actions {
    display: grid;
    gap: 8px;
    margin-top: 8px;
    flex-shrink: 0;
}

.btn {
    padding: 10px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    outline: none;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

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

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

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #e8e8ed;
}

.header-clear-btn {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.header-clear-btn:hover {
    color: #ff3b30;
    border-color: #ffb3ad;
    background: #fff5f4;
}

.cart-print-btn {
    width: 100%;
    padding: 11px 14px;
    font-size: 15px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.loading::after {
    content: "...";
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%,
    20% {
        content: ".";
    }
    40% {
        content: "..";
    }
    60%,
    100% {
        content: "...";
    }
}

/* 이메일 모달 */
.email-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.email-modal.active {
    display: flex;
}

.email-modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.email-modal-header {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.email-modal-desc {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.email-input-group {
    margin-bottom: 20px;
}

.email-input-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.email-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    transition: border-color 0.2s;
}

.email-input:focus {
    outline: none;
    border-color: var(--primary);
}

.email-modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.email-modal-actions .btn {
    flex: 1;
}

.email-status {
    margin-top: 16px;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: none;
}

.email-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.email-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.email-status.loading {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    display: block;
}

/* 인쇄 시 숨김 처리 (평소에는 표시) */
.print-header {
    display: none;
}

/* ── Brand Switch ── */
.brand-switch-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: inherit;
}

.brand-switch-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #e8f0fe;
}

/* 인쇄 스타일 */
@media print {
    @page {
        size: A4;
        margin: 20mm;
    }

    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body {
        background: white;
        margin: 0;
        padding: 0;
    }

    /* UI 요소 숨김 */
    .header,
    .pagination-wrapper,
    nav,
    .navbar,
    .search-section,
    .products-grid,
    .cart-options,
    .cart-actions,
    .remove-btn,
    .quantity-controls,
    .cart-header-actions,
    .brand-switch-btn,
    .discount-code-section,
    footer,
    .site-footer,
    .email-modal,
    .preloader {
        display: none !important;
    }

    /* 인쇄용 브랜드 헤더 */
    .print-header {
        display: flex !important;
        align-items: center;
        gap: 10px;
        padding-bottom: 16px;
        margin-bottom: 20px;
        border-bottom: 2px solid #1e2d7e;
    }

    .print-header img {
        height: 40px;
    }

    .print-header-title {
        font-size: 20px;
        font-weight: 700;
        color: #1e2d7e;
    }

    /* 컨테이너 리셋 */
    .estimate-layout {
        display: block;
        padding: 0;
        margin: 0;
        max-width: 100%;
    }

    /* 장바구니 패널 리셋 */
    .cart-panel {
        box-shadow: none;
        border-radius: 0;
        position: static;
        max-height: none;
        overflow: visible;
        padding: 0;
        width: 100%;
    }

    /* 장바구니 아이템 스크롤 제거 */
    .cart-items {
        overflow: visible;
        max-height: none;
        min-height: 0;
        margin-bottom: 16px;
    }

    /* 아이템 가격 줄바꿈 방지 */
    .cart-item-footer {
        display: flex;
    }

    /* 합계 영역 항상 표시 */
    .cart-summary {
        display: block !important;
        border-top: 2px solid #333;
        padding-top: 12px;
    }

    .summary-row.total {
        border-top: 2px solid #333;
    }

    /* 가견적 안내 인쇄 스타일 */
    .cart-notice {
        border: 1px solid #ccc;
        background: #fffbe6 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ── 페이지네이션 ─────────────────────────────────────────── */
.pagination-wrapper {
    grid-column: 1;
    display: flex;
    justify-content: center;
    margin-top: 8px;
    margin-bottom: 8px;
}

.pagination-inner {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1.5px solid var(--border);
    background: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-btn:hover:not(:disabled):not(.active) {
    border-color: var(--primary);
    color: var(--primary);
    background: #f0f7ff;
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 700;
}

.page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.page-ellipsis {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-secondary);
    user-select: none;
}

/* 반응형 */
@media (max-width: 1024px) {
    .estimate-layout {
        grid-template-columns: 1fr;
        padding: 20px;
    }

    .cart-panel {
        position: static;
        max-height: none;
    }
}

@media (max-width: 640px) {
    .search-box {
        flex-direction: column;
        align-items: stretch;
    }

    .view-toggle-btn {
        width: 100%;
    }

    .products-grid.grouped-view {
        grid-template-columns: 1fr;
    }

    .product-image,
    .no-image {
        height: 180px;
    }

    .logo {
        font-size: 20px;
    }

    .product-name {
        font-size: 17px;
    }

    .cart-header {
        font-size: 21px;
    }
}
