* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0;
    gap: 0;
    background-color: #f0f0f0;
    overflow: auto;
}

/* Menubar Styles */
.menubar {
    display: flex;
    background-color: #333;
    color: white;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    z-index: 1000;
}

.menu-item {
    position: relative;
    display: inline-block;
}

.menu-label {
    display: block;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.menu-label:hover {
    background-color: #555;
}

.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    color: black;
    min-width: 180px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border: 1px solid #ddd;
    z-index: 1001;
}

.menu-item:hover .dropdown {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #eee;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: #f0f0f0;
}

.dropdown-item i {
    width: 16px;
    text-align: center;
    color: #666;
}

.dropdown-separator {
    height: 1px;
    background-color: #ddd;
    margin: 4px 0;
}

/* Toolbar Styles */
.toolbar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #ddd;
    min-height: 48px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    gap: 8px;
}

.toolbar-icon-button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    color: #333;
    font-size: 14px;
    transition: all 0.2s ease;
}

.toolbar-icon-button:hover {
    background-color: #e8e8e8;
    border-color: #999;
}

.toolbar-icon-button:active {
    background-color: #d0d0d0;
}

.toolbar-icon-button:disabled {
    background-color: #f5f5f5;
    color: #ccc;
    border-color: #e0e0e0;
    cursor: not-allowed;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background-color: #ccc;
    margin: 0 4px;
}

/* Legacy button styles for voucher panel */
.toolbar-button {
    padding: 8px 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.toolbar-button:hover {
    background-color: #45a049;
}

.toolbar-button:disabled {
    background-color: #ccc;
    color: #666;
    cursor: not-allowed;
    opacity: 0.6;
}

.toolbar-button:disabled:hover {
    background-color: #ccc;
}

.radio-group {
    display: flex;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    margin: 0;
}

.checkbox-group {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
}

.position-inputs {
    background-color: #fff;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    margin-top: 4px;
}

.qr-position-inputs {
    background-color: #f0f8ff;
    border-color: #4CAF50;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.input-row:last-child {
    margin-bottom: 0;
}

.input-row label {
    font-size: 12px;
    color: #666;
    min-width: 50px;
}

.input-row input[type="number"] {
    width: 60px;
    padding: 2px 4px;
    border: 1px solid #ccc;
    border-radius: 2px;
    font-size: 12px;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-group label {
    font-size: 13px;
    color: #666;
}

.input-group input[type="number"] {
    width: 80px;
    padding: 4px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
}

.editor-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#pdfViewer {
    position: relative;
    background-color: white;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.pdf-container {
    position: relative;
    background-color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    border: 1px solid #ddd;
}

#pdfLayer {
    position: relative;
    z-index: 1;
}

#pdfLayer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 48%, rgba(255, 0, 0, 0.1) 49%, rgba(255, 0, 0, 0.1) 51%, transparent 52%);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: auto;
}

#pdfLayer canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Side Panel Styles */
.side-panel {
    width: 300px;
    background-color: #f9f9f9;
    border-left: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

.panel-section {
    border-bottom: 1px solid #ddd;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    background-color: #f0f0f0;
    border-bottom: 1px solid #ddd;
    user-select: none;
    transition: background-color 0.2s ease;
}

.panel-header:hover {
    background-color: #e8e8e8;
}

.panel-label {
    font-weight: bold;
    font-size: 14px;
    color: #333;
}

.toggle-icon {
    font-size: 12px;
    color: #666;
    transition: transform 0.3s ease;
}

.panel-section.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.panel-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 600px;
    overflow-y: auto;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.panel-section.collapsed .panel-content {
    max-height: 0;
    padding: 0 16px;
    overflow: hidden;
}

/* Properties Panel Specific Styles */
.property-group {
    background-color: white;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 8px;
}

.property-group h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: bold;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

.property {
    margin-bottom: 8px;
}

.property label {
    display: block;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 4px;
    color: #555;
}

.property input[type="number"],
.property input[type="text"],
.property input[type="color"],
.property select {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 12px;
    background-color: white;
}

.property input[type="checkbox"] {
    margin-right: 6px;
}

.property input[readonly],
.property input[disabled] {
    background-color: #f0f0f0;
    color: #666;
    cursor: not-allowed;
}

.property input[type="color"] {
    height: 30px;
    padding: 2px;
}

.property select {
    height: 24px;
    padding: 2px;
    cursor: pointer;
}

.property input:focus,
.property select:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 3px rgba(76, 175, 80, 0.3);
}

.element {
    position: absolute;
    border: 2px solid transparent;
    cursor: move;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    min-width: 20mm;
    min-height: 1em;
    z-index: 3;
    background-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
}

