/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
    overflow: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-content h2 {
    margin: 20px 0 10px 0;
    font-size: 2rem;
    font-weight: 300;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Main App Container */
.app-container {
    display: flex;
    height: 100vh;
    background: white;
}

/* Sidebar Navigation */
.sidebar {
    width: 250px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    background: #34495e;
    border-bottom: 1px solid #2c3e50;
}

.sidebar-header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
}

.sidebar-menu {
    flex: 1;
    padding: 10px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.menu-item:hover {
    background: #34495e;
}

.menu-item.active {
    background: #3498db;
    border-left-color: #2980b9;
}

.menu-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.menu-icon {
    font-size: 1.2rem;
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

.menu-text {
    font-weight: 500;
    flex: 1;
}

.menu-separator {
    height: 1px;
    background: #34495e;
    margin: 10px 20px;
}

.menu-item.external {
    color: #bdc3c7;
    font-size: 0.95rem;
}

.menu-item.external:hover {
    background: #34495e;
    color: white;
}

.external-icon {
    font-size: 0.8rem;
    opacity: 0.7;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid #34495e;
    text-align: center;
}

.app-info {
    color: #95a5a6;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-view {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.content-view.active {
    display: flex;
}

.view-header {
    background: white;
    padding: 30px;
    border-bottom: 1px solid #e1e5e9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.view-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
}

.view-header p {
    color: #7f8c8d;
    font-size: 1rem;
}

.toolbar {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.toolbar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
    min-width: 200px;
}

.toolbar-section h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toolbar-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.download-options-mini {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e1e5e9;
}

.view-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background: #f8f9fa;
}

.view-actions {
    background: white;
    padding: 20px 30px;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

/* Notification System */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.notification {
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #3498db;
    max-width: 400px;
    pointer-events: auto;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
    position: relative;
    font-size: 14px;
    line-height: 1.4;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification.notification-success {
    border-left-color: #27ae60;
    background: #f8fff9;
}

.notification.notification-error {
    border-left-color: #e74c3c;
    background: #fff8f8;
}

.notification.notification-warning {
    border-left-color: #f39c12;
    background: #fffcf8;
}

.notification.notification-info {
    border-left-color: #3498db;
    background: #f8fcff;
}

.notification-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #7f8c8d;
    line-height: 1;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-close:hover {
    color: #2c3e50;
}

/* PDF Info Badge */
.pdf-info-badge {
    position: relative;
    display: inline-block;
    margin-left: 8px;
    cursor: help;
}

.pdf-info-badge .info-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background: #e0e0e0;
    color: #666;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.pdf-info-badge:hover .info-icon {
    background: #2196F3;
    color: white;
}

.pdf-info-badge .pdf-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 12px;
    font-weight: normal;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    pointer-events: none;
    min-width: 150px;
    text-align: left;
}

.pdf-info-badge .pdf-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

.pdf-info-badge:hover .pdf-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2980b9;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #7f8c8d;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover:not(:disabled) {
    background: #138496;
}

.btn-outline {
    background: white;
    color: #3498db;
    border: 2px solid #3498db;
}

.btn-outline:hover {
    background: #3498db;
    color: white;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c0392b;
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.file-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #ecf0f1;
    color: #2c3e50;
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 14px;
}

.file-label:hover {
    background: #d5dbdb;
    border-color: #95a5a6;
}

.file-input {
    display: none;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
}

.form-group input, 
.form-group textarea, 
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    background: white;
}

.form-group input:focus, 
.form-group textarea:focus, 
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.field-description {
    font-size: 0.85rem;
    color: #7f8c8d;
    margin-bottom: 8px;
    line-height: 1.4;
}

.checkbox-container {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 5px;
}

.checkbox-container input[type="checkbox"] {
    width: auto !important;
    margin: 0 !important;
    margin-top: 2px;
    transform: scale(1.1);
    flex-shrink: 0;
}

