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

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background-color: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.container {
    height: 100vh;
    display: grid;
    grid-template-areas:
        "header header header"
        "sidebar main main";
    grid-template-rows: auto 1fr;
    grid-template-columns: 300px 1fr 1fr;
    gap: 20px;
    padding: 20px;
    overflow: hidden;
    position: relative;
}

header {
    grid-area: header;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

h1 {
    color: #333;
    margin: 0;
}

.controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

input[type="file"],
select,
button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
}

button {
    background-color: #4CAF50;
    color: white;
    border: none;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #45a049;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.scale-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.main-content {
    grid-area: main;
    position: relative;
    overflow: auto;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#pdfContainer {
    grid-area: main; /* Assign to the 'main' grid area */
    position: relative;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background-color: #f5f5f5;
    padding: 20px;
    z-index: 2;
}

.pdf-page {
    position: relative;
    margin: 0 auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background-color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    padding: 20px;
    z-index: 3;
    min-height: 100px;
    overflow: visible;
}

canvas {
    display: block;
    margin: 0 auto;
    cursor: move;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background-color: white;
    position: relative;
    z-index: 4;
    max-width: 100%;
    height: auto;
}

.objects-menu {
    grid-area: sidebar;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    height: calc(100vh - 100px);
    overflow-y: auto;
    position: sticky;
    left: 0;
    top: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.objects-menu h3 {
    margin: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    color: #333;
    font-size: 18px;
}

.object-actions {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
}

.object-actions button {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background-color: #0066cc;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.object-actions button:hover {
    background-color: #0052a3;
}

.object-actions input[type="file"] {
    display: none;
}

.objects-list {
    position: relative;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    min-height: 200px;
    flex: 1;
    overflow: visible;
}

.object-item {
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    position: relative;
    z-index: 2;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.object-item:hover {
    border-color: #0066cc;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.object-item.selected {
    border-color: #0066cc;
    background-color: #f0f7ff;
}

.object-item .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.object-item .type {
    font-weight: 600;
    color: #333;
    text-transform: capitalize;
}

.object-item .page {
    font-size: 12px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
}

.object-item .object-id {
    font-size: 12px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
}

.object-item .text-content {
    flex: 1;
    margin-left: 10px;
    color: #666;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.properties-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 8px;
    user-select: none;
}

.properties-header:hover {
    background: #e9ecef;
}

.expand-icon {
    font-size: 12px;
    color: #666;
}

.property-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
}

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

.property label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.property input[type="number"] {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    width: 100%;
}

.property input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
}

.property input[type="color"] {
    width: 100%;
    height: 24px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.object-item .properties {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.object-item .property {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.object-item .property input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

.object-item .property input:focus {
    border-color: #0066cc;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,102,204,0.1);
}

.object-item .actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.object-item button {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    background-color: #0066cc;
    color: white;
    cursor: pointer;
    font-size: 12px;
}

.object-item button:hover {
    background-color: #0052a3;
}

.object-item .link-badge {
    position: absolute;
    right: 10px;
    top: 10px;
    background: #0066cc;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    z-index: 3;
}

.connection-menu {
    position: fixed;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
}

.connection-menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    background-color: #f8f9fa;
    margin-bottom: 4px;
    transition: background-color 0.2s ease;
}

.connection-menu-item:hover {
    background-color: #e9ecef;
}

.connection-menu-item button {
    padding: 4px 8px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.connection-menu-item button:hover {
    background: #c82333;
}

.link-badge {
    background-color: #0066cc;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin: 0 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    user-select: none;
}

.link-badge:hover {
    background-color: #0052a3;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.link-badge:active {
    transform: translateY(0);
    box-shadow: none;
}

.connection-lines-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.edit-panel {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    min-width: 300px;
}

.edit-panel h3 {
    margin-bottom: 15px;
    color: #333;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-control:focus {
    border-color: #4a90e2;
    outline: none;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #4a90e2;
    color: white;
}

.btn-primary:hover {
    background-color: #357abd;
}

.btn-secondary {
    background-color: #f0f0f0;
    color: #333;
}

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 30px;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    vertical-align: middle;
}

input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.context-menu {
    position: fixed;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 1000;
    min-width: 150px;
}

.context-menu-item {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.context-menu-item:hover {
    background-color: #f5f5f5;
}

.context-menu-separator {
    height: 1px;
    background-color: #ddd;
    margin: 4px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        grid-template-areas:
            "header"
            "main"
            "sidebar";
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: auto;
        min-height: 100vh;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .scale-controls {
        margin-left: 0;
        justify-content: center;
    }

    .main-content {
        height: auto;
        min-height: 300px;
    }

    .objects-menu {
        height: auto;
        max-height: 300px;
    }
}

/* Remove the problematic pseudo-elements */
.pdf-page::before,
canvas::after {
    display: none;
}

/* Fix for IE specific issues */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    .pdf-page {
        transform: translateZ(0);
    }
    
    canvas {
        transform: translateZ(0);
    }
    
    #pdfContainer {
        transform: translateZ(0);
    }
}

.property.full-width {
    grid-column: 1 / -1;
}

.property input[type="text"] {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    width: 100%;
}

.property select {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    width: 100%;
    background-color: white;
    cursor: pointer;
}

.property select:hover {
    border-color: #0066cc;
}

.property select:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0,102,204,0.1);
}

