/* Main contracts management container */
.contracts-management {
    padding: 20px;
    background-color: #f8f9fa;
    min-height: calc(100vh - 60px);
}

/* Header section */
.contracts-header {
    margin-bottom: 30px;
}

.contracts-header h2 {
    color: #333;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.contracts-header .subtitle {
    color: #6c757d;
    font-size: 1.1rem;
}

/* Action buttons */
.contracts-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 25px;
}

.contracts-actions .btn {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    padding: 10px 20px;
    transition: all 0.3s ease;
}

.contracts-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Filter section */
.contracts-filters {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.filter-group {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-item label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

.filter-item select,
.filter-item input {
    min-width: 180px;
}

/* Contracts table container */
.contracts-table-container {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Table styling */
.contracts-table {
    width: 100%;
    border-collapse: collapse;
}

.contracts-table thead {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.contracts-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contracts-table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}

.contracts-table tbody tr:hover {
    background-color: #f8f9fa;
}

.contracts-table td {
    padding: 15px;
    color: #333;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge.draft {
    background-color: #e9ecef;
    color: #6c757d;
}

.status-badge.generated {
    background-color: #d1ecf1;
    color: #0c5460;
}

.status-badge.sent {
    background-color: #fff3cd;
    color: #856404;
}

.status-badge.signed {
    background-color: #d4edda;
    color: #155724;
}

.status-badge.cancelled {
    background-color: #f8d7da;
    color: #721c24;
}

/* Action buttons in table */
.action-buttons {
    display: flex;
    gap: 8px;
}

.action-buttons .btn {
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #dee2e6;
}

.empty-state h3 {
    color: #495057;
    margin-bottom: 10px;
}

/* Context Selector Section */
.context-selector {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    padding: 40px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.selector-header {
    text-align: center;
    margin-bottom: 30px;
}

.selector-header h3 {
    color: #333;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.selector-header p {
    color: #6c757d;
    font-size: 1.1rem;
}

.selector-form .form-group {
    margin-bottom: 20px;
}

.selector-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.selector-form .form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.selector-form .form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.25);
}

.selector-form .form-control:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

.selector-actions {
    margin-top: 30px;
    text-align: center;
}

.selector-actions .btn {
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
}

.alternative-access {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    text-align: center;
}

.alternative-access p {
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: #666;
}

.btn-outline-primary {
    background: transparent;
    border: 2px solid #007bff;
    color: #007bff;
    padding: 10px 25px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-outline-primary:hover {
    background: #007bff;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.3);
}

/* No Context Message */
.no-context-message {
    text-align: center;
    padding: 40px;
}

.no-context-message .alert {
    max-width: 500px;
    margin: 0 auto;
    padding: 30px;
    border-radius: 10px;
}

.no-context-message h3 {
    margin: 15px 0 10px 0;
    color: #333;
}

.no-context-message p {
    margin-bottom: 20px;
    color: #666;
}

/* Templates Section */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.template-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.template-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.template-card.selected {
    border: 2px solid #007bff;
}

.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.template-card h4 {
    margin: 0;
    color: #333;
    font-size: 1.2rem;
}

.template-type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.template-type-badge.contract {
    background-color: #e3f2fd;
    color: #1976d2;
}

.template-type-badge.proforma {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.template-card-body {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.template-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.template-meta {
    font-size: 0.85rem;
    color: #999;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.template-meta .template-language {
    background-color: #e9ecef;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.8rem;
}

.template-meta .template-context {
    background-color: #d4edda;
    color: #155724;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.template-meta .template-context.template-global {
    background-color: #cce5ff;
    color: #004085;
}

.template-meta .template-context i {
    font-size: 0.75rem;
}

.template-actions {
    display: flex;
    gap: 10px;
}

/* Contract Generation Form */
.contract-form {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.form-section {
    margin-bottom: 30px;
}

.form-section h4 {
    color: #333;
    font-size: 1.3rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

/* Loading states */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    text-align: center;
}

.loading-spinner .spinner-border {
    width: 3rem;
    height: 3rem;
    margin-bottom: 15px;
}

/* Template Editor Styles */
.template-editor {
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    position: relative;
    overflow: hidden; /* Prevent overflow on the container itself */
}

/* Ensure template editor container has proper height */
.template-editor-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Specific fixes for template editor scrolling */
#template-editor-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#template-editor-container:not(.hidden) {
    display: flex !important;
}

#template-editor-container .template-editor {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f5f5f5;
}

/* Force proper scrollbar styling */
#template-editor-container .canvas-wrapper::-webkit-scrollbar,
.canvas-wrapper::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

#template-editor-container .canvas-wrapper::-webkit-scrollbar-track,
.canvas-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

#template-editor-container .canvas-wrapper::-webkit-scrollbar-thumb,
.canvas-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}

#template-editor-container .canvas-wrapper::-webkit-scrollbar-thumb:hover,
.canvas-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Firefox scrollbar support */
.canvas-wrapper {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* Ensure template canvas doesn't prevent scrolling */
.template-canvas {
    min-height: min-content !important;
    height: auto !important;
    position: relative;
}

/* Force canvas wrapper to be scrollable when content is tall */
#template-editor-container .canvas-wrapper {
    overflow-y: auto !important; /* Changed from scroll to auto to show scrollbar only when needed */
    overflow-x: auto !important;
}

/* Debug: Force visible overflow for A4 pages */
.canvas-page {
    flex-shrink: 0; /* Prevent pages from shrinking */
}

.editor-header {
    background: white;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 10;
}

.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-center {
    flex: 1;
    justify-content: center;
}

.template-name-input,
.template-type-select,
.template-language-select,
.template-fair-select {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.template-name-input {
    min-width: 250px;
}

.editor-mode {
    font-size: 0.9rem;
    color: #6c757d;
    margin-right: 15px;
}

.template-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

.template-info input,
.template-info select {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.editor-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    min-height: 0; /* Important for nested flex containers */
}

/* Editor Sidebar */
.editor-sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    height: 100%; /* Ensure full height */
    overflow: hidden; /* Prevent sidebar itself from scrolling */
    position: relative; /* Ensure proper positioning context */
}

/* Force height calculation for the sidebar in template editor */
#template-editor-container .editor-sidebar {
    height: calc(100vh - 200px) !important; /* Match parent container height */
    max-height: calc(100vh - 200px) !important;
}

.editor-sidebar.collapsed {
    width: 60px;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.sidebar-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.editor-sidebar.collapsed .sidebar-header h4 {
    display: none;
}

/* Collapse Buttons */
.collapse-btn {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: #6c757d;
    transition: color 0.2s;
}

.collapse-btn:hover {
    color: #495057;
}

.sidebar-title {
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.editor-sidebar.collapsed .sidebar-title span {
    display: none;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    min-height: 0; /* Critical for flex containers to allow scrolling */
    max-height: 100%; /* Ensure it doesn't exceed parent height */
}

/* Force scrolling for contract editor sidebar content */
#template-editor-container .sidebar-content {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: 100%;
    max-height: calc(100vh - 280px) !important; /* Account for header and sidebar header */
}

.editor-sidebar.collapsed .sidebar-content {
    padding: 10px 5px;
}

/* Scrollbar styling for sidebar content */
.sidebar-content::-webkit-scrollbar {
    width: 8px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Force scrollbar visibility in contract editor */
#template-editor-container .sidebar-content {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #888 #f1f1f1; /* Firefox */
}

/* Ensure scrollbar is always visible when there's overflow */
#template-editor-container .sidebar-content:hover {
    overflow-y: scroll !important; /* Force scrollbar to show on hover */
}

/* Component Groups */
.component-group {
    margin-bottom: 25px;
    flex-shrink: 0; /* Prevent groups from shrinking */
}

/* Debug: Force visible scrollbar for testing */
#template-editor-container .editor-sidebar .sidebar-content {
    overflow-y: scroll !important; /* Always show scrollbar */
}

.component-group h5 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
}

