/* ========== DATASHEET LAYOUT EDITOR STYLES ========== */

/* Back Link */
.back-link {
    color: #E87722;
    text-decoration: none;
    font-weight: 600;
    padding: 8px 16px;
    border: 1px solid #E87722;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.back-link:hover {
    background: #E87722;
    color: #fff;
}

/* Editor Main Layout */
.editor-main {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    max-width: 100vw;
    margin: 16px auto;
    padding: 0 16px;
    min-height: calc(100vh - 160px);
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Controls Panel */
.editor-controls {
    background: #111;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 14px;
    overflow-y: auto;
    max-height: calc(100vh - 140px);
    position: sticky;
    top: 16px;
}

.editor-controls h2 {
    margin: 0 0 14px 0;
    font-size: 16px;
    color: #E87722;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

/* Control Sections */
.control-section {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.control-header {
    padding: 10px 12px;
    background: #222;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: background 0.2s;
    position: relative;
}

.control-header:hover {
    background: #2a2a2a;
}

/* Collapse indicator arrow */
.control-header::before {
    content: '▼';
    position: absolute;
    right: 12px;
    font-size: 8px;
    color: #666;
    transition: transform 0.3s ease;
}

.control-section.collapsed .control-header::before {
    transform: rotate(-90deg);
}

.control-section.collapsed .control-header {
    border-bottom: none;
}

/* Collapsible body animation */
.control-body {
    padding: 14px;
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.control-section.collapsed .control-body {
    max-height: 0;
    padding: 0 14px;
    opacity: 0;
}

/* Element reorder buttons */
.element-reorder-btns {
    display: flex;
    gap: 4px;
}

.element-reorder-btn {
    background: #333;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.element-reorder-btn:hover {
    background: #E87722;
    border-color: #E87722;
}

/* Missing field warning - red border for fields not found in Excel */
.field-missing {
    border-color: #ff4444 !important;
    background: rgba(255, 68, 68, 0.1) !important;
    box-shadow: 0 0 4px rgba(255, 68, 68, 0.5);
}

.field-missing::placeholder {
    color: #ff6666;
}

/* Lock button */
.element-lock-btn {
    background: #333;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.element-lock-btn:hover {
    background: #555;
}

.element-lock-btn.locked {
    background: #E87722;
    border-color: #E87722;
}

/* Disabled reorder buttons when locked */
.control-section.locked .element-reorder-btn {
    opacity: 0.3;
    pointer-events: none;
}

.element-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}

.element-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #E87722;
}

.control-body {
    padding: 14px;
}

.control-body.disabled {
    opacity: 0.4;
    pointer-events: none;
}

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

.control-row:last-child {
    margin-bottom: 0;
}

.control-row label {
    flex: 0 0 70px;
    font-size: 12px;
    color: #999;
}

.title-text-input {
    font-size: 11px !important;
    cursor: text;
    width: 100%;
}

/* Full width input for footer text etc */
.full-width-input {
    width: 100% !important;
    flex: 1 !important;
    font-size: 11px;
    padding: 8px 10px;
    background: #222;
    border: 1px solid #444;
    border-radius: 4px;
    color: #fff;
}

.control-row select,
.control-row input[type="text"],
.control-row input[type="number"] {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #222;
    color: #fff;
    font-size: 13px;
}

.control-row select:focus,
.control-row input:focus {
    outline: none;
    border-color: #E87722;
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 16px;
}

.radio-group label {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #ccc;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    accent-color: #E87722;
}

/* Value Editor */
.value-editor {
    margin-top: 12px;
    padding: 12px;
    background: #151515;
    border-radius: 8px;
    border: 1px dashed #444;
}

.value-editor.hidden {
    display: none;
}

.value-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #333;
}

.value-row:last-child {
    border-bottom: none;
}

.value-row span {
    font-size: 12px;
    color: #999;
}

.value-row input {
    width: 60px;
    padding: 4px 8px;
    text-align: right;
}

/* CLS Border Controls */
.border-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 6px;
    padding: 10px;
    background: #151515;
    border-radius: 6px;
    border: 1px solid #333;
}

/* Plus/Minus Size Controls */
.plusminus-control {
    display: flex;
    align-items: center;
    gap: 4px;
}

.plusminus-control input {
    width: 50px;
    padding: 4px 6px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #222;
    color: #fff;
    font-size: 12px;
    text-align: center;
}

.pm-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #666;
    border-radius: 4px;
    background: #333;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
}

