/**
 * 시리얼 쪽지 출력 스타일
 * 좌측: 디자이너/옵션, 우측: 미리보기. 인쇄 시 인쇄 전용 영역만 출력.
 */

/* ───── 레이아웃 ───── */
.sn-layout {
    display: grid;
    grid-template-columns: 440px 1fr;
    gap: 20px;
    align-items: start;
}

.sn-left {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sn-right {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@media (max-width: 1100px) {
    .sn-layout {
        grid-template-columns: 1fr;
    }
    .sn-right {
        position: static;
    }
}

/* ───── 공용 패널 ───── */
.sn-panel {
    padding: 18px;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.panel-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #4a5568;
}

.panel-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 8px;
}

.hint-text {
    font-size: 0.8rem;
    color: #888;
    margin: 4px 0 12px;
    line-height: 1.5;
}

.hint-text code {
    background: #eef0ff;
    padding: 1px 6px;
    border-radius: 4px;
    color: #5b6cf2;
    font-size: 0.85em;
}

/* ───── 폼 ───── */
.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 10px;
}

.row-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-label {
    font-size: 0.78rem;
    color: #666;
}

.num-input {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid #e3e6f0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

.num-input:focus {
    outline: none;
    border-color: #a8b5e0;
}

.summary-info {
    justify-content: flex-end;
}

.summary-line {
    font-size: 0.85rem;
    color: #5a6b8c;
}

/* 세그먼트 버튼 */
.seg-group {
    display: inline-flex;
    background: #f3f4fb;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.seg {
    background: transparent;
    border: none;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #5a6b8c;
    cursor: pointer;
    transition: all 0.15s;
}

.seg:hover {
    color: #4a5568;
}

.seg.active {
    background: white;
    color: #4a5568;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(80, 90, 130, 0.12);
}

/* ───── 디자이너 ───── */
.designer-stage {
    background: #f5f6fb;
    border-radius: 12px;
    padding: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 240px;
}

.designer-cell {
    position: relative;
    background: white;
    box-shadow: 0 4px 18px rgba(80, 90, 130, 0.18);
    border-radius: 6px;
    overflow: hidden;
    cursor: default;
}

.designer-cell-inner {
    position: absolute;
    inset: 0;
    border: 1px dotted #dfe3ee;
    pointer-events: none;
}

/* 레이어 */
.layer-node {
    position: absolute;
    box-sizing: border-box;
    user-select: none;
    cursor: move;
    border: 1px dashed transparent;
}

.layer-node.selected {
    border-color: #a18cd1;
    box-shadow: 0 0 0 2px rgba(161, 140, 209, 0.25);
}

.layer-node.text-layer {
    padding: 0;
    line-height: 1.25;
    overflow: hidden;
    word-break: break-word;
    white-space: pre-wrap;
}

.layer-node.image-layer {
    overflow: hidden;
}

.layer-node.image-layer img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    display: block;
}

.layer-resize {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 18px;
    height: 18px;
    background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M13 5 L5 13 M13 9 L9 13' stroke='%238c7ec7' stroke-width='1.6' stroke-linecap='round' fill='none'/></svg>") center/12px no-repeat;
    border: 1.5px solid #8c7ec7;
    border-radius: 4px;
    cursor: nwse-resize;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.layer-node:not(.selected) .layer-resize {
    display: none;
}

/* ───── 레이어 리스트 / 속성 ───── */
.layer-empty {
    text-align: center;
    color: #999;
    font-size: 0.85rem;
    padding: 20px 0;
}

.layer-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: #f5f6fb;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #5a6b8c;
    transition: background 0.15s;
}

.layer-item:hover {
    background: #ecedf6;
}