.checkbox-label {
    margin: 0 !important;
    font-weight: 600 !important;
    cursor: pointer;
    color: #2c3e50;
    line-height: 1.4;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.radio-container {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.radio-container input[type="radio"] {
    width: auto !important;
    margin: 0 !important;
    margin-top: 2px;
    transform: scale(1.1);
    flex-shrink: 0;
}

.radio-label {
    margin: 0 !important;
    cursor: pointer;
    color: #2c3e50;
    line-height: 1.4;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
}


.panel-header {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.panel-content {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}


.group-indicator {
    font-size: 0.8rem;
    color: #7f8c8d;
    font-weight: normal;
}

.unassigned-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e1e5e9;
}

.unassigned-section h4 {
    font-size: 0.9rem;
    color: #e67e22;
    margin-bottom: 10px;
}

.property-section {
    display: none;
}

.property-section.active {
    display: block;
}


.signature-settings {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e1e5e9;
}

.signature-settings h4 {
    margin: 0 0 15px 0;
    font-size: 0.9rem;
    color: #2c3e50;
}

.signature-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.coordinate-help {
    margin-top: 15px;
    padding: 10px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #856404;
}

/* Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

/* PDF Selection */
.pdf-selection-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 100%;
    min-height: 500px;
}

.pdf-selection-list {
    overflow-y: auto;
    padding-right: 10px;
}

.pdf-selection {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pdf-preview-panel {
    background: white;
    border-radius: 8px;
    border: 2px solid #e1e5e9;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: sticky;
    top: 0;
    height: 80vh;
    min-height: 600px;
}

.pdf-preview-panel .preview-header {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
}

.pdf-preview-panel .preview-header h4 {
    margin: 0;
    font-size: 1rem;
    color: #2c3e50;
}

.pdf-preview-panel .preview-content {
    flex: 1;
    padding: 5px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: #7f8c8d;
    text-align: center;
}

.preview-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.pdf-preview-active {
    display: block;
}

.pdf-preview-info {
    margin-bottom: 20px;
}

.pdf-preview-info h5 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.pdf-preview-details {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 15px;
}

.pdf-preview-canvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pdf-checkbox {
    display: flex;
    align-items: flex-start;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border: 2px solid #e1e5e9;
    transition: all 0.2s ease;
    cursor: pointer;
}

.pdf-checkbox:hover {
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
}

.pdf-checkbox.selected {
    border-color: #3498db;
    background: #f8fcff;
}

.pdf-checkbox input[type="checkbox"] {
    margin-right: 15px;
    margin-top: 3px;
    transform: scale(1.2);
}

.pdf-info {
    flex: 1;
}

.pdf-info h4 {
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 1.1rem;
    font-weight: 600;
}

.pdf-path {
    font-size: 0.85em;
    color: #7f8c8d;
    font-family: 'Monaco', 'Menlo', monospace;
    margin-bottom: 5px;
}

.pdf-fields {
    font-size: 0.9em;
    color: #95a5a6;
}

.fields-preview .fields-full {
    display: none;
}

.fields-toggle {
    color: #3498db;
    cursor: pointer;
    font-size: 0.85em;
    margin-top: 5px;
    text-decoration: underline;
}

.fields-toggle:hover {
    color: #2980b9;
}


/* Form Sections */
.form-section {
    background: white;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border-left: 4px solid #3498db;
}

.form-section h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.3rem;
    font-weight: 600;
}

.form-section .description {
    color: #7f8c8d;
    margin-bottom: 20px;
    font-style: italic;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

/* Download Options */
.download-options {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    margin-right: 20px;
    min-width: 300px;
}

.download-options h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 1.1em;
}

.download-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.download-help {
    color: #7f8c8d;
    font-size: 0.9em;
    line-height: 1.4;
}

.download-help strong {
    color: #2c3e50;
}

/* Live Preview Styles */
body.live-preview-active {
    overflow: hidden;
}

body.live-preview-active .view-content {
    display: flex;
    height: calc(100vh - 80px); /* Full height without status bar */
    overflow: hidden;
    padding: 0;
    width: 100%;
}

body.live-preview-active .view-actions {
    display: none; /* Hide the view-actions area when live preview is active */
}

.form-container {
    width: 50%;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    border-right: 1px solid #e1e5e9;
    flex-shrink: 0;
}

.pdf-preview-container {
    width: 50%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.preview-header {
    padding: 15px;
    border-bottom: 1px solid #e1e5e9;
    background: #f8f9fa;
}

.preview-header h4 {
    margin: 0 0 10px 0;
    font-size: 1rem;
    color: #2c3e50;
}

.preview-controls-mini {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.preview-controls-mini select {
    flex: 1;
    min-width: 120px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
}

.preview-nav-mini {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-nav-mini button {
    background: #3498db;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-nav-mini button:hover:not(:disabled) {
    background: #2980b9;
}

.preview-nav-mini button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.preview-nav-mini span {
    font-size: 12px;
    color: #7f8c8d;
    min-width: 40px;
    text-align: center;
}

.preview-content {
    flex: 1;
    padding: 10px;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ecf0f1;
}

#livePreviewCanvas {
    width: 95%;
    height: 95%;
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    background: white;
    border-radius: 4px;
}

.preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #7f8c8d;
}

/* Hidden Data Section */
.hidden-data-section {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.hidden-data-toggle {
    cursor: pointer;
    color: #856404;
    text-decoration: underline;
}

.hidden-data-content {
    display: none;
    margin-top: 15px;
}

/* Signature Components */
.signature-field {
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    padding: 15px;
    background: #f8f9fa;
    grid-column: 1 / -1;
}

.signature-preview {
    width: 100%;
    max-width: 400px;
    height: 150px;
    border: 2px dashed #bdc3c7;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    margin: 10px 0;
    position: relative;
    overflow: hidden;
}

.signature-preview.has-signature {
    border-color: #3498db;
    border-style: solid;
}

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

.signature-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.signature-placeholder {
    color: #95a5a6;
    text-align: center;
    padding: 20px;
    cursor: pointer;
}

.signature-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.signature-controls button {
    padding: 8px 16px;
    border: 1px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.signature-controls button:hover {
    background: #3498db;
    color: white;
}

.signature-controls button.primary {
    background: #3498db;
    color: white;
}

.signature-mode-tabs {
    display: flex;
    border-bottom: 2px solid #e1e5e9;
    margin-bottom: 15px;
}

.signature-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    font-size: 14px;
}

.signature-tab:hover {
    color: #3498db;
    background: #f8f9fa;
}

.signature-tab.active {
    color: #3498db;
    border-bottom-color: #3498db;
    background: #f8fcff;
}

.signature-content {
    display: none;
}

.signature-content.active {
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
    }
    
    .sidebar-menu {
        display: flex;
        flex-direction: row;
        padding: 0;
    }
    
    .menu-item {
        flex-shrink: 0;
        white-space: nowrap;
    }
    
    
    .signature-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .download-buttons {
        flex-direction: column;
    }
    
    body.live-preview-active .view-content {
        flex-direction: column;
    }
    
    .form-container,
    .pdf-preview-container {
        width: 100%;
        height: 50%;
    }
    
    .form-container {
        border-right: none;
        border-bottom: 1px solid #e1e5e9;
    }
    
    .pdf-selection-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .pdf-preview-panel {
        position: static;
        max-height: 300px;
    }
}

/* Error Screen */
.error-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #e74c3c;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.error-content {
    text-align: center;
    color: white;
    max-width: 600px;
    padding: 40px;
}

.error-content h2 {
    margin-bottom: 20px;
    font-size: 2rem;
}

.error-content ul {
    text-align: left;
    margin: 20px 0;
}

/* Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }

/* Selection Summary - removed, using notifications instead */

.url-params {
    background: #e8f4f8;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #17a2b8;
}