.pm-btn:hover {
    background: #555;
    border-color: #f77f00;
}

.border-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.border-row label {
    flex: 0 0 50px;
    font-size: 11px;
    color: #999;
}

.border-row input {
    width: 50px;
    padding: 4px 6px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #222;
    color: #fff;
    font-size: 12px;
    text-align: center;
}

.border-row input:focus {
    outline: none;
    border-color: #E87722;
}

/* Parameters List for Pie Chart */
.params-list {
    background: #151515;
    border-radius: 6px;
    padding: 8px;
    margin-top: 8px;
    border: 1px solid #333;
}

.param-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    border-bottom: 1px solid #333;
}

.param-row:last-child {
    border-bottom: none;
}

.param-row .param-name {
    flex: 1;
    min-width: 80px;
    padding: 4px 6px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #222;
    color: #fff;
    font-size: 11px;
}

.param-row .param-minmax {
    width: 52px;
    padding: 4px 2px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #222;
    color: #999;
    font-size: 10px;
}

.param-row .param-value {
    width: 45px;
    padding: 4px 4px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #222;
    color: #fff;
    font-size: 11px;
    text-align: center;
}

.param-row input:focus,
.param-row select:focus {
    outline: none;
    border-color: #E87722;
}

.delete-param-btn {
    padding: 2px 6px;
    border: none;
    background: transparent;
    color: #ff6666;
    font-size: 12px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.delete-param-btn:hover {
    opacity: 1;
}

/* Excel Data Source Section */
.excel-source {
    border-left: 3px solid #4CAF50;
}

.excel-source select {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #222;
    color: #fff;
    font-size: 12px;
}

.btn-secondary {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #E87722;
    border-radius: 6px;
    background: transparent;
    color: #E87722;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #E87722;
    color: #fff;
}

/* Column Preview Panel */
.column-preview {
    background: #1a1a1a;
    border-radius: 6px;
    padding: 8px;
    margin-top: 8px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 11px;
    color: #aaa;
}

.badge {
    background: #E87722;
    color: #fff;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
}

.badge.warning {
    background: #ff6b6b;
}

.column-list {
    max-height: 200px;
    overflow-y: auto;
}

.column-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 6px;
    margin: 2px 0;
    background: #252525;
    border-radius: 4px;
    font-size: 11px;
}

.column-item .col-name {
    color: #ccc;
}

.column-item .col-value {
    color: #E87722;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* File name display */
.file-name-display {
    font-size: 11px;
    color: #aaa;
    padding: 4px 8px;
    background: #1a1a1a;
    border-radius: 4px;
    margin: 6px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Data Row (Excel data display in content areas) */
.data-row {
    display: flex;
    justify-content: space-between;
    padding: 2mm 3mm;
    border-bottom: 0.5px solid #ddd;
    font-size: 9px;
}

.data-row:last-child {
    border-bottom: none;
}

.data-label {
    color: #333;
    font-weight: 500;
}

.data-value {
    color: #333;
    text-align: right;
    max-width: 60%;
    word-wrap: break-word;
}

/* Upload Areas */
.upload-area {
    background: #1a1a1a;
    border: 2px dashed #444;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
    text-align: center;
}

.upload-preview {
    width: 80px;
    height: 80px;
    margin: 0 auto 10px auto;
    background: #222;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.upload-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.upload-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.upload-btn {
    display: inline-block;
    padding: 8px 14px;
    background: #E87722;
    color: #fff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.upload-btn:hover {
    background: #d66b1c;
}

/* Section List */
.section-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.section-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #222;
    border-radius: 6px;
    font-size: 12px;
    cursor: grab;
    transition: background 0.2s;
}

.section-item:hover {
    background: #2a2a2a;
}

.section-item input[type="checkbox"] {
    accent-color: #E87722;
}

.section-item.dragging {
    opacity: 0.5;
    background: #333;
}

/* Template Actions */
.template-actions h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #ccc;
}

.button-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.button-row button {
    flex: 1;
}

button.small {
    padding: 6px 10px;
    font-size: 11px;
}

/* Saved Templates List */
.saved-templates {
    margin-top: 12px;
    max-height: 150px;
    overflow-y: auto;
}

.saved-template-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #222;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 12px;
}

.saved-template-item:hover {
    background: #2a2a2a;
}

.saved-template-item .template-name {
    flex: 1;
    cursor: pointer;
    color: #ccc;
}