.property .text-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
    background-color: white;
    margin-top: 4px;
}

.property .text-input:focus {
    border-color: #0066cc;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,102,204,0.1);
}

.property .text-input:hover {
    border-color: #0066cc;
}

.text-input-container {
    margin: 8px 0;
    padding: 0 8px;
}

.text-input-container .text-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
    background-color: white;
}

.text-input-container .text-input:focus {
    border-color: #0066cc;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,102,204,0.1);
}

.text-input-container .text-input:hover {
    border-color: #0066cc;
}

.object-item .title {
    flex: 1;
    margin-left: 10px;
    color: #333;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.property .property-value {
    padding: 6px 8px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    color: #666;
    min-height: 32px;
    display: flex;
    align-items: center;
}

.property-group:last-child {
    margin-bottom: 0;
}

.title-input-container {
    margin: 8px 0;
    padding: 0 8px;
}

.title-input-container .title-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
    background-color: white;
}

.title-input-container .title-input:focus {
    border-color: #0066cc;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,102,204,0.1);
}

.title-input-container .title-input:hover {
    border-color: #0066cc;
}

.title-input-container .title-input::placeholder {
    color: #999;
    font-style: italic;
}

/* Enhanced Predefined Values Panel */
.form-section {
    margin-bottom: 25px;
    padding: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background-color: #f9f9f9;
}

.form-section h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 8px;
}

.form-section h5 {
    margin: 10px 0;
    color: #555;
    font-size: 14px;
}

.html-preview {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-top: 10px;
}

.html-items-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 10px;
    background-color: #fff;
}

.html-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 5px;
}

.html-item:last-child {
    border-bottom: none;
}

.html-item-name {
    flex: 1;
    font-weight: 500;
    color: #333;
    margin-right: 10px;
}

.html-item-prices {
    display: flex;
    gap: 15px;
    font-size: 14px;
}

.html-item-price {
    color: #666;
}

.html-item-price.brutto {
    color: #d63384;
}

.html-item-price.netto {
    background-color: #c6f6d5;
    color: #2f855a;
}

.html-item-price.netto {
    color: #198754;
}

/* Meter information styling */
.html-item-data {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.html-item-meters {
    background-color: #e8f4f8;
    color: #2c5282;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: 500;
    display: inline-block;
    margin-bottom: 5px;
    border: 1px solid #bee3f8;
}

.object-linking-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 10px;
    background-color: #fff;
}

.object-link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 5px;
}

.object-link-item:last-child {
    border-bottom: none;
}

.object-link-select {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
}

.object-link-name {
    flex: 2;
    font-size: 12px;
    color: #666;
}

.link-status {
    font-size: 11px;
    font-weight: bold;
    margin-left: 8px;
}

.link-status.linked {
    color: #198754;
}

.predefined-values-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 10px;
    background-color: #fff;
}

.predefined-value-item {
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 15px;
    padding: 15px;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.predefined-value-item:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.predefined-value-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.predefined-value-header strong {
    color: #333;
    font-size: 16px;
}

.predefined-value-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.predefined-value-details .form-group {
    margin-bottom: 10px;
}

.predefined-value-details .form-group.full-width {
    grid-column: 1 / -1;
}

.predefined-value-details label {
    display: block;
    font-size: 13px;
    color: #555;
    margin-bottom: 4px;
    font-weight: 500;
}

.predefined-value-details input,
.predefined-value-details textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.predefined-value-details textarea {
    resize: vertical;
    min-height: 60px;
}

.btn-success {
    background-color: #198754;
    color: white;
    border: none;
}

.btn-success:hover {
    background-color: #157347;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

.offset-inputs {
    display: flex;
    gap: 15px;
    align-items: center;
}

.offset-inputs label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: normal;
}

.offset-input {
    width: 60px !important;
    padding: 4px 6px !important;
    font-size: 12px;
}

/* Enhanced edit panel for larger content */
#predefinedValuesPanel {
    width: 80%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}

#contextMenu,
.context-menu {
    font-size: 13px !important;
}

#contextMenu button,
.context-menu-item {
    font-size: 13px !important;
    padding: 4px 8px !important;
} 