/* Form Sections and Labels */

/* Form Header */
.form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.form-header h1 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    align-items: center;
}

.pdf-upload-wrap {
    position: relative;
    display: inline-flex;
}

/* Form Sections */
.form-section {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
}

.form-section:last-of-type {
    border-bottom: none;
}

/* Separator between Settings and Payment sections */
.form-section-separator {
    margin: var(--spacing-md) 0;
    border: none;
    border-top: 1px solid var(--border-light);
    background: none;
}

.form-section h2 {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--spacing-sm);
}

.form-section--compact {
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.form-section--inline {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    flex-wrap: wrap;
}

.form-section--inline > label,
.form-section--inline > h2 {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 5rem;
    margin: 0;
    height: var(--input-height);
    line-height: var(--input-height);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.form-section--accent {
    background: var(--primary-subtle);
    margin: var(--spacing-sm) calc(-1 * var(--spacing-lg));
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: none;
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.section-header h2 {
    margin-bottom: 0;
}

.section-header-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.section-header h2,
.form-section h2,
.party-block h2 {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-2);
}

/* Editable Section Titles */
.section-title-input {
    font-size: var(--font-size-xs) !important;
    font-weight: 600 !important;
    color: var(--primary) !important;
    text-transform: none !important; /* Case insensitive - user can type any case */
    letter-spacing: 0.04em;
    border: 1px solid var(--border) !important;
    background: var(--bg) !important;
    padding: 0 var(--space-1) !important;
    margin: 0;
    width: auto;
    min-width: 5rem;
    margin-bottom: var(--space-2);
    height: auto !important;
    border-radius: var(--radius-sm);
}

.section-title-input:focus {
    outline: none;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 2px var(--primary-subtle);
}

/* Form Groups */
.form-group {
    margin-bottom: calc(var(--spacing-sm) * 0.75);
    min-width: 0;
}

.form-group label {
    display: flex;
    align-items: center;
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: var(--spacing-xs);
    line-height: 1.4;
}

/* Settings Sections - Flow like text, wrap naturally */
.settings-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    margin-bottom: var(--space-2);
}

/* Label is just another inline element */
.settings-section > label {
    flex-shrink: 0;
    margin: 0;
    white-space: nowrap;
}

/* Settings row uses display: contents to let children flow inline naturally */
.settings-section .settings-row {
    display: contents;
}

/* Options wrap also uses display: contents for true inline flow */
.settings-section .settings-options-wrap {
    display: contents !important;
}

/* Segmented control in settings flows inline */
.settings-row > .segmented-control {
    flex-shrink: 0;
}

/* Inputs and toggles in settings sections should flow inline, not stack */
.settings-section input:not([type="hidden"]),
.settings-section .toggle-switch-label {
    width: auto !important;
    display: inline-flex !important;
    flex-shrink: 0;
}

/* Compact inputs for rate/amount values (VAT rate, discount, shipping cost) */
/* High specificity to override .settings-section input:not([type="hidden"]) width: auto !important */
.settings-section input.global-rate-input {
    width: 3.5rem !important;
    height: var(--input-height);
    padding: 0 var(--space-1);
    font-size: var(--font-size-sm);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    margin-right: var(--space-1);
}

.settings-section input.global-rate-input:focus {
    outline: none;
    border-color: var(--primary);
}

.settings-section .shipping-notes-textarea {
    width: 100%;
    margin-top: var(--space-2);
    padding: var(--space-2);
    font-size: var(--font-size-sm);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    resize: none; /* Disable resize handle */
    min-height: 60px;
}

.settings-section .shipping-notes-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* Toggle Switch */
.toggle-switch-label {
    display: flex !important;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    position: relative;
}

.toggle-switch-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.toggle-switch {
    position: relative;
    width: 32px;
    height: 18px;
    background: var(--border);
    border-radius: 9px;
    transition: background 0.2s ease;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--bg);
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.toggle-switch-label input[type="checkbox"]:checked + .toggle-switch {
    background: var(--primary);
}

.toggle-switch-label input[type="checkbox"]:checked + .toggle-switch::after {
    transform: translateX(14px);
}

/* Disabled toggle state */
.toggle-switch-label:has(input[type="checkbox"]:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle-switch-label input[type="checkbox"]:disabled + .toggle-switch {
    background: var(--border);
    cursor: not-allowed;
}

/* Form Footer */
.form-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-top: var(--spacing-md);
    border-top: 1px solid var(--border-light);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.footer-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
}

.footer-row--primary {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--spacing-md);
}

