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

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f4f4;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background-color: #fff;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.file-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.hidden-file-input {
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    z-index: -1;
}

.file-input-button {
    background-color: #1F7E92;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: inline-block;
}

.file-input-button:hover {
    background-color: #166475;
}

.file-name-display {
    margin-left: 5px;
    font-size: 14px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    display: inline-block;
    padding: 5px 10px;
    background-color: #f5f5f5;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.main-content {
    display: flex;
    gap: 20px;
    height: 1000px;
}

.toolbox {
    width: 400px;
    background-color: #fff;
    border-radius: 5px;
    padding: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10; /* Ensure fields appear above the PDF */
    flex: 0 0 400px; /* Fixed width for toolbox */
    margin-right: 20px;
    height: 100%;
}

.pdf-view-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent flex items from overflowing */
    height: 100%;
}

.pdf-container {
    flex: 1; /* Take up most of the space */
    min-width: 0; /* Prevent flex items from overflowing */
    margin-bottom: 20px;
}
    
    /* Ensure the page container doesn't add extra width */
    .page-container canvas {
    max-width: 100%;
    height: auto;
}

.fields-list-container {
    padding: 15px;
    border-bottom: 1px solid #ddd;
}

.fields-list {
    max-height: 180px; /* Increased height to show more fields */
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 10px 0;
}

.field-list-item {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.field-list-item:hover {
    background-color: #f5f5f5;
}

.field-list-item.selected {
    background-color: #e3f2fd;
    font-weight: bold;
}

.field-list-item .field-page {
    font-size: 0.8em;
    color: #666;
    background-color: #eee;
    padding: 2px 6px;
    border-radius: 10px;
}

.empty-list-message {
    padding: 15px;
    text-align: center;
    color: #999;
    font-style: italic;
}

.field-properties {
    padding: 14px;
    overflow-y: auto;
    flex-grow: 1; /* Allow it to expand to fill available space */
}

.fixed-controls {
    background-color: #fff;
    padding: 15px;
    border-top: 1px solid #ddd;
    position: sticky;
    bottom: 0;
    z-index: 5;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
}

.fixed-controls button {
    width: 100%;
}

.add-btn {
    background-color: #4CAF50;
    width: 100%;
    margin: 10px 0;
}

.add-btn:hover {
    background-color: #388E3C;
}

.delete-btn {
    background-color: #f44336;
    width: 100%;
}

.delete-btn:hover {
    background-color: #d32f2f;
}

.delete-btn:disabled {
    background-color: #ffcdd2;
    cursor: not-allowed;
}

#updateField:disabled {
    background-color: #b0bec5;
    cursor: not-allowed;
}

.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.half-width {
    flex: 1;
    margin-bottom: 0;
}

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px; /* Slightly larger font size for better readability */
}

.form-group input[readonly] {
    background-color: #f5f5f5;
    color: #666;
    cursor: not-allowed;
}

#predefinedFields {
    background-color: #f0f8ff;
    border: 2px solid #1F7E92;
    font-weight: bold;
}

#predefinedFields:focus {
    border-color: #166475;
    box-shadow: 0 0 5px rgba(31, 126, 146, 0.5);
}

button {
    background-color: #1F7E92;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

button:hover {
    background-color: #166475;
}

/* Improve visibility of input values */
.form-group input[type="text"],
.form-group input[type="number"] {
    background-color: #f9f9f9;
    border: 1px solid #ccc;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #1F7E92;
    box-shadow: 0 0 3px rgba(31, 126, 146, 0.3);
}

/* Styles for Add Field button now handled by .add-btn class */

.pdf-container {
    flex-grow: 1;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
    display: flex;
    flex-direction: column;
    height: 600px;
}

.pdf-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #ddd;
    z-index: 5;
}

.pdf-navigation button {
    min-width: 100px;
    cursor: pointer;
    padding: 8px 15px;
    background-color: #1F7E92;
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
}

.pdf-navigation button:hover:not(:disabled) {
    background-color: #166a7b;
}