.layer-item.active {
    background: linear-gradient(135deg, #a8b5e0 0%, #c8a6d4 100%);
    color: white;
}

.layer-item .layer-icon {
    font-size: 0.95rem;
}

.layer-item .layer-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-item .layer-z {
    display: flex;
    gap: 2px;
}

.layer-item .z-btn {
    background: rgba(255, 255, 255, 0.5);
    border: none;
    border-radius: 4px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 0.7rem;
    color: #5a6b8c;
}

.layer-item.active .z-btn {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.layer-item .z-btn:hover {
    background: rgba(255, 255, 255, 0.85);
}

/* 속성 폼 */
.layer-props {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.advanced-toggle {
    align-self: flex-start;
    background: transparent;
    border: 1px dashed #c5cae9;
    color: #6b7aa8;
    padding: 5px 12px;
    font-size: 0.78rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.advanced-toggle:hover {
    background: #eef0fb;
    border-color: #a5add4;
}

.advanced-toggle .chev {
    display: inline-block;
    margin-left: 4px;
    transition: transform 0.2s;
}

.advanced-toggle.open .chev {
    transform: rotate(180deg);
}

.prop-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 10px;
    align-items: center;
}

.prop-row label {
    font-size: 0.82rem;
    color: #666;
}

.prop-row input[type="text"],
.prop-row input[type="number"],
.prop-row input[type="color"],
.prop-row select,
.prop-row textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1.5px solid #e3e6f0;
    border-radius: 8px;
    font-size: 0.88rem;
    font-family: inherit;
}

.prop-row input[type="color"] {
    padding: 2px;
    height: 36px;
    cursor: pointer;
}

.prop-row textarea {
    min-height: 80px;
    resize: vertical;
}

.prop-row input:focus,
.prop-row select:focus,
.prop-row textarea:focus {
    outline: none;
    border-color: #a8b5e0;
}

.prop-inline {
    display: flex;
    gap: 6px;
}

.prop-inline input {
    flex: 1;
}

.slider-inline {
    align-items: center;
    gap: 10px;
}

.slider-inline input[type="range"] {
    flex: 1;
    padding: 0;
    border: none;
    background: transparent;
    height: 22px;
    cursor: pointer;
}

.slider-val {
    min-width: 50px;
    text-align: right;
    font-size: 0.82rem;
    color: #5a6b8c;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.hidden-file {
    display: none;
}

/* ───── 표 데이터 패널 ───── */
.data-summary {
    font-size: 0.85rem;
    color: #5a6b8c;
    margin-bottom: 8px;
}

.data-summary strong {
    color: #4a5568;
}

.data-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.data-column-tag {
    background: linear-gradient(135deg, #fff1c4 0%, #fde8a0 100%);
    color: #7a5b00;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-family: 'Consolas', 'Monaco', monospace;
}

/* ───── 모달 ───── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(40, 50, 80, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal-card {
    background: white;
    border-radius: 14px;
    width: min(720px, 100%);
    max-height: calc(100vh - 60px);
    box-shadow: 0 20px 60px rgba(40, 50, 80, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eef0f8;
}

.modal-header h3 {
    flex: 1;
    color: #4a5568;
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1rem;
    color: #888;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.modal-close:hover {
    background: #f1f3fa;
    color: #4a5568;
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-body textarea {
    width: 100%;
    min-height: 140px;
    padding: 12px;
    border: 1.5px solid #e3e6f0;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
}

.modal-body textarea:focus {
    outline: none;
    border-color: #a8b5e0;
}

.table-preview-wrap {
    margin-top: 12px;
}

.table-preview-label {
    font-size: 0.78rem;
    color: #5a6b8c;
    margin-bottom: 6px;
}

.table-preview {
    max-height: 220px;
    overflow: auto;
    border: 1px solid #e3e6f0;
    border-radius: 8px;
    background: #f8f9fc;
}

.table-preview table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.82rem;
}

.table-preview th,
.table-preview td {
    border-right: 1px solid #e3e6f0;
    border-bottom: 1px solid #e3e6f0;
    padding: 6px 10px;
    text-align: left;
    white-space: nowrap;
}

.table-preview th {
    background: linear-gradient(135deg, #fff1c4 0%, #fde8a0 100%);
    color: #7a5b00;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.table-preview td {
    color: #4a5568;
}

.table-preview .preview-empty {
    padding: 18px;
    text-align: center;
    color: #999;
    font-size: 0.85rem;
}

.table-error {
    margin-top: 10px;
    padding: 8px 12px;
    background: #fdecea;
    color: #c0392b;
    border-radius: 6px;
    font-size: 0.82rem;
    display: none;
}

.table-error.show {
    display: block;
}

.modal-actions {
    padding: 14px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid #eef0f8;
    background: #fafbfe;
}

.modal-actions .btn {
    padding: 8px 18px;
}

/* ───── 요약 ───── */
.summary-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.9rem;
    color: #5a6b8c;
}

.summary-row strong {
    color: #4a5568;
    font-size: 1rem;
}

/* ───── 미리보기 ───── */
.preview-panel {
    padding: 18px;
}

.preview-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.preview-nav-btn {
    background: #f3f4fb;
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #5a6b8c;
    transition: all 0.15s;
}

.preview-nav-btn:hover {
    background: #e6e8f5;
}

.preview-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.preview-page-info {
    padding: 0 6px;
    font-size: 0.85rem;
    color: #5a6b8c;
    min-width: 56px;
    text-align: center;
}

.preview-stage {
    background: #f5f6fb;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 480px;
    overflow: auto;
}

.paper {
    position: relative;
    background: white;
    box-shadow: 0 8px 28px rgba(80, 90, 130, 0.22);
}

.paper-grid {
    position: absolute;
    inset: 0;
    display: grid;
}

.paper-cell {
    position: relative;
    overflow: hidden;
}

/* 절취선 옵션
 *   - none   : 표시 안 함
 *   - cross  : 격자 교차점의 십자 마크 SVG (.crop-marks)
 *   - dotted : 셀 사이의 점선 보더 (.cut-lines)
 */
.crop-marks {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

.paper-cell.cut-lines {
    border-right: 1px dotted #d6dbeb;
    border-bottom: 1px dotted #d6dbeb;
}
.paper-cell.cut-lines.no-r {
    border-right: none;
}
.paper-cell.cut-lines.no-b {
    border-bottom: none;
}

.cut-lines-field {
    margin-top: 6px;
}

.paper-cell-inner {
    position: absolute;
    inset: 0;
}

.paper-cell-inner .layer-node {
    cursor: default;
    border-color: transparent !important;
    box-shadow: none !important;
}

.paper-cell-inner .layer-resize {
    display: none !important;
}

/* ───── 인쇄 ───── */
.print-root {
    display: none;
}

@media print {
    @page {
        margin: 0;
    }
    html, body {
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    /* body 직계 자식 중 .container만 보이게 — BMC 위젯, 토스트, 홈/언어 버튼 등 일괄 차단 */
    body > *:not(.container) {
        display: none !important;
    }
    .container {
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .container > *:not(.print-root) {
        display: none !important;
    }
    .print-root {
        display: block !important;
    }
    .print-page {
        position: relative;
        page-break-after: always;
        background: white;
        overflow: hidden;
    }
    .print-page:last-child {
        page-break-after: auto;
    }
    .print-grid {
        position: absolute;
        inset: 0;
        display: grid;
    }
    .print-cell {
        position: relative;
        overflow: hidden;
    }
    .print-cell.cut-lines {
        border-right: 1px dotted #b5b5b5;
        border-bottom: 1px dotted #b5b5b5;
    }
    .print-cell.cut-lines.no-r {
        border-right: none;
    }
    .print-cell.cut-lines.no-b {
        border-bottom: none;
    }
    .print-cell .layer-node {
        border-color: transparent !important;
        box-shadow: none !important;
    }
}

/* 변환 버튼 위치 조정 */
.convert-section {
    margin-top: 4px;
    margin-bottom: 0;
}