.footer-row--primary .footer-feedback:first-child {
    justify-self: end;
}

.footer-row--primary .footer-donate-group {
    justify-self: center;
    display: flex;
    gap: var(--space-2);
}

.footer-row--primary .footer-feedback:last-child {
    justify-self: start;
}

.footer-row--secondary {
    flex-wrap: wrap;
}

.footer-credit {
    color: var(--text-light);
}

.footer-donate-btn {
    width: auto;
    min-width: fit-content;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-4);
    font-size: var(--font-size-xs);
    font-weight: 500;
    text-decoration: none;
    color: white;
    background: #e57373;
    border: none;
    border-radius: var(--radius);
    transition: background-color 0.2s ease, box-shadow 0.15s ease;
    cursor: pointer;
    white-space: nowrap;
}

.footer-donate-btn:hover {
    background: #ef5350;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.footer-donate-btn:active {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.footer-trustpilot-btn {
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-4);
    background: #00b67a;
    border-radius: var(--radius);
    transition: background-color 0.2s ease, box-shadow 0.15s ease;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
}

.footer-trustpilot-btn a {
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: white;
    text-decoration: none;
    line-height: 28px;
}

.footer-trustpilot-btn:hover {
    background: #00a06a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.footer-trustpilot-btn:active {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Legacy footer-donate class (in case it's used elsewhere) */
.footer-donate {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
    padding: var(--space-1) var(--space-3);
    background: var(--primary-subtle);
    border-radius: var(--radius-sm);
    transition: background-color 0.15s, color 0.15s; /* Specific properties only */
}

.footer-donate:hover {
    background: var(--primary);
    color: white;
}

.footer-feedback {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.footer-feedback:hover {
    color: var(--primary);
}

/* Export Section */
.form-export-section {
    padding: var(--spacing-lg) var(--spacing-md);
    border-top: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Due Date Custom Field */
.due-date-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.due-date-container .segmented-control {
    flex-shrink: 0;
}

.due-date-custom {
    flex: 1 1 auto;
    min-width: 120px;
    max-width: 180px;
    display: none;
}

/* Show date input when "other" option is selected */
.due-date-container:has(#due-other:checked) .due-date-custom {
    display: block;
}

.due-date-custom.show {
    display: block;
}

/* PDF Styling Section - Flowing Layout */
.form-section--pdf-styling {
    /* Remove bottom border for cleaner look */
}

.pdf-controls-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-3);
    row-gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.pdf-control-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-xs);
    flex-shrink: 0;
}

.pdf-control-item--full-width {
    width: 100%;
    flex-basis: 100%;
    margin-top: var(--space-2);
}

.pdf-control-item > label {
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--text-muted);
    margin: 0;
    white-space: nowrap;
}

/* Paper size control */
.pdf-control-item--paper-size {
}

.pdf-control-item-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: nowrap;
}

/* Segmented controls in PDF section should be inline */
.pdf-control-item .segmented-control {
    display: inline-flex;
}

/* Style Picker Buttons - Auto Width */
.btn-style-picker {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    width: auto;
    height: var(--input-height);
    padding: 0 var(--space-2);
    font-size: var(--font-size-sm);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease; /* Specific properties only */
    white-space: nowrap;
}

.btn-style-picker:hover {
    border-color: var(--primary);
    background: var(--bg-muted);
}

.btn-style-picker.active {
    border-color: var(--primary);
    background: var(--primary-subtle);
}

