/* 베올리아 거래명세서 전용 스타일 */

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

body {
    font-family: 'Malgun Gothic', '맑은 고딕', sans-serif;
    background: #f5f5f5;
    padding: 20px;
}

/* 인쇄 설정 */
@page {
    size: A4 portrait !important;
    margin: 8mm 10mm;
}

@media print {
    body {
        background: white;
        padding: 0;
        margin: 0;
    }
    
    .no-print {
        display: none !important;
    }
    
    .report-document {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
        box-shadow: none;
        page-break-after: always;
        page-break-inside: avoid;
    }
    
    /* 인쇄 시 전체 크기 조정 */
    .report-title {
        font-size: 22pt !important;
        letter-spacing: 8px !important;
        margin-bottom: 5px !important;
    }
    
    .title-underline {
        margin: 2px 0 !important;
        height: 1.5px !important;
    }
    
    .title-section {
        margin-bottom: 15px !important;
    }
    
    .header-row {
        margin-bottom: 12px !important;
    }
    
    .date-row {
        font-size: 16pt !important;
        margin-top: 20px !important;
        margin-bottom: 8px !important;
    }
    
    .recipient-row,
    .confirmation-row {
        font-size: 16pt !important;
        margin-bottom: 5px !important;
    }
    
    .supplier-table td {
        padding: 3px 5px !important;
        font-size: 7.5pt !important;
    }
    
    .supplier-table .label {
        font-size: 7pt !important;
    }
    
    .supplier-table .sublabel {
        font-size: 7pt !important;
    }
    
    .total-amount-section {
        margin-bottom: 12px !important;
    }
    
    .amount-left,
    .amount-right {
        padding: 12px !important;
    }
    
    .amount-label {
        font-size: 13pt !important;
        letter-spacing: 4px !important;
        margin-bottom: 6px !important;
    }
    
    .amount-detail {
        font-size: 9pt !important;
    }
    
    .amount-korean {
        font-size: 14pt !important;
        margin-bottom: 10px !important;
    }
    
    .amount-box {
        font-size: 20pt !important;
    }
    
    .veolia-table {
        margin-bottom: 12px !important;
        border: 2px solid #2d3748 !important;
        border-collapse: separate !important;
        border-spacing: 0 !important;
    }
    
    .veolia-table th,
    .veolia-table td {
        padding: 2px !important;
        font-size: 8pt !important;
        height: 22px !important;
        border-right: 2px solid #2d3748 !important;
        border-bottom: 2px solid #2d3748 !important;
    }
    
    .veolia-table th:last-child,
    .veolia-table td:last-child {
        border-right: none !important;
    }
    
    .veolia-table tbody tr:last-child td {
        border-bottom: none !important;
    }
    
    .veolia-table thead th {
        font-size: 8.5pt !important;
        padding: 4px 3px !important;
        border-bottom: 2px solid #2d3748 !important;
    }
    
    .veolia-table tfoot td {
        border-bottom: none !important;
    }
    
    .total-row td {
        font-size: 12pt !important;
        padding: 7px !important;
        border-top: 2px solid #2d3748 !important;
        border-right: 2px solid #2d3748 !important;
        border-bottom: none !important;
    }
    
    .total-row td:last-child {
        border-right: none !important;
    }
    
    .total-label {
        font-size: 12pt !important;
        letter-spacing: 4px !important;
    }
    
    .total-value {
        font-size: 13pt !important;
        font-weight: bold !important;
    }
    
    .remarks-section {
        min-height: 45px !important;
        padding: 6px !important;
        margin-bottom: 0 !important;
    }
    
    .remarks-label {
        font-size: 9pt !important;
        margin-bottom: 4px !important;
    }
    
    .remarks-content {
        min-height: 30px !important;
    }
    
    /* 테이블이 페이지를 넘지 않도록 */
    .veolia-table {
        page-break-inside: avoid;
    }
    
    /* 흑백 인쇄 모드 */
    body.print-bw * {
        color: black !important;
        background: white !important;
        border-color: black !important;
    }
}

