/* ── Designer shell ───────────────────────────────────────── */
.pf-designer {
    display: flex;
    height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    background: #1e1e2e;
    color: #cdd6f4;
    user-select: none;
}

/* ── Toolbox (left) ──────────────────────────────────────── */
.pf-toolbox {
    width: 200px;
    min-width: 200px;
    background: #181825;
    border-right: 1px solid #313244;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.pf-toolbox-section { padding: 8px 12px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #6c7086; }
.pf-toolbox-section-toggle {
    width: 100%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    text-align: left;
}
.pf-toolbox-section-toggle:hover {
    color: #cdd6f4;
}
.pf-toolbox-section-toggle span {
    width: 10px;
    color: #89b4fa;
}
.pf-toolbox-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 14px; cursor: pointer; border: none;
    background: transparent; color: #cdd6f4; width: 100%; text-align: left;
    border-radius: 4px; margin: 1px 6px; width: calc(100% - 12px);
    transition: background 0.15s;
}
.pf-toolbox-btn:hover { background: #313244; }
.pf-toolbox-btn .icon { font-size: 16px; width: 20px; text-align: center; }
.pf-toolbox-divider { border-top: 1px solid #313244; margin: 6px 0; }

/* Page size presets */
.pf-preset-btn {
    display: block; width: calc(100% - 12px); margin: 1px 6px;
    padding: 5px 14px; cursor: pointer; border: 1px solid #45475a;
    background: transparent; color: #bac2de; border-radius: 4px;
    font-size: 11px; text-align: left;
}
.pf-preset-btn:hover { background: #313244; border-color: #89b4fa; }
.pf-preset-btn.selected {
    background: #1e293b;
    border-color: #ffffff;
    color: #ffffff;
    box-shadow: inset 0 0 0 1px #89b4fa;
}

/* Toolbox input settings styling */
.pf-toolbox input, .pf-toolbox select {
    background: #313244; border: 1px solid #45475a; color: #cdd6f4;
    border-radius: 4px; padding: 4px 7px; font-size: 12px; width: 100%; box-sizing: border-box;
}
.pf-toolbox input:focus, .pf-toolbox select:focus {
    outline: none; border-color: #89b4fa;
}


/* ── Canvas area (center) ────────────────────────────────── */
.pf-canvas-area {
    flex: 1;
    overflow: auto;
    background: #313244;
    display: flex;
    flex-direction: column;
}
.pf-canvas-toolbar {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; background: #181825; border-bottom: 1px solid #313244;
    flex-wrap: wrap;
}
.pf-canvas-toolbar button {
    padding: 4px 12px; border: 1px solid #45475a; border-radius: 4px;
    background: #313244; color: #cdd6f4; cursor: pointer; font-size: 12px;
}
.pf-canvas-toolbar button:hover { background: #45475a; }
.pf-canvas-toolbar button.primary { background: #89b4fa; color: #1e1e2e; border-color: #89b4fa; font-weight: 600; }
.pf-canvas-toolbar button.primary:hover { background: #74c7ec; }
.pf-canvas-toolbar button.danger { background: #f38ba8; color: #1e1e2e; border-color: #f38ba8; }
.pf-canvas-toolbar select, .pf-canvas-toolbar input[type=range], .pf-canvas-toolbar input[type=text] {
    background: #313244; border: 1px solid #45475a; color: #cdd6f4;
    border-radius: 4px; padding: 3px 6px; font-size: 12px;
}
.pf-canvas-toolbar input[type=text]:focus {
    outline: none; border-color: #89b4fa;
}

.pf-canvas-scroll { flex:1; overflow:auto; display:flex; justify-content:flex-start; align-items:flex-start; padding: 32px; gap: 0; }
.pf-canvas-scroll-inner { display:flex; justify-content:flex-start; min-width:100%; min-height:100%; padding: 12px; }

/* ── Page / canvas ───────────────────────────────────────── */
.pf-page {
    position: relative;
    background: #ffffff;
    border: 1px solid #d7dce8;
    box-sizing: border-box;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
    flex-shrink: 0;
    overflow: hidden;
}
/* Handles on selected elements need to escape the page clip,
   so we lift them out via a sibling overlay trick — but for
   elements not at the very edge this is invisible. */
.pf-page > .pf-element.selected {
    overflow: visible;
}

/* ── Elements on canvas ──────────────────────────────────── */
.pf-element {
    position: absolute;
    box-sizing: border-box;
    cursor: move;
    border: 1px dashed transparent;
}
.pf-element:hover { border-color: #89b4fa80; }
.pf-element.selected { border-color: #89b4fa; border-style: solid; }

/* Resize handles */
.pf-handle {
    position: absolute; width: 8px; height: 8px;
    background: #89b4fa; border: 1px solid #1e1e2e;
    border-radius: 2px; z-index: 100;
}
.pf-handle.nw { top:-4px;  left:-4px;  cursor:nw-resize; }
.pf-handle.n  { top:-4px;  left:calc(50% - 4px); cursor:n-resize; }
.pf-handle.ne { top:-4px;  right:-4px; cursor:ne-resize; }
.pf-handle.w  { top:calc(50% - 4px); left:-4px; cursor:w-resize; }
.pf-handle.e  { top:calc(50% - 4px); right:-4px; cursor:e-resize; }
.pf-handle.sw { bottom:-4px; left:-4px;  cursor:sw-resize; }
.pf-handle.s  { bottom:-4px; left:calc(50% - 4px); cursor:s-resize; }
.pf-handle.se { bottom:-4px; right:-4px; cursor:se-resize; }

/* Element content rendering */
.pf-text-content { width:100%; height:100%; overflow:hidden; box-sizing:border-box; padding:1px; pointer-events:none; }
.pf-barcode-content, .pf-qrcode-content, .pf-image-content {
    width:100%; height:100%; display:flex; align-items:center; justify-content:center;
    pointer-events:none; overflow:hidden;
}
.pf-barcode-content { background: repeating-linear-gradient(90deg,#000 0,#000 2px,#fff 2px,#fff 4px); opacity:0.7; }
.pf-qrcode-content  { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Crect width='40' height='40' fill='white'/%3E%3Crect x='2' y='2' width='14' height='14' fill='none' stroke='black' stroke-width='2'/%3E%3Crect x='5' y='5' width='8' height='8' fill='black'/%3E%3Crect x='24' y='2' width='14' height='14' fill='none' stroke='black' stroke-width='2'/%3E%3Crect x='27' y='5' width='8' height='8' fill='black'/%3E%3Crect x='2' y='24' width='14' height='14' fill='none' stroke='black' stroke-width='2'/%3E%3Crect x='5' y='27' width='8' height='8' fill='black'/%3E%3C/svg%3E") center/contain no-repeat; }
.pf-table-content   { width:100%; height:100%; overflow:hidden; pointer-events:none; }
.pf-line-h { width:100%; height:0; border:none; border-top:1px solid #000; position:absolute; top:50%; }
.pf-line-v { height:100%; width:0; border:none; border-left:1px solid #000; position:absolute; left:50%; }
.pf-rect-content { width:100%; height:100%; box-sizing:border-box; }

/* ── Properties panel (right) ───────────────────────────── */
.pf-properties {
    width: 260px; min-width: 260px;
    background: #181825;
    border-left: 1px solid #313244;
    display: flex; flex-direction: column;
    overflow-y: auto;
}
.pf-prop-header {
    padding: 10px 14px; font-weight: 600; font-size: 12px;
    border-bottom: 1px solid #313244; background: #11111b;
    text-transform: uppercase; letter-spacing: 0.5px; color: #89b4fa;
}
.pf-prop-section { padding: 8px 14px 4px; font-size: 10px; text-transform: uppercase; color: #6c7086; letter-spacing: 1px; }
.pf-prop-row { padding: 4px 14px; display:flex; flex-direction:column; gap:2px; }
.pf-prop-row label { font-size: 11px; color: #a6adc8; }
.pf-prop-row input:not([type=checkbox]):not([type=range]), 
.pf-prop-row select, 
.pf-prop-row textarea,
.pf-prop-row-inline input:not([type=checkbox]):not([type=range]), 
.pf-prop-row-inline select, 
.pf-prop-row-inline textarea {
    background: #313244; border: 1px solid #45475a; color: #cdd6f4;
    border-radius: 4px; padding: 4px 7px; font-size: 12px; width: 100%; box-sizing: border-box;
}
.pf-prop-row input:not([type=checkbox]):not([type=range]):focus, 
.pf-prop-row select:focus, 
.pf-prop-row textarea:focus,
.pf-prop-row-inline input:not([type=checkbox]):not([type=range]):focus, 
.pf-prop-row-inline select:focus, 
.pf-prop-row-inline textarea:focus {
    outline: none; border-color: #89b4fa;
}
.pf-designer select option {
    background-color: #1e1e2e;
    color: #cdd6f4;
}
.pf-prop-row input[type=color], .pf-prop-row-inline input[type=color] {
    padding: 2px;
    height: 26px;
    cursor: pointer;
}

.pf-prop-row-inline { display:flex; gap:6px; padding: 4px 14px; }
.pf-prop-row-inline > * { flex:1; }
.pf-prop-row-inline label { font-size: 11px; color: #a6adc8; display:block; margin-bottom:2px; }
.pf-prop-checkbox { display:flex; align-items:center; gap:8px; padding:4px 14px; }
.pf-prop-checkbox input[type=checkbox] { accent-color: #89b4fa; width:14px; height:14px; }
.pf-prop-checkbox label { font-size:12px; }
.pf-prop-btn {
    margin: 6px 14px; padding: 6px; border: 1px solid #45475a;
    background: #313244; color: #cdd6f4; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.pf-prop-btn:hover { background: #45475a; }
.pf-prop-btn.danger { border-color:#f38ba8; color:#f38ba8; }
.pf-prop-btn.danger:hover { background:#f38ba8; color:#1e1e2e; }

/* Table column cards */
.pf-col-card { margin:4px 10px; background:#11111b; border:1px solid #313244; border-radius:5px; padding:6px 8px; display:flex; flex-direction:column; gap:4px; }
.pf-col-r1 { display:flex; gap:4px; align-items:center; }
.pf-col-input { flex:1; background:#313244; border:1px solid #45475a; color:#cdd6f4; border-radius:3px; padding:3px 6px; font-size:11px; min-width:0; }
.pf-col-input:focus { outline:none; border-color:#89b4fa; }
.pf-col-w { max-width:44px; flex:none; text-align:center; }
.pf-col-pad { max-width:34px; flex:none; text-align:center; }
.pf-col-del { background:transparent; border:1px solid #45475a; color:#f38ba8; border-radius:3px; padding:2px 6px; cursor:pointer; font-size:11px; flex-shrink:0; }
.pf-col-del:hover { background:#f38ba8; color:#1e1e2e; }
.pf-col-style-row { display:flex; align-items:center; gap:3px; flex-wrap:wrap; }
.pf-col-label { font-size:9px; text-transform:uppercase; color:#6c7086; letter-spacing:.5px; width:22px; flex-shrink:0; }
.pf-align-btn { width:20px; height:20px; display:flex; align-items:center; justify-content:center; background:#313244; border:1px solid #45475a; color:#a6adc8; border-radius:3px; cursor:pointer; font-size:10px; padding:0; }
.pf-align-btn:hover, .pf-align-btn.active { background:#89b4fa; border-color:#89b4fa; color:#1e1e2e; }
.pf-style-btn { width:20px; height:20px; display:flex; align-items:center; justify-content:center; background:#313244; border:1px solid #45475a; color:#a6adc8; border-radius:3px; cursor:pointer; font-size:11px; font-weight:bold; padding:0; }
.pf-style-btn.italic { font-style:italic; font-weight:normal; }
.pf-style-btn:hover, .pf-style-btn.active { background:#89b4fa; border-color:#89b4fa; color:#1e1e2e; }
.pf-col-add { margin:4px 10px; padding:5px 8px; background:transparent; border:1px dashed #45475a; color:#a6adc8; border-radius:4px; cursor:pointer; font-size:11px; width:calc(100% - 20px); }
.pf-col-add:hover { border-color:#89b4fa; color:#89b4fa; }

/* No-selection placeholder */
.pf-no-selection { padding:20px 14px; color:#6c7086; font-size:12px; text-align:center; }

/* ── Preview modal ───────────────────────────────────────── */
.pf-preview-overlay {
    position:fixed; inset:0; background:rgba(0,0,0,0.7); z-index:1000;
    display:flex; align-items:center; justify-content:center;
}
.pf-preview-modal {
    background:#1e1e2e; border:1px solid #45475a; border-radius:8px;
    padding:20px; max-width:90vw; max-height:90vh; display:flex; flex-direction:column; gap:12px;
}
.pf-preview-modal iframe { flex:1; border:none; background:#fff; border-radius:4px; }
.pf-preview-modal button { align-self:flex-end; padding:6px 16px; background:#89b4fa; color:#1e1e2e; border:none; border-radius:4px; cursor:pointer; font-weight:600; }

/* ── Sticky Rulers & Multi-page canvas ─────────────────────────── */
.pf-canvas-container {
    position: relative;
    background: #1e1e2e;
    box-shadow: 0 4px 24px rgba(0,0,0,0.25);
    border-radius: 4px;
    border: 1px solid #313244;
}
.pf-ruler-corner {
    border-top-left-radius: 4px;
}
.pf-ruler-horizontal {
    border-top-right-radius: 4px;
}
.pf-ruler-vertical {
    border-bottom-left-radius: 4px;
}
.pf-canvas-workspace {
    background: #313244;
}
.pf-page-break {
    position: absolute;
    left: 0;
    width: 100%;
    height: 0;
    border-top: 1.5px dashed #f38ba8;
    z-index: 50;
    pointer-events: none;
}
.pf-page-break-label {
    position: absolute;
    right: 12px;
    top: -9px;
    background: #f38ba8;
    color: #1e1e2e;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.pf-margin-guide {
    position: absolute;
    border: 1px dashed rgba(137, 180, 250, 0.35);
    pointer-events: none;
    z-index: 5;
}
.pf-margin-label {
    position: absolute;
    left: 6px;
    top: 4px;
    color: rgba(137, 180, 250, 0.4);
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.pf-add-page-btn {
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.pf-add-page-btn:hover {
    background: #313244 !important;
    border-color: #a6e3a1 !important;
    color: #a6e3a1 !important;
    transform: scale(1.02);
}
.pf-add-page-btn:active {
    transform: scale(0.98);
}
.pf-layer-btn {
    flex: 1;
    height: 26px;
    background: #313244;
    border: 1px solid #45475a;
    color: #cdd6f4;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: background 0.15s, border-color 0.15s;
}
.pf-layer-btn:hover {
    background: #45475a;
    border-color: #89b4fa;
}

.pf-marquee {
    border: 1px dashed #89b4fa;
    background: rgba(137, 180, 250, 0.15);
}

.pf-back-btn:hover {
    background: #45475a !important;
    border-color: #89b4fa !important;
    color: #ffffff !important;
}

/* Specificity overrides to defeat ERP app.css global input styles */
.pf-designer input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
.pf-designer select,
.pf-designer textarea {
    background-color: #313244 !important;
    border: 1px solid #45475a !important;
    color: #cdd6f4 !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    height: auto !important;
    line-height: normal !important;
}

.pf-designer input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):focus,
.pf-designer select:focus,
.pf-designer textarea:focus {
    border-color: #89b4fa !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(137, 180, 250, 0.2) !important;
}

/* Padding and width overrides to ensure compact fields in designer panels */
.pf-designer .pf-toolbox input,
.pf-designer .pf-toolbox select,
.pf-designer .pf-prop-row input,
.pf-designer .pf-prop-row select,
.pf-designer .pf-prop-row textarea,
.pf-designer .pf-prop-row-inline input,
.pf-designer .pf-prop-row-inline select,
.pf-designer .pf-prop-row-inline textarea {
    padding: 4px 7px !important;
    font-size: 12px !important;
}

.pf-designer .pf-canvas-toolbar input[type=text],
.pf-designer .pf-canvas-toolbar select {
    padding: 3px 6px !important;
    font-size: 12px !important;
    width: auto !important;
}

.pf-designer .pf-col-input {
    padding: 3px 6px !important;
    font-size: 11px !important;
}