.saved-template-item .delete-btn {
    background: transparent;
    border: none;
    color: #c0392b;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
}

/* Preview Section */
.editor-preview {
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    max-width: calc(100vw - 340px);
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.preview-header h2 {
    margin: 0;
    font-size: 16px;
    color: #ccc;
}

.preview-actions {
    display: flex;
    gap: 8px;
}

/* Preview Canvas Wrapper */
.preview-canvas-wrapper {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    padding: 12px;
    background: #151515;
    border-radius: 6px;
}

/* Preview Canvas */
.preview-canvas {
    padding: 20px;
    overflow: auto;
}

/* 4-Page Grid Layout (2x2) */
.pages-container {
    display: grid;
    grid-template-columns: repeat(2, 105mm);
    grid-template-rows: repeat(2, 297mm);
    column-gap: 0;
    row-gap: 10mm;
    background: #333;
}

.datasheet-page {
    width: 105mm;
    height: 297mm;
    background: white;
    color: #000;
    padding: 3mm;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 9px;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid #ccc;
}

/* P1.1 - Pie Chart Panel (60mm = P2.1 + P2.2) */
.p1-chart-panel {
    width: 100%;
    height: auto;
    min-height: 50mm;
    background: white;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    box-sizing: border-box;
    padding: 2mm;
    margin: 0;
    /* border-bottom: 1px dashed #ccc; - Guide line hidden */
}

.p1-chart-panel canvas {
    max-width: 100%;
    max-height: 60mm;
}

/* Pie Chart with Labels Layout */
.pie-with-labels {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 3mm;
    padding: 2mm;
}

.pie-labels {
    display: flex;
    flex-direction: column;
    gap: 1mm;
    padding-top: 2mm;
}

.pie-label-row {
    /* font-size and font-weight are set dynamically by JS */
    color: #333;
    text-align: left;
    white-space: nowrap;
}

/* P1.1 - Ingredient Info Panel (auto height, shrinks to fit content) */
.p1-ingredient-panel {
    width: 100%;
    height: auto;
    min-height: 30mm;
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    /* border-bottom: 1px dashed #ccc; - Guide line hidden */
}

.p1-ingredient-panel .ingredient-header {
    width: 100%;
    background: #000;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 3mm;
    box-sizing: border-box;
}

.p1-ingredient-panel .ingredient-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9px;
}

.p1-ingredient-panel .ingredient-table tr {
    border-bottom: 1px solid #ddd;
}

.p1-ingredient-panel .ingredient-table tr:last-child {
    border-bottom: none;
}

.p1-ingredient-panel .ingredient-table td {
    padding: 1mm 3mm;
}

.p1-ingredient-panel .ingredient-table td.label {
    width: 50%;
    color: #333;
}

.p1-ingredient-panel .ingredient-table td.value {
    width: 50%;
    text-align: right;
    color: #000;
    font-weight: 500;
}

/* P1.3 - Content Area (fills remaining space using flex) */
.p1-content-area {
    width: 100%;
    flex: 1;
    min-height: 100mm;
    background: white;
    padding: 3mm;
    padding-bottom: 20mm;
    /* 15mm footer + 3mm buffer */
    overflow: hidden;
    box-sizing: border-box;
}

/* Page 1 specific layout */
#page1 {
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* P2.1 - Fixed Image Panel at top of Page 2 */
.p2-image-panel {
    width: 100%;
    height: 50mm;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    /* border-bottom: 1px dashed #ccc; - Guide line hidden */
}

.p2-image-panel img {
    width: 105mm;
    height: auto;
    max-height: 50mm;
    object-fit: contain;
    background: white;
    border: none;
    display: block;
}

/* P2.2 - Heading Strip (20mm height) */
.p2-heading-strip {
    width: 100%;
    height: 10mm;
    background: #fff;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-sizing: border-box;
    padding: 0 3mm;
    /* border-bottom: 1px dashed #ccc; - Guide line hidden */
}

/* P2.3 - Content Area (remaining space after image + heading) */
.p2-content-area {
    width: 100%;
    height: calc(297mm - 50mm - 10mm - 6mm);
    background: white;
    padding: 3mm;
    padding-bottom: 20mm;
    /* 15mm footer + 3mm buffer */
    overflow: hidden;
    box-sizing: border-box;
}

