/* ==========================================================================
   KNG ERP 견적서 관리 (Quotation) 전용 스타일시트
   - ECOUNT ERP 표준 고밀도 디자인 시스템 (완전 독립 내장)
   - 품목별 사진 썸네일 및 드롭존 스타일
   - 정규 A4 인쇄 / PDF 최적화 (@media print)
   ========================================================================== */

:root {
    --erp-primary: #2563eb;
    --erp-primary-hover: #1d4ed8;
    --erp-primary-light: #eff6ff;
    --erp-success: #10b981;
    --erp-warning: #f59e0b;
    --erp-danger: #ef4444;
    --erp-dark: #1e293b;
    --erp-th-bg: #f8fafc;
    --erp-border: #cbd5e1;
    --erp-border-light: #e2e8f0;
    --erp-text: #1e293b;
    --erp-text-muted: #64748b;
    --erp-row-hover: #f1f5f9;
    --erp-row-active: #eff6ff;
    --erp-row-focused: #e0e7ff;
    --erp-font-size: 11.5px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Pretendard', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    background-color: #f8fafc;
    color: var(--erp-text);
    margin: 0;
    padding: 6px 10px;
    font-size: var(--erp-font-size);
    line-height: 1.35;
    -webkit-font-smoothing: antialiased;
}