/* 헤더 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 1.5rem;
    color: #2d3748;
    font-weight: 600;
}

.nav-buttons, .control-buttons {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-refresh {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.btn-print {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.btn-add-row {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

.btn-delete-row {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
}

.btn-clear-all {
    background: linear-gradient(135deg, #ffa500 0%, #ff8c00 100%);
}

/* 설정 패널 */
.settings-panel {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.settings-panel h3 {
    font-size: 1.1rem;
    color: #2d3748;
    margin-bottom: 15px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.setting-item label {
    font-size: 0.9rem;
    color: #4a5568;
    font-weight: 500;
}

.setting-item select {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.setting-item select:focus {
    outline: none;
    border-color: #667eea;
}

/* 슬라이더 스타일 */
.setting-item input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #667eea 0%, #764ba2 100%);
    outline: none;
    -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.setting-item input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: none;
}

.setting-item span {
    display: inline-block;
    background: #edf2f7;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #2d3748;
    font-weight: 600;
    text-align: center;
    min-width: 50px;
}

/* 보고서 문서 */
.report-document {
    background: white;
    padding: 25px;
    max-width: 210mm;
    margin: 0 auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

@media print {
    .report-document {
        padding: 0;
        border-radius: 0;
    }
}

/* 보고서 헤더 */
.report-header {
    margin-bottom: 30px;
}

/* 제목 섹션 */
.title-section {
    text-align: center;
    margin-bottom: 20px;
}

.report-title {
    font-size: 24pt;
    font-weight: bold;
    letter-spacing: 10px;
    margin-bottom: 8px;
    color: #2d3748;
}

.title-underline {
    width: 100%;
    height: 2px;
    background: #2d3748;
    margin: 3px 0;
}

/* 헤더 행 (왼쪽: 날짜/수신자/확인, 오른쪽: 공급자) */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
}

.left-section {
    flex: 1;
    text-align: left;
}

.right-section {
    flex: 0 0 auto;
    margin-left: 25px;
}

/* 날짜, 수신자, 확인 행 */
.date-row {
    font-size: 16pt;
    margin-top: 25px;
    margin-bottom: 8px;
    color: #2d3748;
    font-weight: 500;
}

.recipient-row,
.confirmation-row {
    font-size: 16pt;
    margin-bottom: 6px;
    color: #2d3748;
}

.recipient-name {
    border-bottom: 2px solid #2d3748;
    padding-bottom: 2px;
}

.confirmation-text {
    border-bottom: 2px solid #2d3748;
    padding-bottom: 2px;
}

/* 공급자 박스 */
.supplier-box {
    border: 2px solid #2d3748;
}

.supplier-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 360px;
    max-width: 380px;
}

.supplier-table td {
    border: 1.5px solid #2d3748;
    padding: 4px 5px;
    font-size: 8pt;
}

.supplier-table .label {
    background: #f7fafc;
    font-weight: bold;
    text-align: center;
    width: 32px;
    vertical-align: middle;
    line-height: 1.2;
    font-size: 7.5pt;
}

.supplier-table .sublabel {
    background: #f7fafc;
    font-weight: 500;
    text-align: center;
    width: 55px;
    white-space: nowrap;
    font-size: 7.5pt;
}

.supplier-table .value {
    text-align: center;
    min-width: 65px;
    padding: 4px 5px;
    font-size: 8pt;
}

/* 편집 가능한 공급자 칸 */
.editable-supplier {
    cursor: text;
}

.editable-supplier:focus {
    outline: 2px solid #667eea;
    background: #f0f4ff;
}

.editable-supplier:hover {
    background: #f8f9fa;
}

/* 인쇄 시 편집 모드 효과 제거 */
@media print {
    .editable-supplier:focus {
        outline: none;
        background: transparent;
    }
    
    .editable-supplier:hover {
        background: transparent;
    }
    
    .supplier-table .label {
        background: #f7fafc !important;
    }
    
    .supplier-table .sublabel {
        background: #f7fafc !important;
    }
}

/* 합계 금액 섹션 */
.total-amount-section {
    border: 2px solid #2d3748;
    display: flex;
    margin-bottom: 18px;
}

.amount-left {
    flex: 0 0 30%;
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-right: 2px solid #2d3748;
}

.amount-divider {
    width: 2px;
    background: #2d3748;
}

.amount-right {
    flex: 1;
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.amount-label {
    font-size: 14pt;
    font-weight: bold;
    margin-bottom: 8px;
    letter-spacing: 4px;
    color: #2d3748;
}

.amount-detail {
    font-size: 10pt;
    color: #4a5568;
}

.amount-korean {
    font-size: 16pt;
    font-weight: bold;
    color: #e53e3e;
    margin-bottom: 12px;
}

.amount-box {
    font-size: 24pt;
    font-weight: bold;
    color: #2d3748;
}

.currency {
    margin-right: 10px;
}

/* 테이블 컨트롤 */
.table-controls {
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
}

/* 테이블 */
.veolia-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 18px;
    border: 2px solid #2d3748;
}

.veolia-table th,
.veolia-table td {
    border-right: 2px solid #2d3748;
    border-bottom: 2px solid #2d3748;
    padding: 5px;
    text-align: center;
    font-size: 9pt;
    height: 26px;
}

.veolia-table th:last-child,
.veolia-table td:last-child {
    border-right: none;
}

.veolia-table thead th {
    background: #edf2f7;
    font-weight: bold;
    color: #2d3748;
    letter-spacing: 1px;
    border-bottom: 2px solid #2d3748;
}

.veolia-table tbody tr:last-child td {
    border-bottom: none;
}

.veolia-table tbody td {
    color: #2d3748;
}

.veolia-table tfoot td {
    border-bottom: none;
    border-right: 2px solid #2d3748;
}

.veolia-table tfoot td:last-child {
    border-right: none;
}

/* 열 너비 */
.col-date { width: 12%; }
.col-item { width: 10%; }
.col-spec { width: 8%; }
.col-vehicle { width: 15%; }
.col-qty { width: 12%; }
.col-price { width: 15%; }
.col-amount { width: 18%; }

/* 합계 행 */
.total-row {
    background: #f7fafc;
    font-weight: bold;
}

.total-row td {
    border-top: 2px solid #2d3748;
    border-right: 2px solid #2d3748;
    border-bottom: none;
}

.total-row td:last-child {
    border-right: none;
}

.total-label {
    text-align: center !important;
    letter-spacing: 4px;
    font-size: 14pt;
    padding: 10px !important;
}

.total-value {
    color: #e53e3e;
    font-size: 15pt;
    font-weight: bold;
    text-align: center !important;
    padding: 10px !important;
}

/* 빈 행 스타일 */
.empty-row td {
    color: #e2e8f0;
    height: 26px;
}

/* 편집 가능한 셀 */
.veolia-table tbody td {
    position: relative;
}

.veolia-table tbody td input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 9pt;
    padding: 5px;
    font-family: 'Malgun Gothic', '맑은 고딕', sans-serif;
}