/* Page Footer Overlay (15mm) - Full A4 width, spans both page columns */
.a4-footer-overlay {
    position: absolute;
    left: 0;
    width: 210mm;
    /* Full A4 width */
    height: 15mm;
    background: #ffffff;
    /* White background */
    color: #000000;
    /* Black text */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 400;
    letter-spacing: 0.3px;
    text-align: center;
    box-sizing: border-box;
    padding: 0 5mm;
    z-index: 100;
    /* Above all page content */
    border-top: 0.5px solid #ccc;
    /* Subtle separator line */
}

/* Footer Row 1 - Bottom of pages 1+2 */
.a4-footer-row1 {
    top: 282mm;
    /* 297mm - 15mm */
}

/* Footer Row 2 - Bottom of pages 3+4 */
.a4-footer-row2 {
    top: 589mm;
    /* 297mm + 10mm gap + 297mm - 15mm */
}

.a4-footer-overlay .footer-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Make pages-container position relative for footer overlay */
.pages-container {
    position: relative;
}

/* P3/P4 Content Areas */
.p3-content-area,
.p4-content-area {
    width: 100%;
    height: calc(297mm - 15mm);
    /* Full height minus footer */
    background: white;
    padding: 3mm;
    padding-bottom: 20mm;
    /* 15mm footer + 3mm buffer */
    overflow: hidden;
    box-sizing: border-box;
}

/* Overflow content area for dynamic pages (p5, p6, etc.) */
.overflow-content-area {
    width: 100%;
    height: calc(297mm - 15mm);
    background: white;
    padding: 3mm;
    padding-bottom: 20mm;
    /* 15mm footer + 3mm buffer */
    overflow: hidden;
    box-sizing: border-box;
}

/* Page 2 specific layout - no padding to allow P2.1 full width */
#page2 {
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Locked elements at page tops */
.locked-element {
    width: 100%;
    margin-bottom: 3mm;
    text-align: center;
}

.page-chart {
    width: 100%;
    max-width: 45mm;
    height: auto;
}

.locked-image img {
    width: 100%;
    height: auto;
    max-height: 60mm;
    object-fit: contain;
}

/* Black strip section headings */
.section-heading {
    background: #000;
    color: #fff;
    padding: 2mm 3mm;
    font-weight: bold;
    font-size: 8px;
    margin-bottom: 1mm;
}

.section-data {
    padding: 1mm 0;
    font-size: 8px;
    line-height: 1.4;
}

/* Legacy a4-page class - kept for backwards compatibility */
.a4-page {
    width: 105mm;
    min-height: 297mm;
    background: white;
    color: #000;
    padding: 5mm;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 9px;
    position: relative;
    box-sizing: border-box;
}

/* A4 Page Elements */
.a4-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: flex-start;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.a4-header:empty {
    display: none;
}

.a4-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.a4-logo {
    object-fit: contain;
}

.a4-logo.small {
    width: 40px;
}

.a4-logo.medium {
    width: 60px;
}

.a4-logo.large {
    width: 80px;
}

.a4-title {
    font-size: 16px;
    font-weight: bold;
    margin: 0;
}

.a4-subtitle {
    font-size: 12px;
    color: #555;
    margin: 4px 0 0 0;
}

.a4-header-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.a4-stacked-element {
    width: 100%;
    text-align: right;
}

.a4-product-img {
    max-width: 100px;
    max-height: 80px;
    object-fit: contain;
}

.a4-product-img.small {
    max-width: 60px;
    max-height: 60px;
}

.a4-product-img.medium {
    max-width: 100px;
    max-height: 100px;
}

.a4-product-img.large {
    max-width: 140px;
    max-height: 140px;
}

.a4-product-img.xlarge {
    max-width: 180px;
    max-height: 180px;
}

.a4-product-img.xxxl {
    width: 100%;
    max-width: 100%;
    max-height: none;
    height: auto;
}

.a4-logo.xlarge {
    width: 100px;
}

/* Title Sizes */
.a4-title.small {
    font-size: 12px;
}

.a4-title.medium {
    font-size: 16px;
}

.a4-title.large {
    font-size: 20px;
}

/* Title Section (in data grid) */
.a4-title-section {
    margin-bottom: 8px;
}

/* Product Image Section (in data grid) */
.a4-product-image-section {
    margin-bottom: 10px;
    text-align: center;
}

.a4-title-section .a4-section-title {
    font-weight: bold;
    text-transform: uppercase;
    padding: 4px 0;
}

.a4-title-section.small .a4-section-title {
    font-size: 12px;
}