.btn-style-picker .template-icon,
.btn-style-picker .layout-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-style-picker .template-icon svg {
    width: 14px;
    height: 14px;
}

.btn-style-picker .picker-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-style-picker .font-preview {
    font-size: 1rem;
    font-weight: 500;
}

.btn-style-picker .color-preview {
    display: flex;
    gap: 2px;
}

.btn-style-picker .color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
}


/* Style Picker Dropdowns (reuse from preview.css) */
.style-picker-dropdown {
    position: fixed;
    display: none;
    z-index: 2000;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    max-width: 320px;
    max-height: 400px;
    overflow-y: auto;
}

.picker-dropdown-header {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-light);
}

.picker-options {
    padding: var(--space-1);
}

.picker-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

.picker-option:hover {
    background: var(--bg-muted);
}

.picker-option.selected {
    background: var(--primary-subtle);
}

.picker-option-preview {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.picker-option-info {
    flex: 1;
    min-width: 0;
}

.picker-option-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text);
}

.picker-option-desc {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.picker-option-check {
    opacity: 0;
    color: var(--primary);
    font-size: 1rem;
    transition: opacity 0.15s ease;
}

.picker-option.selected .picker-option-check {
    opacity: 1;
}

/* Color palette specific styles */
.color-palette-preview {
    display: flex;
    gap: 2px;
    align-items: center;
}

.color-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.picker-option--color {
    padding: var(--space-2) var(--space-3);
}

.color-palette-swatches {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-right: var(--space-2);
}

.color-palette-swatches .color-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.color-palette-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.color-palette-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text);
}

.color-palette-desc {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Font Option Preview */
.font-opt-preview {
    font-size: 1.25rem;
    font-weight: 500;
    width: 32px;
    height: 32px;
}

.font-opt-preview[data-family="helvetica"],
.font-opt-preview[data-family="arial"] {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica", sans-serif;
}

.font-opt-preview[data-family="times"] {
    font-family: "Times New Roman", Times, serif;
}

.font-opt-preview[data-family="courier"] {
    font-family: "Courier New", Courier, monospace;
}

/* Color Option Preview */
.color-opt-preview {
    display: flex;
    gap: 3px;
}

.color-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--border-light);
}

.color-swatch-bg {
    opacity: 0.5;
}

/* Element Option Preview */
.element-opt-preview {
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
}

/* Layout Dropdown */
.layout-dropdown {
    position: fixed;
    display: none;
    z-index: 1000;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    max-width: 360px;
    max-height: 500px;
    overflow-y: auto;
    padding: var(--space-2);
}

.layout-dropdown-header {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: var(--space-2);
    border-bottom: 1px solid var(--border-light);
    margin: calc(-1 * var(--space-2)) calc(-1 * var(--space-2)) var(--space-2);
}

.layout-module {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-light);
}

.layout-module:last-child {
    border-bottom: none;
}

.layout-module > label {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--text);
    margin-bottom: var(--space-1);
}

.layout-module .segmented-control {
    width: 100%;
}

/* Highlighted Section (for invoice-type specific emphasis) */
.settings-section--highlighted {
    background: var(--primary-subtle);
    padding: var(--space-2) var(--space-3);
    margin: var(--space-2) calc(-1 * var(--space-3));
    border-radius: var(--radius);
    border: 1px solid var(--primary);
    animation: highlight-pulse 0.3s ease;
}

@keyframes highlight-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 var(--primary);
    }
    50% {
        transform: scale(1.01);
        box-shadow: 0 0 0 4px var(--primary-subtle);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 transparent;
    }
}

/* Badge for required/important sections */
.badge-required {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    margin-left: var(--space-1);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    vertical-align: middle;
}

/* Type-specific field styling */
/* Removed blue highlight styling - fields should use default styling */
.field--quote-validity input:focus,
.field--credit-ref input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

/* Conditional field animations */
.field--quote-validity,
.field--credit-ref,
.field--quote-note,
.field--proforma-note {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