.component-group h5 .badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    font-weight: normal;
    letter-spacing: normal;
}

/* Language-specific component styling */
.component-item[data-language="ro"] {
    border-left: 3px solid #dc3545;
}

.component-item[data-language="en"] {
    border-left: 3px solid #007bff;
}

.editor-sidebar.collapsed .component-group h5 {
    display: none;
}

/* Component Items */
.component-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: grab;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.component-item:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateX(3px);
}

.component-item:active {
    cursor: grabbing;
}

.component-item i {
    color: #6c757d;
    width: 20px;
    text-align: center;
}

.component-item .badge {
    font-size: 0.65rem;
    padding: 2px 5px;
    margin-left: auto;
}

.editor-sidebar.collapsed .component-item {
    padding: 10px;
    justify-content: center;
}

.editor-sidebar.collapsed .component-item span {
    display: none;
}

.editor-sidebar.collapsed .component-item .badge {
    display: none;
}

/* Editor Main Area */
.editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    min-height: 0; /* Allow proper flex shrinking */
    height: 100%; /* Ensure full height */
}

/* Specific fix for template editor main area */
#template-editor-container .editor-main {
    height: 100% !important;
    overflow: hidden !important;
}

/* Properties Panel */
.editor-properties {
    width: 300px;
    background: white;
    border-left: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    position: relative;
    z-index: 5;
}

.editor-properties.collapsed {
    width: 40px;
}

.properties-header {
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.properties-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.editor-properties.collapsed .properties-header h4 {
    display: none;
}

.properties-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.editor-properties.collapsed .properties-content {
    display: none;
}

/* Canvas Area */
.canvas-wrapper {
    flex: 1;
    display: block !important; /* Changed from flex to block */
    overflow-y: scroll !important; /* Force scroll to always show */
    overflow-x: auto !important;
    background: #f5f5f5;
    padding: 20px 20px 100px 20px; /* Extra bottom padding for scrolling */
    position: relative;
    min-height: 0; /* Important for flex containers to allow scrolling */
    height: 100%; /* Explicit height for proper scrolling */
    max-height: calc(100vh - 200px) !important; /* Limit height to ensure scrolling */
}

/* Ensure canvas wrapper in template editor specifically has scroll */
#template-editor-container .canvas-wrapper {
    display: block !important;
    overflow-y: scroll !important;
    overflow-x: auto !important;
    height: 100% !important;
    max-height: calc(100vh - 200px) !important; /* Match parent container */
}

/* Force the editor main to have proper height */
#template-editor-container .editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Critical for nested flex containers */
    height: 100%;
    max-height: calc(100vh - 200px);
}

/* Canvas Toolbar */
.canvas-toolbar {
    background: white;
    padding: 10px 15px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    min-height: 50px;
}