.a4-title-section.medium .a4-section-title {
    font-size: 16px;
}

.a4-title-section.large .a4-section-title {
    font-size: 20px;
}

/* Title Bar (for top-center position) */
.a4-title-bar {
    text-align: center;
    padding: 8px 0;
    border-bottom: 2px solid #000;
    margin-bottom: 10px;
}


/* Absolute Top Right - Product image at very top right with nothing above */
.a4-top-right-absolute {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
}

/* Above Title Image */
.a4-above-title-image {
    text-align: center;
    margin-bottom: 10px;
}

/* Header Center */
.a4-header-center {
    flex: 1;
    text-align: center;
}

/* Section Reorder Buttons */
.section-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #222;
    border-radius: 6px;
    font-size: 12px;
    transition: background 0.2s;
}

.section-item .section-label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-item .reorder-btns {
    display: flex;
    gap: 2px;
}

.section-item .reorder-btn {
    background: #333;
    border: none;
    color: #999;
    padding: 2px 5px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.2s;
}

.section-item .reorder-btn:hover {
    background: #E87722;
    color: #fff;
}

/* Pie Chart Toggle */
.pie-toggle {
    margin-left: auto;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #444;
    border: 1px solid #666;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.pie-toggle:hover {
    background: #555;
    border-color: #E87722;
}

.pie-toggle:has(input:checked) {
    background: #E87722;
    border-color: #E87722;
    color: #fff;
}

.pie-toggle input {
    display: none;
}

/* Content Grid */
.a4-content {
    display: grid;
    gap: 15px;
}

.a4-content.cols-1 {
    grid-template-columns: 1fr;
}

.a4-content.cols-2 {
    grid-template-columns: 1fr 1fr;
}

/* Chart Area */
.a4-chart-area {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.a4-chart-img {
    object-fit: contain;
}

.a4-chart-img.small {
    width: 80px;
    height: 80px;
}

.a4-chart-img.medium {
    width: 120px;
    height: 120px;
}

.a4-chart-img.large {
    width: 160px;
    height: 160px;
}

/* Data Sections */
.a4-section {
    margin-bottom: 10px;
}

.a4-section-header {
    background: #000;
    color: #fff;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.a4-section-content {
    font-size: 10px;
    line-height: 1.4;
}

.a4-data-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 0.5px solid #ddd;
}

.a4-data-key {
    color: #333;
}

.a4-data-val {
    font-weight: 500;
    text-align: right;
}

/* Footer */
.a4-footer {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 8px;
    color: #666;
    border-top: 1px solid #ccc;
    padding-top: 8px;
    margin-top: 15px;
}

.a4-footer-content {
    font-size: 8px;
    color: #666;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 1200px) {
    .editor-main {
        grid-template-columns: 280px 1fr;
    }
}

@media (max-width: 900px) {
    .editor-main {
        grid-template-columns: 1fr;
    }

    .editor-controls {
        position: static;
        max-height: none;
    }

    .preview-canvas-wrapper {
        min-height: 500px;
    }

    .a4-page {
        transform: scale(0.5);
        transform-origin: top center;
    }
}

/* ========== STRIP-BASED LAYOUT SYSTEM ========== */
/* Horizontal strips that stack vertically for easy reordering */

.a4-strips-container {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.a4-strip {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ccc;
    padding: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 5px;
    background: rgba(0, 0, 0, 0.02);
}

.a4-strip:last-child {
    border-bottom: none;
}

/* Strip heights */
.a4-strip.height-small {
    min-height: 30mm;
}

.a4-strip.height-medium {
    min-height: 55mm;
}

.a4-strip.height-large {
    min-height: 80mm;
}

.a4-strip.height-auto {
    min-height: auto;
}

/* Strip content alignment */
.a4-strip.align-left {
    justify-content: flex-start;
}

.a4-strip.align-center {
    justify-content: center;
}

.a4-strip.align-right {
    justify-content: flex-end;
}

/* Strip element types */
.a4-strip-title {
    width: 100%;
    text-align: center;
}

.a4-strip-image {
    max-width: 100%;
}

.a4-strip-chart {
    display: flex;
    justify-content: center;
}

.a4-strip-data {
    width: 100%;
}

/* Visual indicator for strip reordering */
.a4-strip.dragging {
    opacity: 0.5;
    background: #f0f0f0;
}

.a4-strip.drop-target {
    border-top: 3px solid #E87722;
}