.veolia-table tbody td input:focus {
    outline: 2px solid #667eea;
    background: #f0f4ff;
}

/* 인쇄 시 input 테두리 제거 */
@media print {
    .veolia-table tbody td input {
        border: none;
        outline: none;
        background: transparent;
        padding: 3px !important;
        font-size: 8pt !important;
    }
}

/* 비고 섹션 */
.remarks-section {
    border: 2px solid #2d3748;
    min-height: 55px;
    padding: 8px;
}

.remarks-label {
    font-size: 10pt;
    font-weight: bold;
    margin-bottom: 5px;
    letter-spacing: 2px;
    color: #2d3748;
}

.remarks-content {
    min-height: 35px;
    color: #4a5568;
}

/* 반응형 디자인 */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
    }
    
    .report-document {
        padding: 20px;
    }
    
    .report-title {
        font-size: 20pt;
        letter-spacing: 6px;
    }
    
    .header-row {
        flex-direction: column;
    }
    
    .right-section {
        margin-left: 0;
        margin-top: 20px;
    }
    
    .amount-korean {
        font-size: 12pt;
    }
    
    .amount-box {
        font-size: 18pt;
    }
    
    .veolia-table th,
    .veolia-table td {
        padding: 4px;
        font-size: 8pt;
    }
}