.canvas-toolbar .btn {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.canvas-toolbar .toolbar-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.canvas-toolbar .zoom-controls,
.canvas-toolbar .page-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.canvas-toolbar .zoom-level {
    min-width: 50px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
}

.canvas-toolbar .page-indicator {
    padding: 0 10px;
    font-size: 0.85rem;
}

.canvas-toolbar .page-settings {
    display: flex;
    gap: 10px;
}

.canvas-toolbar .form-select {
    padding: 6px 12px;
    font-size: 0.85rem;
    min-width: auto;
}

/* Page Tabs Container */
.page-tabs-container {
    background: white;
    border-bottom: 1px solid #dee2e6;
    padding: 0 15px;
    min-height: 40px;
}

.page-tabs {
    display: flex;
    gap: 5px;
    padding: 5px 0;
}

/* Template Canvas */
.template-canvas {
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
    transform-origin: top center;
    transition: transform 0.3s ease;
    padding-bottom: 100px; /* Extra padding at bottom */
}

/* Canvas Pages */
.canvas-page {
    width: 794px; /* 210mm at 96dpi */
    min-height: 1123px; /* 297mm at 96dpi */
    margin: 0 auto 30px auto;
    background: white;
    border: 1px solid #dee2e6;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    position: relative;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Georgia', 'Times New Roman', serif !important;
    font-size: 8pt !important;
    line-height: 1.3 !important;
    color: #2c3e50 !important;
}

.canvas-page:last-child {
    margin-bottom: 100px; /* Extra space at bottom for scrolling */
}

/* Page Content */
.page-content {
    padding: 40px 40px; /* Reduced top/bottom padding for editor view */
    min-height: 1123px; /* 297mm at 96dpi */
    box-sizing: border-box;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

/* Reduce excessive top padding in editor mode */
.template-editor-container:not(.preview-mode) .page-content {
    padding-top: 20px; /* Much less top padding in editor */
    padding-bottom: 30px; /* Reasonable bottom padding */
}

/* Page Number Indicator */
.page-number {
    position: absolute;
    top: -30px;
    right: 0;
    background: #6c757d;
    color: white;
    padding: 4px 12px;
    border-radius: 4px 4px 0 0;
    font-size: 0.85rem;
}

/* Drop Zones */
.drop-zone {
    min-height: 80px;
    border: 2px dashed #dee2e6;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
    color: #adb5bd;
    position: relative;
    transition: all 0.3s ease;
}

.drop-zone:last-child {
    margin-bottom: 0;
}

.drop-zone.drag-over {
    border-color: #007bff;
    background: #e3f2fd;
    color: #007bff;
}

.drop-zone:not(:empty) {
    border: none;
    padding: 0;
    min-height: auto;
    text-align: left;
}

/* Show empty state text with pseudo-element */
.drop-zone.empty::before {
    content: 'Drop content here';
    display: block;
    color: #adb5bd;
    text-align: center;
    padding: 20px;
}

/* Drop zone selected state */
.drop-zone.selected {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Template Elements */
.template-element {
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid transparent;
    border-radius: 4px;
    position: relative;
    transition: all 0.2s ease;
    cursor: move;
}

.template-element:hover {
    border-color: #dee2e6;
    background: #f8f9fa;
}

.template-element.selected {
    border-color: #007bff;
    background: #e3f2fd;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.25);
}

.template-element:last-child {
    margin-bottom: 0;
}

/* Contract Template Component Styles for Editor View - Match Preview Exactly */

/* Apply base font to all contract elements */
.template-element {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 8pt;
    line-height: 1.3;
    color: #2c3e50;
}

/* Reset all professional elements to match preview exactly */
.template-element [class*="professional"] {
    font-family: 'Georgia', 'Times New Roman', serif !important;
    font-size: 8pt !important;
    line-height: 1.3 !important;
    color: #2c3e50 !important;
}

/* Ensure consistent spacing */
.template-element [class*="-wrapper"] {
    width: 100%;
    margin: 4px 0;
    page-break-inside: avoid;
}

/* Override any conflicting styles from main.css */
.template-element * {
    box-sizing: border-box;
}

/* Force Georgia font and professional styling in editor */
.canvas-page * {
    font-family: 'Georgia', 'Times New Roman', serif !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.template-canvas * {
    font-family: 'Georgia', 'Times New Roman', serif !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Standardize all h4 titles */
.canvas-page h4,
.template-canvas h4 {
    font-size: 9pt !important;
    font-weight: 500 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
    margin: 0 0 4px 0 !important;
}

/* Ensure editor matches preview styling exactly */
.canvas-page .document-title {
    font-size: 9pt !important;
    font-weight: 500 !important;
    text-align: center !important;
    color: #2c3e50 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
    margin-bottom: 4px !important;
}

/* Contract header title should be slightly bigger */
.canvas-page .contract-header-element .document-title {
    font-size: 10pt !important;
}

.canvas-page .field-label {
    font-size: 7pt !important;
    font-weight: 400 !important;
    color: #2c3e50 !important;
}

.canvas-page .field-value {
    font-size: 7pt !important;
    font-weight: 400 !important;
    color: #2c3e50 !important;
    border-bottom: 1px dotted #ddd !important;
}

.canvas-page .section-header {
    font-size: 7pt !important;
    font-weight: 500 !important;
    color: #2c3e50 !important;
    text-transform: uppercase !important;
    background: transparent !important;
    padding: 1px 2px !important;
    margin-bottom: 2px !important;
}

/* Specific overrides for detailed accessories in editor */
.canvas-page .detailed-accessories-wrapper,
.template-canvas .detailed-accessories-wrapper {
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.canvas-page .detailed-accessories-element,
.template-canvas .detailed-accessories-element {
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

/* Fix header column widths for editor display */
.canvas-page .detailed-accessories-element.professional .header-qty,
.template-canvas .detailed-accessories-element.professional .header-qty {
    width: 60px;
}

.canvas-page .detailed-accessories-element.professional .header-unit,
.template-canvas .detailed-accessories-element.professional .header-unit {
    width: 80px;
}

.canvas-page .detailed-accessories-element.professional .header-total,
.template-canvas .detailed-accessories-element.professional .header-total {
    width: 80px;
}

/* Consistent field value styling */
.template-element .field-value,
.template-element .value-compact,
.template-element .amount {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* Pricing Table Professional Style - Ultra Compact */
.pricing-table-wrapper {
    width: 100%;
    margin: 4px 0;
    page-break-inside: avoid;
    background: white;
    font-family: 'Georgia', 'Times New Roman', serif !important;
    font-size: 8pt !important;
    line-height: 1.2 !important;
    color: #2c3e50 !important;
}

.pricing-table-element.professional {
    width: 100%;
    padding: 0;
    background: white;
    border: none;
    border-radius: 0;
}

.pricing-table-element.professional .document-title {
    text-align: center;
    font-size: 9pt !important;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid #ddd;
    color: #2c3e50;
}

.pricing-table-element.professional .pricing-section {
    border: 1px solid #ddd;
    border-radius: 3px;
    margin-bottom: 6px;
    padding: 6px;
    background: #fafbfc;
}

.pricing-table-element.professional .section-header {
    font-weight: 600;
    font-size: 8pt;
    text-transform: uppercase;
    margin-bottom: 4px;
    text-align: center;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #bdc3c7;
    padding-bottom: 2px;
    color: #34495e;
}

.pricing-table-element.professional .price-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 3px 0;
    border-bottom: 1px solid #ecf0f1;
}

.pricing-table-element.professional .price-row:last-child {
    border-bottom: none;
}

.pricing-table-element.professional .item-description {
    flex: 1;
}

.pricing-table-element.professional .item-name {
    font-weight: 600;
    font-size: 7pt;
    color: #2c3e50;
    margin-bottom: 1px;
}

.pricing-table-element.professional .item-details {
    font-size: 6pt;
    color: #7f8c8d;
    font-style: italic;
}

.pricing-table-element.professional .amount {
    font-weight: 600;
    font-size: 7pt;
    color: #2c3e50;
    text-align: right;
    min-width: 60px;
    border-bottom: 1px dotted #bdc3c7;
    padding: 0 2px;
}

.pricing-table-element.professional .pricing-totals {
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px solid #34495e;
}

.pricing-table-element.professional .total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 2px 0;
}

.pricing-table-element.professional .total-label {
    font-weight: 600;
    font-size: 7pt;
    color: #495057;
}

.pricing-table-element.professional .total-amount {
    font-weight: 600;
    font-size: 7pt;
    color: #2c3e50;
    text-align: right;
}

.pricing-table-element.professional .total-row.subtotal {
    border-top: 1px solid #ecf0f1;
    padding-top: 3px;
    margin-top: 3px;
}

.pricing-table-element.professional .total-row.discount .total-amount {
    color: #e74c3c;
}

.pricing-table-element.professional .total-row.vat {
    font-size: 7pt;
}

.pricing-table-element.professional .total-row.final {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 2px solid #34495e;
}

.pricing-table-element.professional .total-row.final .total-label {
    font-size: 8pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #2c3e50;
}

.pricing-table-element.professional .total-row.final .total-amount {
    font-size: 8pt;
    font-weight: 700;
    border-bottom: 1px solid #34495e;
    color: #2c3e50;
}

/* Exhibitor Details Professional Style - Ultra Compact */
.exhibitor-details-wrapper {
    width: 100%;
    margin: 8px 0;
    page-break-inside: avoid;
    background: white;
    font-family: 'Georgia', 'Times New Roman', serif !important;
    font-size: 8pt !important;
    line-height: 1.3 !important;
    color: #2c3e50 !important;
}

.exhibitor-details-element.professional {
    width: 100%;
    padding: 0;
    background: white;
    border: none;
    border-radius: 0;
}

.exhibitor-details-element.professional .document-title {
    text-align: center;
    font-size: 9pt !important;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid #ddd;
    color: #2c3e50;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.exhibitor-details-element.professional .contract-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 6px;
    margin-bottom: 4px;
}

.exhibitor-details-element.professional .info-section {
    border: none;
    border-radius: 0;
    padding: 3px;
    background: transparent;
}

.exhibitor-details-element.professional .section-header {
    font-weight: 600;
    font-size: 7pt;
    text-transform: uppercase;
    margin-bottom: 3px;
    text-align: center;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #bdc3c7;
    padding-bottom: 2px;
    color: #34495e;
}

.exhibitor-details-element.professional .field-row {
    margin-bottom: 2px;
    display: flex;
    align-items: baseline;
}

.exhibitor-details-element.professional .field-label {
    font-weight: 400;
    font-size: 7pt;
    color: #2c3e50;
    margin-right: 3px;
}

.exhibitor-details-element.professional .field-value {
    flex: 1;
    border-bottom: 1px dotted #bdc3c7;
    min-height: 10px;
    padding: 0 2px;
    font-size: 7pt;
    color: #2c3e50;
}

.exhibitor-details-element.professional .full-width-section {
    grid-column: 1 / -1;
    border: 1px solid #ddd;
    border-radius: 2px;
    padding: 4px;
    margin-top: 4px;
    background: #fafbfc;
}

/* Contract Header Professional Style - Ultra Compact */
.contract-header-wrapper {
    width: 100%;
    margin: 4px 0;
    page-break-inside: avoid;
    background: white;
    font-family: 'Georgia', 'Times New Roman', serif !important;
    font-size: 8pt !important;
    line-height: 1.2 !important;
    color: #2c3e50 !important;
}

.contract-header-element.professional {
    width: 100%;
    padding: 0;
    background: white;
    border: none;
    border-radius: 0;
}

.contract-header-element.professional .document-title {
    text-align: center;
    font-size: 9pt !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid #ddd;
    color: #2c3e50;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.contract-header-element.professional .contract-subtitle {
    text-align: center;
    font-size: 8pt;
    font-weight: 500;
    font-style: italic;
    color: #6c757d;
    margin-bottom: 8px;
    padding-bottom: 4px;
}

.contract-header-element.professional .contract-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 6px;
}

.contract-header-element.professional .meta-section {
    border: none;
    border-radius: 0;
    padding: 4px;
    background: transparent;
}

.contract-header-element.professional .field-row {
    margin-bottom: 3px;
    display: flex;
    align-items: baseline;
}

.contract-header-element.professional .field-label {
    font-weight: 600;
    font-size: 8pt;
    color: #34495e;
    margin-right: 4px;
    min-width: 60px;
}

.contract-header-element.professional .field-value {
    flex: 1;
    border-bottom: 1px dotted #bdc3c7;
    min-height: 12px;
    padding: 0 3px;
    font-size: 8pt;
    color: #2c3e50;
}

/* Organizer Info Professional Style - Ultra Compact */
.organizer-info-wrapper {
    width: 100%;
    margin: 8px 0;
    page-break-inside: avoid;
    background: white;
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 8pt;
    line-height: 1.3;
}

.organizer-info-element.professional {
    width: 100%;
    padding: 8px;
    background: white;
    border: 1px solid #34495e;
    border-radius: 4px;
}

.organizer-info-element.professional .document-header {
    text-align: center;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid #34495e;
}

.organizer-info-element.professional .document-header h4 {
    margin: 0;
    font-size: 9pt !important;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #2c3e50;
}

.organizer-info-element.professional .compact-info {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 4px;
}

.organizer-info-element.professional .info-column {
    padding: 3px;
    background: #f8f9fa;
    border: 1px solid #eee;
}

.organizer-info-element.professional .column-title {
    font-weight: 600;
    font-size: 6pt;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 2px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 1px;
    letter-spacing: 0.3px;
    color: #34495e;
}

.organizer-info-element.professional .info-line {
    margin-bottom: 1px;
    display: flex;
    align-items: baseline;
}

.organizer-info-element.professional .label-compact {
    font-weight: 600;
    font-size: 6pt;
    color: #34495e;
    margin-right: 2px;
}

.organizer-info-element.professional .value-compact {
    flex: 1;
    border-bottom: 1px dotted #ddd;
    min-height: 8px;
    padding: 0 1px;
    font-size: 6pt;
    color: #2c3e50;
}

/* Additional Services Professional Style - Ultra Compact */
.additional-services-wrapper {
    width: 100%;
    margin: 8px 0;
    page-break-inside: avoid;
    background: white;
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 8pt;
    line-height: 1.3;
    color: #2c3e50;
}

.additional-services-element.professional {
    width: 100%;
    padding: 8px;
    background: white;
    border: 1px solid #34495e;
    border-radius: 4px;
}

.additional-services-element.professional .document-title {
    text-align: center;
    font-size: 9pt !important;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid #ddd;
    color: #2c3e50;
}

.additional-services-element.professional .services-subtitle {
    text-align: center;
    font-size: 8pt;
    font-style: italic;
    color: #7f8c8d;
    margin-bottom: 8px;
}

.additional-services-element.professional .service-category {
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 6px;
    background: #fafbfc;
}

.additional-services-element.professional .category-title {
    font-weight: 600;
    font-size: 8pt;
    text-transform: uppercase;
    margin-bottom: 4px;
    text-align: center;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #bdc3c7;
    padding-bottom: 2px;
    color: #34495e;
}

.additional-services-element.professional .service-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: start;
    padding: 2px 0;
    border-bottom: 1px solid #ecf0f1;
}

.additional-services-element.professional .service-item:last-child {
    border-bottom: none;
}

.additional-services-element.professional .service-name {
    font-weight: 600;
    font-size: 7pt;
    color: #2c3e50;
    margin-bottom: 1px;
}

.additional-services-element.professional .service-details {
    font-size: 6pt;
    color: #7f8c8d;
    font-style: italic;
}

.additional-services-element.professional .service-quantity {
    font-size: 7pt;
    color: #34495e;
    font-weight: 600;
    min-width: 30px;
    text-align: center;
}

.additional-services-element.professional .service-price {
    font-size: 7pt;
    color: #2c3e50;
    font-weight: 600;
    min-width: 60px;
    text-align: right;
    border-bottom: 1px dotted #bdc3c7;
    padding: 0 3px;
}

.additional-services-element.professional .services-total {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #34495e;
    text-align: right;
}

.additional-services-element.professional .total-label {
    font-weight: 700;
    font-size: 8pt;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #2c3e50;
}

.additional-services-element.professional .total-amount {
    font-weight: 700;
    font-size: 8pt;
    color: #2c3e50;
    border-bottom: 2px solid #34495e;
    min-width: 80px;
    text-align: right;
    padding: 0 3px;
}

.additional-services-element.professional .services-note {
    margin-top: 6px;
    padding: 4px 6px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 6pt;
    color: #6c757d;
    text-align: center;
    font-style: italic;
}

/* Detailed Accessories Professional Style */
.detailed-accessories-wrapper {
    width: 100%;
    margin: 4px 0;
    page-break-inside: avoid;
    background: white;
    font-family: 'Georgia', 'Times New Roman', serif !important;
    font-size: 8pt !important;
    line-height: 1.2 !important;
    color: #2c3e50 !important;
}

.detailed-accessories-element.professional {
    width: 100%;
    padding: 0;
    background: white;
    border: none;
    border-radius: 0;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.detailed-accessories-element.professional .document-title {
    text-align: center;
    font-size: 9pt !important;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid #ddd;
    color: #2c3e50;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.detailed-accessories-element.professional .accessories-subtitle {
    text-align: center;
    font-size: 7pt !important;
    font-style: italic;
    color: #7f8c8d;
    margin-bottom: 10px;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.detailed-accessories-element.professional .accessories-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Georgia', 'Times New Roman', serif !important;
    font-size: 8pt !important;
}

.detailed-accessories-element.professional .accessories-header {
    display: grid;
    grid-template-columns: 3fr 60px 80px 80px;
    background: #34495e;
    color: white;
    font-weight: 600;
    font-size: 7pt !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.detailed-accessories-element.professional .accessories-header > div {
    padding: 6px 4px;
    text-align: center;
    border-right: 1px solid #fff;
}

.detailed-accessories-element.professional .accessories-header > div:last-child {
    border-right: none;
}

.detailed-accessories-element.professional .header-item {
    text-align: left !important;
    padding-left: 8px !important;
}

.detailed-accessories-element.professional .accessories-body {
    background: white;
    border: 1px solid #ddd;
    border-top: none;
}

.detailed-accessories-element.professional .accessory-row {
    display: grid;
    grid-template-columns: 3fr 60px 80px 80px;
    border-bottom: 1px solid #e8e8e8;
    padding: 4px 0;
    align-items: start;
    min-height: 36px;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.detailed-accessories-element.professional .accessory-row:last-child {
    border-bottom: none;
}

.detailed-accessories-element.professional .accessory-row.sample {
    background: #fafbfc;
}

.detailed-accessories-element.professional .accessory-name {
    padding: 4px 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.detailed-accessories-element.professional .item-name {
    font-weight: 600;
    font-size: 8pt !important;
    color: #2c3e50;
    margin-bottom: 1px;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.detailed-accessories-element.professional .item-description {
    font-size: 6pt !important;
    color: #7f8c8d;
    font-style: normal;
    line-height: 1.2;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.detailed-accessories-element.professional .accessory-qty,
.detailed-accessories-element.professional .accessory-unit,
.detailed-accessories-element.professional .accessory-total {
    text-align: center;
    font-size: 8pt !important;
    color: #2c3e50;
    font-weight: 500;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.detailed-accessories-element.professional .accessories-total {
    background: #f4f4f4;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-top: 1px solid #34495e;
}

.detailed-accessories-element.professional .accessories-total .total-row {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 10px;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.detailed-accessories-element.professional .accessories-total .total-label {
    font-weight: 600;
    font-size: 8pt !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #2c3e50;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.detailed-accessories-element.professional .accessories-total .total-amount {
    font-weight: 700;
    font-size: 9pt !important;
    color: #2c3e50;
    border-bottom: 1px dotted #34495e;
    min-width: 80px;
    text-align: right;
    padding: 0 4px;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.detailed-accessories-element.professional .accessories-note {
    margin-top: 6px;
    padding: 4px 6px;
    background: #fafbfc;
    border: 1px solid #e8e8e8;
    border-radius: 0;
    font-size: 6pt !important;
    color: #6c757d;
    text-align: center;
    font-style: italic;
    font-family: 'Georgia', 'Times New Roman', serif !important;
}

.detailed-accessories-element.professional .accessories-note .fas {
    margin-right: 3px;
    font-size: 6pt;
}

/* Image Element - for logos and graphics */
.image-element {
    text-align: center;
    margin: 4px 0;
    padding: 4px;
}

.image-element img {
    max-width: 100%;
    height: auto;
    display: inline-block;
}

.image-element.logo-header {
    margin-bottom: 8px;
}

.image-element.logo-header img {
    max-height: 80px;
}

/* Signature Block */
.signature-element {
    margin: 20px 0;
}

.signature-element .signature-grid {
    display: flex;
    justify-content: space-between;
    margin-top: 50px;
}

.signature-element .signature-block {
    width: 45%;
    text-align: center;
}

.signature-element .signature-line {
    border-bottom: 2px solid #333;
    width: 100%;
    margin: 50px 0 10px 0;
}

.signature-element .signature-label {
    font-size: 14px;
    line-height: 1.5;
}

/* Terms & Conditions */
.terms-conditions-element {
    margin: 30px 0;
}

.terms-conditions-element h3 {
    color: #1a237e;
    margin-bottom: 15px;
}

.terms-conditions-element ol {
    padding-left: 20px;
}

.terms-conditions-element li {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* Make field placeholders visible in editor */
.template-element [class*="-element"] {
    min-height: 40px;
}

.template-element .field-value:empty::before,
.template-element .value-compact:empty::before,
.template-element .amount:empty::before,
.template-element .total-amount:empty::before {
    content: '...';
    color: #adb5bd;
}

/* Fix canvas page to show properly */
.canvas-page {
    background: white !important;
}

.page-content {
    background: white;
}

/* Ensure proper text styling in editor */
.template-element h1,
.template-element h2,
.template-element h3,
.template-element h4,
.template-element h5,
.template-element h6 {
    color: #2c3e50;
    margin: 10px 0;
}

.template-element p {
    line-height: 1.6;
    margin: 10px 0;
}

/* Element Types */
.text-element {
    min-height: 40px;
    padding: 8px;
    line-height: 1.6;
}

.heading-element {
    font-weight: bold;
    margin: 15px 0;
    color: #333;
}

.paragraph-element {
    line-height: 1.8;
    color: #495057;
}

.field-element {
    background: #e3f2fd;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9rem;
    display: inline-block;
}

.table-element {
    width: 100%;
    margin: 15px 0;
}

.table-element table {
    width: 100%;
    border-collapse: collapse;
}

.table-element th,
.table-element td {
    border: 1px solid #dee2e6;
    padding: 8px;
    text-align: left;
}

.table-element th {
    background: #f8f9fa;
    font-weight: 600;
}

.signature-element {
    margin: 30px 0;
}

.signature-line {
    border-bottom: 2px solid #333;
    width: 200px;
    margin: 20px 0 10px 0;
}

/* Properties Panel */
.properties-panel {
    width: 320px;
    background: white;
    border-left: 1px solid #dee2e6;
    padding: 20px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.properties-panel.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
}

.properties-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.properties-title {
    font-weight: 600;
    color: #333;
}

/* Property Groups */
.property-group {
    margin-bottom: 25px;
}

.property-group h5 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e9ecef;
}

.property-item {
    margin-bottom: 15px;
}

.property-item label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #6c757d;
}

.property-item input,
.property-item select,
.property-item textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.9rem;
}

.property-item input[type="color"] {
    height: 40px;
    cursor: pointer;
}

/* Collapse/Expand Buttons */
.toggle-panel {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    background: white;
    border: 1px solid #dee2e6;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.toggle-panel:hover {
    background: #f8f9fa;
}

#toggle-sidebar {
    left: -1px;
    border-radius: 0 4px 4px 0;
}

#toggle-properties {
    right: -1px;
    border-radius: 4px 0 0 4px;
}

/* Image Elements */
.image-element {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.image-element img {
    max-width: 100%;
    height: auto;
    display: block;
}

.image-element.selected {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Preview Mode */
.preview-mode .template-element {
    cursor: default;
}

.preview-mode .template-element:hover {
    border-color: transparent;
    background: none;
}

.preview-mode .drop-zone {
    border: none !important;
    background: none !important;
    min-height: 0;
}

.preview-mode .field-element {
    background: transparent;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
}

.preview-mode .page-number {
    display: none;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .editor-sidebar {
        width: 240px;
    }
    
    .properties-panel {
        width: 280px;
    }
}

@media (max-width: 1200px) {
    .template-canvas {
        transform: scale(0.8);
    }
}

@media (max-width: 992px) {
    .editor-workspace {
        flex-direction: column;
    }
    
    .editor-sidebar,
    .properties-panel {
        width: 100%;
        height: auto;
        border: none;
        border-bottom: 1px solid #dee2e6;
    }
    
    .canvas-wrapper {
        padding: 10px;
    }
    
    .template-canvas {
        transform: scale(0.6);
    }
}

/* Print Styles */
@media print {
    .editor-header,
    .editor-sidebar,
    .properties-panel,
    .canvas-toolbar {
        display: none !important;
    }
    
    .canvas-wrapper {
        padding: 0;
        background: white;
    }
    
    .template-canvas {
        transform: none !important;
        max-width: 100%;
    }
    
    .canvas-page {
        margin: 0;
        box-shadow: none;
        border: none;
        page-break-after: always;
    }
    
    .drop-zone {
        border: none !important;
        min-height: 0 !important;
    }
    
    .template-element {
        border: none !important;
        background: none !important;
        box-shadow: none !important;
    }
}

/* Contract Preview Modal */
.contract-preview-modal .modal-dialog {
    max-width: 900px;
}

.contract-preview-modal .modal-body {
    padding: 0;
    max-height: 80vh;
    overflow-y: auto;
}

.contract-preview-content {
    padding: 40px;
    background: white;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.zoom-level {
    font-size: 0.9rem;
    color: #6c757d;
    min-width: 50px;
    text-align: center;
}

/* Template Actions Dropdown */
.template-actions .dropdown-menu {
    min-width: 160px;
}

.template-actions .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
}

.template-actions .dropdown-item i {
    width: 16px;
    text-align: center;
    color: #6c757d;
}

.template-actions .dropdown-item:hover i {
    color: inherit;
}

/* Status Indicator */
.save-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #28a745;
}

.save-status i {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Error States */
.error-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 12px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* Success States */
.success-message {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 12px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* Upload Controls */
.upload-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 2;
}

.upload-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.upload-btn:hover {
    background: #0056b3;
}

/* Inline positioned elements */
.template-element.inline-positioned {
    position: relative !important;
    display: inline-block;
    cursor: default;
}

/* Free positioned elements */
.template-element.free-positioned {
    position: absolute !important;
    cursor: move;
}

/* No image state */
.image-element.no-image {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    min-width: 200px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Page Break Element */
.page-break-element {
    text-align: center;
    margin: 20px 0;
    color: #999;
    font-style: italic;
    border-top: 2px dashed #ddd;
    border-bottom: 2px dashed #ddd;
    padding: 10px;
}

/* Line Element */
.line-element {
    border: none;
    border-top: 2px solid #333;
    margin: 20px 0;
}

/* Drop zone text alignment */
.drop-zone[style*="text-align: center"] {
    text-align: center;
}

.drop-zone[style*="text-align: right"] {
    text-align: right;
}

.drop-zone[style*="text-align: left"] {
    text-align: left;
}

.drop-zone[style*="text-align: justify"] {
    text-align: justify;
}

/* Inline image alignment based on parent drop zone */
.drop-zone[style*="text-align: center"] .template-element.inline-positioned {
    margin-left: auto;
    margin-right: auto;
}

.drop-zone[style*="text-align: right"] .template-element.inline-positioned {
    margin-left: auto;
    margin-right: 0;
}

.drop-zone[style*="text-align: left"] .template-element.inline-positioned {
    margin-left: 0;
    margin-right: auto;
}

/* Image resize handles */
.image-element.resizing {
    cursor: nwse-resize !important;
}

/* Show resize indicator on hover */
.image-element:hover::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #007bff;
    cursor: nwse-resize;
    border-radius: 2px;
}

/* Canvas page overflow indicator */
.page-content.has-overflow {
    border: 2px solid #dc3545;
    box-shadow: 0 0 10px rgba(220, 53, 69, 0.3);
}

.page-overflow-indicator {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: #dc3545;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    z-index: 100;
}

.page-overflow-indicator::before {
    content: '⚠ Content overflow';
}

/* Two Column Layout */
.columns-container {
    column-count: 2;
    column-gap: 30px;
    column-rule: 1px solid #dee2e6;
    margin: 20px 0;
}

.columns-container .template-element {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 15px;
}

/* Ensure images don't break across columns */
.columns-container .image-element {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* A4 page size enforcement */
.canvas-page {
    width: 210mm !important;
    height: 297mm !important;
    max-width: 210mm !important;
    max-height: 297mm !important;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

.page-content {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

/* Preview mode - ensure A4 dimensions are maintained */
.preview-mode .canvas-page {
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
}

/* PDF Generation - ensure proper A4 sizing */
@page {
    size: A4;
    margin: 0;
}

/* Force contenteditable elements to use their inline styles */
.template-element [contenteditable="true"] {
    /* Don't override inline styles */
    font-size: inherit !important;
    line-height: inherit !important;
    font-family: inherit !important;
    color: inherit !important;
    text-align: inherit !important;
}

/* Only apply these defaults if no inline style is present */
.template-element .text-element:not([style*="font-size"]) {
    font-size: 12px;
}

.template-element .heading-element:not([style*="font-size"]) {
    font-size: 16px;
}

.template-element .paragraph-element:not([style*="font-size"]) {
    font-size: 12px;
}

/* Editor Scale Indicator - always visible */
.editor-scale-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    z-index: 100;
    pointer-events: none;
    opacity: 1;
    visibility: visible;
    display: block;
}

/* Show actual page size next to scale */
.editor-scale-indicator::after {
    content: ' (A4: 210 × 297mm)';
    opacity: 0.7;
    font-weight: normal;
}

/* Ensure scale indicator is above other elements */
.canvas-wrapper {
    position: relative;
}

/* Make canvas wrapper contain the scale indicator */
.canvas-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

/* Force display of scale in editor mode */
.template-editor-container:not(.preview-mode) .editor-scale-indicator {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Hide scale indicator in preview mode */
.preview-mode .editor-scale-indicator {
    display: none !important;
}

/* Ensure no conflicting styles hide the indicator */
.template-editor-container .editor-scale-indicator {
    position: fixed !important;
    top: 80px !important; /* Below header */
    left: 300px !important; /* After sidebar */
    z-index: 1000 !important;
}

/* Adjust position when sidebar is collapsed */
.editor-sidebar.collapsed ~ .canvas-wrapper .editor-scale-indicator,
.template-editor-container:has(.editor-sidebar.collapsed) .editor-scale-indicator {
    left: 80px !important;
}

/* Contract generation preview specific - hide overflow beyond A4 */
.preview-mode .page-content {
    overflow: hidden !important;
    max-height: calc(297mm - 80px) !important; /* A4 height minus padding */
}

/* Ensure content doesn't overflow in preview */
.preview-mode .template-element {
    max-width: 100%;
    overflow: hidden;
    word-wrap: break-word;
}

/* Hide any content that exceeds page height */
.preview-mode .canvas-page {
    overflow: hidden !important;
}

/* Visual indicator that content is cut off (for editor mode only) */
.canvas-page:not(.preview-mode) .page-content {
    position: relative;
}

/* Red line at bottom of page in editor mode if content overflows */
.page-content.overflow-warning::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #dc3545 50%, transparent 50%);
    background-size: 10px 100%;
    z-index: 100;
    animation: scroll 1s linear infinite;
}

@keyframes scroll {
    0% { background-position: 0 0; }
    100% { background-position: 10px 0; }
}

/* Ensure print preview matches A4 exactly */
@media print {
    .canvas-page {
        width: 210mm !important;
        height: 297mm !important;
        overflow: hidden !important;
        page-break-after: always;
        page-break-inside: avoid;
    }
}

/* Text Alignment Controls Visibility */
.property-item#text-align-container {
    display: block !important;
}

/* Ensure text alignment property is always visible for drop zones */
.drop-zone-properties .property-item#text-align-container {
    display: block !important;
}

/* Forced canvas dimensions for A4 */
.canvas-page {
    width: 794px !important; /* 210mm at 96dpi */
    height: 1123px !important; /* 297mm at 96dpi */
    transform-origin: top center;
}

/* Scale down for display while maintaining aspect ratio */
.template-canvas {
    transform: scale(0.9); /* Slightly smaller for better fit */
}

/* Adjust scale based on viewport */
@media (max-width: 1600px) {
    .template-canvas {
        transform: scale(0.8);
    }
}

@media (max-width: 1400px) {
    .template-canvas {
        transform: scale(0.7);
    }
}

@media (max-width: 1200px) {
    .template-canvas {
        transform: scale(0.6);
    }
}

/* Fixed template editor dimensions */
.template-editor-page {
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 auto 30px auto;
    background: white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    position: relative;
    box-sizing: border-box;
}

/* Force correct dimensions in preview */
.preview-wrapper .template-canvas,
.preview-wrapper .canvas-page {
    transform: none !important;
    width: 210mm !important;
    height: 297mm !important;
}

/* Additional styles for proper A4 rendering */
.canvas-page {
    /* Reset any conflicting styles */
    min-width: 210mm !important;
    max-width: 210mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    /* Ensure proper box model */
    box-sizing: border-box !important;
    /* Prevent any overflow */
    overflow: hidden !important;
}

/* Page content should respect page boundaries */
.page-content {
    /* A4 with standard margins */
    width: 210mm !important;
    height: 297mm !important;
    padding: 20mm !important; /* Standard ~2cm margins */
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* Preview mode specific adjustments */
.preview-mode .page-content {
    /* Ensure content stays within printable area */
    max-height: calc(297mm - 40mm) !important; /* Height minus top and bottom padding */
    overflow: hidden !important;
}

/* PDF and print specific */
@media print {
    @page {
        size: 210mm 297mm; /* Explicit A4 size */
        margin: 0;
    }
    
    .canvas-page {
        margin: 0 !important;
        page-break-after: always !important;
        page-break-inside: avoid !important;
    }
    
    .page-content {
        page-break-inside: avoid !important;
    }
}

/* Reset zoom for actual display */
.template-canvas.no-zoom {
    transform: none !important;
}

/* Template info spacing fix */
.template-info {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: nowrap; /* Prevent wrapping */
}

.template-info > * {
    flex-shrink: 0; /* Prevent items from shrinking */
}

.template-info input[type="text"] {
    min-width: 200px; /* Ensure template name has minimum width */
}

.template-info select {
    min-width: 150px; /* Ensure type selector has minimum width */
}

/* Scale indicator position adjustment */
.editor-scale-indicator {
    position: fixed !important;
    top: 90px !important; /* Below header with some spacing */
    left: 300px !important; /* Right of sidebar */
    z-index: 2000 !important; /* Above canvas toolbar */
}

/* Ensure proper z-index stacking */
.canvas-toolbar {
    z-index: 1000;
}

.editor-scale-indicator {
    z-index: 1001; /* Just above toolbar */
}

/* Colorize based on zoom level */
.editor-scale-indicator[data-zoom="100"] {
    background: rgba(40, 167, 69, 0.9); /* Green for actual size */
}

.editor-scale-indicator[data-zoom]:not([data-zoom="100"]) {
    background: rgba(0, 123, 255, 0.9); /* Blue for scaled */
}

/* Force A4 height */
.canvas-page {
    height: 1123px !important; /* 297mm at 96dpi */
    max-height: 1123px !important;
    min-height: 1123px !important;
}

/* CRITICAL: Override any min-height that might stretch the page */
.page-content {
    min-height: initial !important; /* Remove min-height */
    height: 100% !important; /* Fill parent */
    max-height: 100% !important; /* Don't exceed parent */
}

/* Ensure drop zones don't force page to expand */
.drop-zone {
    min-height: 60px; /* Reasonable minimum */
    max-height: calc(100% - 40px); /* Leave some margin */
}

/* FORCE all pages to be exactly A4 height */
.canvas-page,
.canvas-page[style] {
    height: 297mm !important;
    max-height: 297mm !important;
    min-height: 297mm !important;
}

/* Override inline styles with important */
.canvas-page[style*="height"] {
    height: 297mm !important;
}

/* Ensure page content doesn't expand beyond page */
.page-content,
.page-content[style] {
    height: 100% !important;
    max-height: 100% !important;
    min-height: unset !important; /* Remove minimum height */
    overflow: hidden !important;
}

/* Template info language selector container */
#language-selector-container {
    display: flex;
    align-items: center;
    margin-left: auto;
}

/* Visibility fix for text alignment in drop zones */
.drop-zone-text-align {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Template editor workspace responsiveness */
.editor-workspace {
    height: 100%;
    min-height: 0; /* Allow shrinking */
}

/* Canvas wrapper should be scrollable */
.canvas-wrapper {
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
}

/* Color input styling fix */
input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 100%;
    height: 40px;
    border-radius: 4px;
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

/* Default text color for editor */
.template-element [contenteditable="true"] {
    color: #000000;
}

/* Default heading sizes in preview mode - can be overridden by inline styles */
.preview-mode .canvas-page h1:not([style*="font-size"]) { font-size: 16px; }
.preview-mode .canvas-page h2:not([style*="font-size"]) { font-size: 14px; }
.preview-mode .canvas-page h3:not([style*="font-size"]) { font-size: 12px; }
.preview-mode .canvas-page h4:not([style*="font-size"]), .preview-mode .canvas-page h5:not([style*="font-size"]), .preview-mode .canvas-page h6:not([style*="font-size"]) { font-size: 11px; }

/* Visual indicator for content overflow in preview */
.preview-mode .page-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: red;
    display: none;
}

.preview-mode .page-content.overflow::after {
    display: block;
}

/* Text overflow handling */
.template-element {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Prevent images from breaking layout */
.template-element img {
    max-width: 100%;
    height: auto;
}

/* Ensure tables don't overflow */
.template-element table {
    table-layout: fixed;
    width: 100%;
}

/* Column-specific text width control */
.template-element.in-column {
    max-width: 100%;
    padding-right: 5px;
    padding-left: 5px;
}

/* Responsive column adjustment */
@media screen and (max-width: 1200px) {
    .columns-container {
        column-count: 1;
    }
}

/* Print-specific styles */
@media print {
    @page {
        size: A4;
        margin: 0;
    }
    
    body {
        margin: 0;
    }
    
    .canvas-wrapper {
        padding: 0;
    }
    
    .template-canvas {
        transform: none !important;
        padding: 0;
    }
    
    .canvas-page {
        width: 210mm !important;
        height: 297mm !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        page-break-after: always;
        page-break-inside: avoid;
    }
    
    .canvas-page:last-child {
        page-break-after: auto;
    }
    
    .page-content {
        padding: 10mm 10mm 10mm 10mm !important; /* Reduced padding for better space usage */
    }
    
    .page-number {
        display: none;
    }
    
    .columns-container {
        column-count: 2;
        column-gap: 25px;
    }
    
    /* Hide editor UI elements */
    .editor-header,
    .editor-sidebar,
    .properties-panel,
    .canvas-toolbar {
        display: none !important;
    }
}

/* ================================================
   LANGUAGE SELECTOR STYLES
   ================================================ */

/* Language Selector Container */
.language-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.language-selector-label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #666;
    font-weight: 500;
    margin: 0;
    white-space: nowrap;
}

.language-selector-label i {
    color: #2196F3;
    font-size: 16px;
}

/* Language Selector Dropdown */
.language-selector-dropdown {
    position: relative;
    display: flex;
    align-items: center;
}

.language-selector-dropdown select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    min-width: 150px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.language-selector-dropdown select:hover {
    border-color: #2196F3;
}

.language-selector-dropdown select:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* Language Flag Indicator */
.language-flag {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 14px;
    border-radius: 2px;
    background-size: cover;
    background-position: center;
    pointer-events: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.language-flag.en {
    background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIwMCIgaGVpZ2h0PSI2MDAiIHZpZXdCb3g9IjAgMCAxMjAwIDYwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGRlZnM+CjxjbGlwUGF0aCBpZD0idCI+CjxwYXRoIGQ9Im0wLDB2MzAwaDEyMDB2MzAweiIvPgo8L2NsaXBQYXRoPgo8L2RlZnM+CjxwYXRoIGZpbGw9IiNiMjIyMzQiIGQ9Im0wLDB2NjAwaDEyMDB2LTYwMHoiLz4KPHBhdGggZmlsbD0iI2ZmZiIgZD0ibTAsNzV2MTUwaDEyMDB2LTE1MHptMCwzMDB2MTUwaDEyMDB2LTE1MHoiLz4KPHBhdGggZmlsbD0iIzNjM2I2ZSIgZD0ibTAsNjBoNjAwdjI0MGgtNjAweiIvPgo8L3N2Zz4=');
}

.language-flag.ro {
    background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAwIiBoZWlnaHQ9IjQwMCIgdmlld0JveD0iMCAwIDYwMCA0MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIyMDAiIGhlaWdodD0iNDAwIiBmaWxsPSIjMDAyOGEzIi8+CjxyZWN0IHg9IjIwMCIgd2lkdGg9IjIwMCIgaGVpZ2h0PSI0MDAiIGZpbGw9IiNmZmQ5MDAiLz4KPHJlY3QgeD0iNDAwIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjQwMCIgZmlsbD0iI2NlMTEyNiIvPgo8L3N2Zz4=');
}

/* Compact Language Selector */
.compact-language-selector {
    padding: 0;
}

.compact-language-selector .language-selector-dropdown select {
    padding: 4px 8px;
    font-size: 12px;
    min-width: 120px;
}

.compact-language-selector .language-flag {
    right: 6px;
    width: 16px;
    height: 11px;
}

/* Full Language Selector */
.full-language-selector {
    padding: 10px 0;
}

/* Language Change Notification */
.language-change-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    background: #4CAF50;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 300px;
}

.language-change-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.language-change-notification .notification-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.language-change-notification .notification-content i {
    font-size: 16px;
}

/* Language Selector in Header */
.editor-header .language-selector {
    margin-left: auto;
    margin-right: 20px;
}

.editor-header .language-selector-label {
    color: #555;
    font-size: 13px;
}

.editor-header .language-selector-dropdown select {
    padding: 5px 10px;
    font-size: 13px;
    border: 1px solid #ccc;
    min-width: 140px;
}

/* Language Selector in Template Info Section */
.template-info .language-selector-container {
    margin-left: auto;
}

.template-info .language-selector {
    gap: 6px;
    font-size: 12px;
}

.template-info .language-selector-label {
    color: #666;
    font-size: 12px;
    white-space: nowrap;
}

.template-info .language-selector-dropdown select {
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid #ddd;
    min-width: 120px;
    height: 32px;
}

.template-info .language-flag {
    right: 6px;
    width: 16px;
    height: 11px;
}

/* Fix template-info layout to accommodate language selector */
.template-info {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.template-info .language-selector-container {
    flex-shrink: 0;
}

/* Ensure template name input and type select have proper sizing */
.template-name-input {
    flex: 1;
    min-width: 200px;
}

.template-type-select {
    flex-shrink: 0;
    min-width: 140px;
}

/* Responsive adjustments for template info */
@media (max-width: 768px) {
    .template-info {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .template-info .language-selector-container {
        margin-left: 0;
        align-self: flex-end;
    }
}

/* Language Selector in Settings */
.settings-language-selector {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    margin: 10px 0;
}

.settings-language-selector .language-selector-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.settings-language-selector .language-selector-dropdown select {
    width: 100%;
    max-width: 250px;
    padding: 8px 12px;
    font-size: 15px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .language-selector-label {
        display: none;
    }
    
    .language-selector-dropdown select {
        min-width: 100px;
        font-size: 12px;
    }
    
    .editor-header .language-selector {
        margin-right: 10px;
    }
    
    .language-change-notification {
        right: 10px;
        max-width: 250px;
        font-size: 13px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .language-selector-dropdown select {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .language-selector-dropdown select:hover {
        border-color: #4299e1;
    }
    
    .language-selector-dropdown select:focus {
        border-color: #4299e1;
        box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.2);
    }
    
    .language-selector-label {
        color: #a0aec0;
    }
    
    .settings-language-selector {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .settings-language-selector .language-selector-label {
        color: #e2e8f0;
    }
}

/* Page Tabs */
.page-tabs-container {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    padding: 0;
    margin: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-tabs {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
    overflow-x: auto;
    min-height: 48px;
}

.page-tab {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
    position: relative;
    user-select: none;
}

.page-tab:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.page-tab.active {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

.page-tab-number {
    font-weight: bold;
    margin-right: 8px;
    font-size: 14px;
}

.page-tab-label {
    font-size: 13px;
    flex: 1;
}

.page-tab-drag-handle {
    margin-left: 8px;
    cursor: move;
    opacity: 0.6;
}

.page-tab-drag-handle:hover {
    opacity: 1;
}

/* Reorder mode styles */
.page-tabs.reorder-mode .page-tab {
    cursor: move;
    border-style: dashed;
}

.page-tab-ghost {
    opacity: 0.4;
}

.page-tab-chosen {
    background: #e3f2fd !important;
    border-color: #2196f3 !important;
}

.page-tab-drag {
    opacity: 0;
}

/* Reorder button active state */
.btn.active {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
}

/* Fix delete button visibility */
.delete-element-btn {
    background-color: #dc3545 !important;
    color: white !important;
    border: 1px solid #dc3545 !important;
}

.delete-element-btn:hover {
    background-color: #c82333 !important;
    border-color: #bd2130 !important;
}



/* Image resize handles for better visibility */
.template-element.free-positioned {
    position: absolute \!important;
}

.template-element.free-positioned .image-element {
    position: relative \!important;
    width: 100% \!important;
    height: 100% \!important;
}

.template-element.free-positioned .image-element img {
    width: 100% \!important;
    height: 100% \!important;
    object-fit: contain \!important;
}

/* Add resize handle visual indicator */
.template-element.selected::after {
    content: '';
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 15px;
    height: 15px;
    background-color: #007bff;
    border: 2px solid white;
    cursor: nw-resize;
    z-index: 100;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Add move handle visual indicator */
.template-element.selected::before {
    content: '⋮⋮';
    position: absolute;
    top: -5px;
    right: -5px;
    width: 25px;
    height: 25px;
    background-color: #007bff;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: move;
    z-index: 100;
    border-radius: 4px;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Highlight selected image container */
.template-element.selected {
    outline: 2px solid #007bff \!important;
    outline-offset: 2px;
}

/* Make the entire image container the resize/drag target for free positioned images */
.template-element.free-positioned.selected {
    cursor: move;
}

.template-element.free-positioned.selected:hover {
    outline: 2px solid #0056b3 \!important;
}

/* Remove pointer events from inner elements during drag/resize */
.template-element.resizing * {
    pointer-events: none \!important;
}

/* Delete button visibility fix */
.delete-element-btn {
    background-color: #dc3545 !important;
    color: white !important;
    border: 1px solid #dc3545 !important;
}

/* Image element states */
.image-element {
    position: relative;
    width: 100%;
    height: 100%;
    /* Checkered background for transparency */
    background-image: 
        linear-gradient(45deg, #e9ecef 25%, transparent 25%), 
        linear-gradient(-45deg, #e9ecef 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #e9ecef 75%), 
        linear-gradient(-45deg, transparent 75%, #e9ecef 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.image-element.no-image {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}

.image-element.no-image img {
    opacity: 0.5;
}

.image-element:not(.no-image) .upload-controls {
    display: none !important;
}

/* Upload controls positioning */
.upload-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

/* Ensure images are interactive when selected */
.template-element.selected .image-element {
    cursor: move;
}

/* Hide upload button when image is loaded */
.image-element:not(.no-image) .upload-btn {
    display: none !important;
}

/* Ensure images preserve transparency */
.image-element img {
    background: transparent;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Template element background for free positioned images */
.template-element.free-positioned {
    background: transparent;
}

/* Optional: Add subtle shadow to make transparent images more visible */
.template-element.free-positioned .image-element img {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* Performance optimization during drag */
.template-element.dragging {
    will-change: transform, left, top;
    transition: none !important;
}

.template-element.dragging * {
    pointer-events: none !important;
}

/* Smooth transitions when not dragging */
.template-element:not(.dragging) {
    transition: box-shadow 0.2s ease;
}

/* Visual feedback during drag */
.template-element.dragging {
    opacity: 0.9;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

/* Scrolling fixes for contract editor */
.editor-canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for nested flex containers */
}

/* Ensure canvas wrapper fills space and scrolls properly */
.template-editor .canvas-wrapper {
    flex: 1;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: auto !important;
}

/* Additional bottom spacing for last page */
.template-editor .template-canvas::after {
    content: '';
    display: block;
    height: 100px;
    width: 100%;
}