.pdf-navigation button:disabled {
    background-color: #b0bec5;
    cursor: not-allowed;
}

#pageInfo {
    font-weight: bold;
    min-width: 100px;
    text-align: center;
}
    
    /* Modal styles */
    .modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    }
    
    .modal-content {
    position: relative;
    background-color: #fff;
    margin: 10% auto;
    padding: 0;
    width: 600px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    animation: modalFadeIn 0.3s;
    }
    
    @keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-50px); }
    to { opacity: 1; transform: translateY(0); }
    }
    
    .modal-header {
    padding: 15px 20px;
    background-color: #1F7E92;
    color: white;
    border-radius: 5px 5px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    }
    
    .modal-body {
    padding: 20px;
    }
    
    .modal-footer {
    padding: 15px 20px;
    background-color: #f5f5f5;
    border-top: 1px solid #ddd;
    border-radius: 0 0 5px 5px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    }
    
    .close-modal {
    color: white;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    }
    
    .close-modal:hover {
    color: #ddd;
    }
    
    #jsonInputText {
    width: 100%;
    height: 250px;
    padding: 10px;
    font-family: monospace;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    margin-top: 10px;
        transition: background-color 0.3s;
    }
    
    #jsonInputText.paste-success {
        background-color: #e8f5e9;
        border-color: #4CAF50;
    }
    
    /* Help text in modal */
    .modal-body p {
        margin-bottom: 10px;
        color: #666;
    }
    
    #cancelImport {
    background-color: #9e9e9e;
    }
    
    #confirmImport {
    background-color: #4CAF50;
    }

#pdfViewer {
    flex-grow: 1;
    position: relative;
    overflow: auto;
    background-color: #f5f5f5;
}

.page-container {
    margin: 20px auto;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    background-color: white;
}

.placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: #999;
    text-align: center;
}

.error-message {
    color: #f44336;
    text-align: center;
    margin: 20px;
    padding: 10px;
    border: 1px solid #f44336;
    border-radius: 4px;
    background-color: #ffebee;
}

#pdfViewer {
    position: relative;
    min-height: 100%;
}

.placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: #999;
}

.json-output {
    background-color: #fff;
    border-radius: 5px;
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    flex: 0 0 auto; /* Don't allow it to grow */
    height: 200px;
    display: flex;
    flex-direction: column;
    margin-top: 20px;
}

#jsonOutput {
    width: 100%;
    flex: 1; /* Take up remaining space */
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    margin-bottom: 10px;
    resize: none;
}

#copyJson {
    display: block;
    margin-left: auto;
}

.text-field {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px dashed #1F7E92;
    cursor: move;
    user-select: none;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.text-field.signature-field {
    border: 1px dashed #9C27B0;
    background-color: rgba(156, 39, 176, 0.1);
}

.text-field.signature-field .field-name {
    background-color: #9C27B0;
}

.text-field.signature-field .resize-handle {
    background-color: #9C27B0;
}

.text-field.selected {
    border: 2px solid #1F7E92;
    z-index: 10;
}

.text-field.signature-field.selected {
    border: 2px solid #9C27B0;
}

.text-field .resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #1F7E92;
    right: 0;
    bottom: 0;
    cursor: nwse-resize;
}

.text-field .field-name {
    position: absolute;
    top: -18px;
    left: 0;
    font-size: 12px;
    background-color: #1F7E92;
    color: white;
    padding: 1px 5px;
    border-radius: 3px;
}

.page-container {
    position: relative;
    margin-bottom: 10px;
}

.page-number {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 12px;
}

.error-message {
    color: #f44336;
    text-align: center;
    margin: 20px;
    padding: 10px;
    border: 1px solid #f44336;
    border-radius: 4px;
    background-color: #ffebee;
}

.placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: #999;
    text-align: center;
    width: 100%;
}

.pdf-navigation button {
    min-width: 100px;
}

#pageInfo {
    min-width: 100px;
    text-align: center;
}

.page-container {
    margin: 0 auto;
    position: relative;
}