/* ── 1. ECOUNT ERP 1행 탑 툴바 (.erp-top-toolbar) ── */
.erp-top-toolbar {
    background: #ffffff;
    border: 1px solid var(--erp-border);
    border-radius: 3px;
    padding: 4px 8px;
    min-height: 38px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.erp-title-tag {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding-right: 12px;
    border-right: 1px solid var(--erp-border-light);
    letter-spacing: -0.3px;
}

/* 탭 버튼 그룹 */
.erp-tab-group {
    display: inline-flex;
    gap: 2px;
    background: #f1f5f9;
    padding: 2px;
    border-radius: 3px;
}

.erp-tab-btn {
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 2px;
    background: transparent;
    color: var(--erp-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 18px;
    user-select: none;
}

.erp-tab-btn:hover {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.7);
}

.erp-tab-btn.active {
    background: #ffffff !important;
    color: var(--erp-primary) !important;
    border-color: var(--erp-border) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.erp-tab-badge {
    font-size: 9.5px;
    padding: 0 5px;
    border-radius: 8px;
    background: #e2e8f0;
    color: #475569;
    font-weight: 700;
}

.erp-tab-btn.active .erp-tab-badge {
    background: #dbeafe;
    color: #1e40af;
}

/* 견적 바구니 배지 버튼 */
.btn-quote-cart {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    border: none;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(234, 88, 12, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: transform 0.15s ease;
}

.btn-quote-cart:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(234, 88, 12, 0.4);
}

/* ── 2. ECOUNT ERP 버튼 시스템 (.btn-erp) ── */
.btn-erp {
    height: 26px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 0 9px;
    border-radius: 2px;
    background: #ffffff;
    border: 1px solid var(--erp-border);
    color: #334155;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.1s ease;
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
}

.btn-erp:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

.btn-erp-primary {
    background: var(--erp-primary) !important;
    border-color: var(--erp-primary) !important;
    color: #ffffff !important;
}

.btn-erp-primary:hover {
    background: var(--erp-primary-hover) !important;
    border-color: var(--erp-primary-hover) !important;
}

.btn-erp-warning {
    background: #f59e0b !important;
    border-color: #d97706 !important;
    color: #ffffff !important;
}

.btn-erp-warning:hover {
    background: #d97706 !important;
}

.btn-erp-danger {
    background: #ffffff !important;
    border-color: #fca5a5 !important;
    color: #dc2626 !important;
}

.btn-erp-danger:hover {
    background: #fef2f2 !important;
    border-color: #ef4444 !important;
}

.key-shortcut-badge {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 2px;
    padding: 1px 4px;
    font-size: 9.5px;
    font-weight: bold;
    letter-spacing: 0.5px;
    margin-left: 2px;
}

.btn-erp-primary .key-shortcut-badge {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* ── 3. ECOUNT ERP 2행 필터 리본 (.erp-filter-ribbon) ── */
.erp-filter-ribbon {
    background: #ffffff;
    border: 1px solid var(--erp-border);
    border-radius: 3px;
    padding: 4px 8px;
    min-height: 34px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.erp-stock-filters {
    display: inline-flex;
    gap: 2px;
    background: #f1f5f9;
    padding: 2px;
    border-radius: 3px;
}

.erp-filter-chip {
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 2px;
    background: transparent;
    color: var(--erp-text-muted);
    cursor: pointer;
    transition: all 0.1s ease;
    line-height: 18px;
    user-select: none;
}

.erp-filter-chip:hover {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.6);
}

.erp-filter-chip.active {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: var(--erp-border) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.erp-input-date {
    height: 26px !important;
    font-size: 11.5px !important;
    padding: 1px 6px !important;
    border: 1px solid var(--erp-border) !important;
    border-radius: 2px !important;
    width: 120px !important;
}

.erp-search-box {
    width: 250px;
    position: relative;
}

.erp-search-box .form-control {
    height: 26px !important;
    font-size: 11.5px !important;
    padding-left: 8px;
    padding-right: 24px;
    border-radius: 2px;
    border: 1px solid var(--erp-border);
}

.erp-search-box .form-control:focus {
    border-color: var(--erp-primary);
    box-shadow: 0 0 0 1.5px rgba(37, 99, 235, 0.2);
}

/* ── 4. ECOUNT ERP 테이블 시스템 (.erp-table & .erp-table-wrapper) ── */
.erp-table-wrapper {
    background: #ffffff;
    border: 1px solid var(--erp-border);
    border-radius: 3px;
    overflow-x: auto;
    overflow-y: auto;
    box-sizing: border-box;
    position: relative;
}

.erp-table {
    width: 100%;
    border-collapse: collapse !important;
    font-size: 11.5px;
    margin: 0 !important;
    background-color: #ffffff;
}

.erp-table thead th {
    background-color: var(--erp-th-bg) !important;
    color: #1e293b !important;
    font-weight: 700 !important;
    text-align: center !important;
    vertical-align: middle !important;
    padding: 3px 6px !important;
    font-size: 11px !important;
    border: 1px solid var(--erp-border) !important;
    white-space: nowrap !important;
    position: sticky !important;
    top: 0;
    z-index: 6;
    height: 28px !important;
    user-select: none;
}

.erp-table thead th.sortable {
    cursor: pointer;
}

.erp-table thead th.sortable:hover {
    background-color: #e2e8f0 !important;
}

.erp-table tbody td {
    padding: 2px 6px !important;
    border: 1px solid var(--erp-border) !important;
    vertical-align: middle !important;
    background-color: #ffffff;
    height: 28px !important;
    font-size: 11.5px;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.erp-table tbody tr:hover td {
    background-color: var(--erp-row-hover) !important;
}

.erp-table tbody tr.cursor-pointer {
    cursor: pointer;
}

/* ── 5. 견적서 작성기 폼 & 카드 스타일 ── */
.quote-header-box .card {
    border-color: var(--erp-border) !important;
    border-radius: 3px;
}

.quote-header-box .card-header {
    background-color: #f8fafc !important;
    border-bottom: 1px solid var(--erp-border);
    font-size: 12px;
}

.erp-form-table {
    width: 100%;
    margin: 0;
    font-size: 11.5px;
    border-collapse: collapse;
}

.erp-form-table th,
.erp-form-table td {
    padding: 3px 6px;
    border: 1px solid var(--erp-border-light);
    vertical-align: middle;
}

.erp-form-table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #334155;
    font-size: 11px;
}

.erp-form-table .form-control,
.erp-form-table .form-select {
    font-size: 11.5px;
    padding: 2px 6px;
    height: 25px;
    border-radius: 2px;
    border-color: var(--erp-border);
}

.quote-stamp-preview {
    position: absolute;
    right: 28px;
    top: 22px;
    width: 58px;
    height: 58px;
    object-fit: contain;
    opacity: 0.88;
    pointer-events: none;
    z-index: 5;
    mix-blend-mode: multiply;
}

/* 총 견적금액 요약 리본 */
.quote-summary-ribbon {
    background: #ffffff;
    border: 1px solid var(--erp-border);
    border-radius: 3px;
    padding: 6px 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* ── 6. 품목 그리드 내 사진 셀 스타일 [사용자 요구사항] ── */
.quote-item-thumb-box {
    width: 44px;
    height: 44px;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    margin: 0 auto;
    overflow: hidden;
    transition: all 0.15s ease;
}

.quote-item-thumb-box:hover {
    border-color: var(--erp-primary);
    box-shadow: 0 0 0 1px var(--erp-primary);
}

.quote-item-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: #ffffff;
}

.quote-item-thumb-empty {
    font-size: 9.5px;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
}

.quote-item-thumb-empty i {
    font-size: 16px;
    margin-bottom: 2px;
}

/* ── 7. 이미지 업로드 드롭존 모달 ── */
.image-dropzone {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.image-dropzone:hover,
.image-dropzone.dragover {
    border-color: var(--erp-primary);
    background: #eff6ff;
}

/* ── 8. 모달 공통 스타일 ── */
.erp-modal-content {
    border-radius: 4px;
    border: 1px solid var(--erp-border);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.erp-modal-header {
    background-color: #f8fafc;
    border-bottom: 1px solid var(--erp-border);
    padding: 6px 12px;
}

.erp-modal-footer {
    background-color: #f8fafc;
    border-top: 1px solid var(--erp-border);
    padding: 6px 12px;
}

/* 토스트 */
.toast-container .toast {
    font-size: 12px;
    border-radius: 3px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: #1e293b;
    color: #ffffff;
    padding: 8px 14px;
    margin-top: 6px;
}

.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.warning { background: #d97706; }
.toast.info { background: #2563eb; }

/* ── 인쇄 전용 영역 초기 숨김 ── */
.print-only {
    display: none;
}

/* ==========================================================================
   A4 정규 견적서 인쇄 / PDF 전용 스타일 (@media print)
   - 사진 가로세로 비율 완벽 유지 (object-fit: contain)
   - 대표 직인 날인 완벽 오버랩
   ========================================================================== */
@media print {
    @page {
        size: A4 portrait;
        margin: 10mm 10mm 12mm 10mm;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-family: 'Pretendard', 'Noto Sans KR', sans-serif !important;
        padding: 0 !important;
        margin: 0 !important;
        font-size: 11pt !important;
    }

    .no-print,
    .erp-top-toolbar,
    .erp-filter-ribbon,
    .modal,
    .toast-container {
        display: none !important;
    }

    #quotationListView,
    #quotationEditorView {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    /* ── A4 정규 견적서 서식 레이아웃 ── */
    .a4-quote-page {
        width: 100%;
        max-width: 190mm;
        margin: 0 auto;
        color: #111111;
        line-height: 1.35;
        box-sizing: border-box;
    }

    /* ── 입출고내역 거래명세서 동일 상단 헤더 ── */
    .header-container {
        display: flex;
        justify-content: space-between;
        margin-bottom: 6px;
        align-items: flex-end;
        width: 100%;
    }
    .header-left {
        flex: 1;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    /* 공급자 표 미포함 시 상단 헤더 중앙 정렬 */
    .header-container.no-supplier {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 2px solid #000;
        width: 100%;
    }
    .header-container.no-supplier .title-box {
        margin-bottom: 6px;
        text-align: center;
    }
    .header-container.no-supplier .title-box h1 {
        font-size: 26px;
        letter-spacing: 6px;
        margin: 0;
        text-align: center;
    }
    .header-container.no-supplier .recipient-box {
        margin-bottom: 6px;
        font-size: 16px;
        text-align: center;
    }
    .header-container.no-supplier .date-info {
        font-size: 11.5px;
        color: #333333;
        text-align: center;
    }
    .title-box {
        padding-bottom: 4px;
        margin-bottom: 8px;
    }
    .title-box h1 {
        margin: 0;
        font-size: 26px;
        letter-spacing: 6px;
        font-weight: 800;
        white-space: nowrap;
        color: #000000;
    }
    .recipient-box {
        margin-bottom: 6px;
    }
    .recipient-name {
        font-size: 18px;
        font-weight: bold;
        color: #000000;
    }
    .date-info {
        font-size: 12px;
        color: #333333;
    }

    /* ── 공급자 표 (정산장부/거래명세서 380px 표준) ── */
    .supplier-table {
        border-collapse: collapse;
        border: 2px solid black;
        width: 380px;
        font-size: 11px;
        margin-left: auto;
    }
    .supplier-table th, .supplier-table td {
        border: 1px solid black;
        padding: 3px 4px;
        text-align: center;
        height: 24px;
        white-space: nowrap;
    }
    .supplier-table th {
        background-color: #f9f9f9 !important;
        font-weight: bold;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color: #000000;
    }
    .vertical-th {
        width: 22px;
        writing-mode: vertical-lr;
        letter-spacing: 6px;
        padding-top: 6px !important;
        text-align: center;
    }
    .stamp-cell {
        position: relative;
    }
    .stamp {
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        width: 42px;
        height: 42px;
        opacity: 0.92;
        mix-blend-mode: multiply;
    }
    .address-cell {
        white-space: normal !important;
        text-align: left !important;
        padding-left: 6px !important;
        font-size: 10px;
        line-height: 1.2;
    }

    /* ── 금액란 (사용자 요청: 합 계 금 액 : ₩ 3,410,880) ── */
    .amount-box {
        border: 2px solid black;
        padding: 6px 14px;
        margin-top: 8px;
        margin-bottom: 8px;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        font-size: 14px;
        font-weight: 800;
        background: #ffffff;
        letter-spacing: 1px;
    }

    /* 인쇄 직인 도장 날인 */
    .a4-seal-stamp {
        position: absolute;
        right: 18px;
        top: 24px;
        width: 54px;
        height: 54px;
        object-fit: contain;
        opacity: 0.9;
        mix-blend-mode: multiply;
        z-index: 10;
    }

    /* 본문 품목 테이블 */
    .a4-items-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 9pt;
        margin-top: 10px;
        margin-bottom: 12px;
    }

    .a4-items-table th,
    .a4-items-table td {
        border: 1px solid #333333;
        padding: 4px 5px;
        vertical-align: middle;
    }

    .a4-items-table thead th {
        background-color: #f1f5f9;
        font-weight: 700;
        text-align: center;
        height: 26px;
    }

    .a4-items-table tbody tr {
        page-break-inside: avoid;
    }

    /* 인쇄 사진 스타일 [사용자 요구사항 완벽 반영: 원비율 유지] */
    .a4-item-img {
        width: 48px;
        height: 48px;
        object-fit: contain;
        display: block;
        margin: 0 auto;
        background: #ffffff;
    }

    .a4-items-table tfoot th,
    .a4-items-table tfoot td {
        background-color: #f8fafc;
        font-weight: 700;
        border-top: 2px solid #111111;
    }

    /* 하단 특이사항 및 결제 안내 */
    .a4-footer-notes {
        border: 1px solid #666666;
        padding: 8px 10px;
        font-size: 8.5pt;
        margin-top: 8px;
        background-color: #ffffff;
        page-break-inside: avoid;
    }

    .a4-footer-notes-title {
        font-weight: 700;
        margin-bottom: 4px;
        color: #111111;
    }
}

/* ═══════════════════════════════════════════════════════════════
   인쇄 옵션 모달 전용 프리미엄 디자인
   ═══════════════════════════════════════════════════════════════ */
.print-modal-card {
    border: 1px solid #cbd5e1 !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.05) !important;
    overflow: hidden;
}

.print-modal-header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 18px !important;
}

.print-modal-icon-badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #eff6ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--erp-primary, #2563eb);
}

.print-option-section {
    display: flex;
    flex-direction: column;
}

.print-section-label {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 7px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 1. 프리셋 칩 */
.print-preset-chips-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.print-preset-chip {
    appearance: none;
    -webkit-appearance: none;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 5px 11px;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.16s ease;
    outline: none;
    line-height: 1.3;
}

.print-preset-chip:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #94a3b8;
    transform: translateY(-1px);
}

.print-preset-chip.active {
    background: var(--erp-primary, #2563eb) !important;
    color: #ffffff !important;
    border-color: var(--erp-primary, #2563eb) !important;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.28);
}

.print-title-input {
    font-size: 13.5px !important;
    letter-spacing: 0.8px;
    padding: 7px 12px !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

.print-title-input:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
}

/* 2. 금액 표시 모드 3분할 세그먼트 카드 */
.print-mode-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.print-mode-card {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 9px 10px;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.16s ease;
    user-select: none;
    margin: 0;
}

.print-mode-card:hover {
    border-color: #93c5fd;
    background: #f8fafc;
}

.print-mode-card:has(input:checked) {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 0 0 1px #2563eb;
}

.print-mode-card input[type="radio"] {
    margin-top: 2px;
    cursor: pointer;
    accent-color: #2563eb;
}

.print-mode-card-content {
    display: flex;
    flex-direction: column;
}

.print-mode-card-title {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.25;
}

.print-mode-card:has(input:checked) .print-mode-card-title {
    color: #1d4ed8;
}

.print-mode-card-desc {
    font-size: 10px;
    color: #64748b;
    margin-top: 3px;
    line-height: 1.25;
}

/* 3. 출력 세부 옵션 박스 */
.print-suboptions-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 11px 13px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.print-suboption-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    margin: 0;
    font-size: 12px;
    color: #1e293b;
    user-select: none;
}

.print-suboption-row input[type="checkbox"] {
    margin-top: 2px;
    cursor: pointer;
    accent-color: #2563eb;
}

.print-suboption-text {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px;
}

.print-suboption-text .sub-hint {
    font-size: 10.5px;
    color: #64748b;
    font-weight: 400;
}

.print-suboption-nested {
    margin-left: 24px;
    padding-left: 10px;
    border-left: 2px solid #cbd5e1;
    margin-top: -2px;
    margin-bottom: 2px;
    transition: all 0.2s ease;
}

.print-modal-footer {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 10px 18px !important;
}