.element.selected {
    border-color: #4CAF50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

.element.dragging {
    opacity: 0.8;
    cursor: grabbing;
}

/* Visual indicator when element reaches the PDF boundary */
.element.dragging:after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px dashed #ff9800;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.element.dragging[style*="0mm"], 
.element.dragging[style*="-"] {
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
}

.element.dragging[style*="0mm"]:after, 
.element.dragging[style*="-"]:after {
    opacity: 1;
}

.element.resizing {
    opacity: 0.9;
    outline: 2px dashed #4CAF50;
    background-color: rgba(255, 255, 255, 0.5);
    transition: none;
}

/* Style for when element position is reset */
.element.position-reset {
    animation: flash-warning 0.5s ease-in-out;
    border: 2px solid #ff5722;
    box-shadow: 0 0 15px rgba(255, 87, 34, 0.6);
}

@keyframes flash-warning {
    0% { opacity: 0.7; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

/* Aspect ratio lock indicator */
.element .aspect-ratio-lock {
    position: absolute;
    top: -25px;
    right: 0;
    width: 20px;
    height: 20px;
    background-color: #4CAF50;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    opacity: 0.8;
}

.element .aspect-ratio-lock:hover {
    opacity: 1;
}

.element .aspect-ratio-lock.locked::after {
    content: '🔒';
}

.element .aspect-ratio-lock.unlocked::after {
    content: '🔓';
}

/* Hide aspect ratio lock when not selected */
.element:not(.selected) .aspect-ratio-lock {
    display: none;
}

/* Resize handles */
.element .resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #4CAF50;
    border-radius: 50%;
    z-index: 1;
}

.element .resize-handle.nw { top: 0; left: 0; cursor: nw-resize; }
.element .resize-handle.ne { top: 0; right: 0; cursor: ne-resize; }
.element .resize-handle.sw { bottom: 0; left: 0; cursor: sw-resize; }
.element .resize-handle.se { bottom: 0; right: 0; cursor: se-resize; }
.element .resize-handle.n { top: 0; left: 50%; cursor: n-resize; }
.element .resize-handle.s { bottom: 0; left: 50%; cursor: s-resize; }
.element .resize-handle.e { right: 0; top: 50%; cursor: e-resize; }
.element .resize-handle.w { left: 0; top: 50%; cursor: w-resize; }

/* Hide resize handles when not selected */
.element:not(.selected) .resize-handle {
    display: none;
}

.text-element {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.5);
}

.text-element .text-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    word-break: break-word;
    overflow: hidden;
    transition: all 0.1s ease;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    background-color: transparent;
}

.text-element.selected {
    border-color: #4CAF50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.text-element.resizing {
    border-color: #FF9800;
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
}

.text-element.selected .text-content {
    border: 1px dashed rgba(76, 175, 80, 0.5);
    background-color: rgba(255, 255, 255, 0.5);
}

.text-element.resizing .text-content {
    pointer-events: none;
    border: 1px dashed rgba(255, 152, 0, 0.5);
    background-color: rgba(255, 255, 255, 0.5);
}

.image-element {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-element img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.qrcode-element {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.qrcode-element canvas {
    max-width: 100%;
    max-height: 100%;
}

/* Alignment indicators */
.text-element .alignment-indicator {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: rgba(76, 175, 80, 0.7);
    border-radius: 4px;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
}

.text-element.selected .alignment-indicator {
    display: flex;
}

.text-element .alignment-indicator.horizontal {
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
}

.text-element .alignment-indicator.vertical {
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
}

/* Checkbox styling */
.property input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    vertical-align: middle;
}

.property label.checkbox-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

/* JSON input styling */
.property input[type="text"].json-input {
    font-family: monospace;
    font-size: 12px;
    min-height: 60px;
    resize: vertical;
}

.resize-handles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: #4CAF50;
    border: 2px solid white;
    border-radius: 50%;
    z-index: 10;
    pointer-events: auto;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease, background-color 0.2s ease;
}

.resize-handle:hover {
    transform: scale(1.2);
    background-color: #45a049;
}

.resize-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.resize-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.resize-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.resize-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }
.resize-handle.n { top: -6px; left: 50%; margin-left: -6px; cursor: n-resize; }
.resize-handle.s { bottom: -6px; left: 50%; margin-left: -6px; cursor: s-resize; }
.resize-handle.e { right: -6px; top: 50%; margin-top: -6px; cursor: e-resize; }
.resize-handle.w { left: -6px; top: 50%; margin-top: -6px; cursor: w-resize; }

.element:not(.selected) .resize-handle {
    display: none;
}

.element.resizing {
    opacity: 0.9;
    outline: 2px dashed #4CAF50;
    background-color: rgba(255, 255, 255, 0.5);
    transition: none;
}

/* Group element styles */
.group-element {
    border: 2px dashed #007bff !important;
    background-color: rgba(0, 123, 255, 0.1) !important;
    box-sizing: border-box;
}

.group-element.selected {
    border-color: #0056b3 !important;
    background-color: rgba(0, 123, 255, 0.2) !important;
}

.group-label {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 10px;
    color: #007bff;
    font-weight: bold;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.8);
    padding: 1px 4px;
    border-radius: 2px;
} 