/* --- CSS Custom Properties --- */
:root {
    /* Color Palette */
    --color-primary: #294b6a;
    --color-primary-dark: #1a2f42;
    --color-primary-light: rgba(41, 75, 106, 0.1);
    --color-primary-lighter: rgba(41, 75, 106, 0.05);
    
    --color-success: #16a34a;
    --color-success-dark: #15803d;
    
    --color-text-primary: #374151;
    --color-text-secondary: #4b5563;
    --color-text-muted: #6b7280;
    --color-text-light: #9ca3af;
    --color-text-dark: #1f2937;
    
    --color-background: #fff;
    --color-background-gray: #f9fafb;
    --color-background-light: #f3f4f6;
    
    --color-border: #e5e7eb;
    --color-border-light: #e2e8f0;
    --color-border-muted: #cbd5e1;
    --color-border-gray: #d1d5db;
    --color-border-dark: #9ca3af;
    --color-border-subtle: #eff2f5; /* New variable for subtle borders */
    
    --color-shadow: rgba(0, 0, 0, 0.12);
    --color-shadow-light: rgba(0, 0, 0, 0.15);
    --color-shadow-primary: rgba(41, 75, 106, 0.1);
    --color-shadow-primary-light: rgba(41, 75, 106, 0.15);
    --color-shadow-focus: rgba(41, 75, 106, 0.2);

    /* Spacing Scale */
    --space-xs: 0.25rem;    /* 4px */
    --space-sm: 0.5rem;     /* 8px */
    --space-md: 0.75rem;    /* 12px */
    --space-lg: 1rem;       /* 16px */
    --space-xl: 1.25rem;    /* 20px */
    --space-2xl: 1.5rem;    /* 24px */
    --space-3xl: 2rem;      /* 32px */
    --space-4xl: 3rem;      /* 48px */
    --space-5xl: 4rem;      /* 64px */
    
    /* Font Sizes */
    --text-xs: 0.75rem;     /* 12px */
    --text-sm: 0.875rem;    /* 14px */
    --text-base: 1rem;      /* 16px */
    --text-lg: 1.125rem;    /* 18px */
    --text-xl: 1.25rem;     /* 20px */
    --text-2xl: 1.5rem;     /* 24px */
    --text-3xl: 1.875rem;   /* 30px */
    --text-4xl: 2.25rem;    /* 36px */
    
    /* Border Radius Scale */
    --radius-sm: 0.25rem;   /* 4px */
    --radius-md: 0.375rem;  /* 6px */
    --radius-lg: 0.5rem;    /* 8px */
    --radius-xl: 0.75rem;   /* 12px */
    --radius-2xl: 1rem;     /* 16px */
    --radius-3xl: 1.5rem;   /* 24px */
    --radius-full: 9999px;  /* Fully rounded */
    
    /* Line Heights */
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    
    /* Letter Spacing */
    --tracking-wide: 0.025em;
    --tracking-normal: 0em; /* New variable for normal letter spacing */
    
    /* Shadows */
    --shadow-sm: 0 2px 8px var(--color-shadow-primary);
    --shadow-md: 0 4px 12px var(--color-shadow-light);
    --shadow-lg: 0 8px 30px var(--color-shadow);
    --shadow-focus: 0 0 0 2px var(--color-shadow-focus);
    
    /* Transitions */
    --transition-fast: 0.2s ease-in-out;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.3s ease-in-out;
}

/* --- Base Styles --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

.form-wrapper {
    background-color: var(--color-background-light);
    padding-top: var(--space-4xl);
    padding-bottom: var(--space-4xl);
}

.form-container {
    width: 85%;
    min-width: 800px;
    max-width: 1400px;
    margin: var(--space-3xl) auto;
    background: var(--color-background); /* A solid, clean background */
    padding: clamp(var(--space-2xl), 4vw, var(--space-4xl));
    border-radius: var(--radius-3xl);
    box-shadow: 
      0 1.8px 2.2px rgba(0, 0, 0, 0.02),
      0 4.3px 5.3px rgba(0, 0, 0, 0.028),
      0 8.1px 10px rgba(0, 0, 0, 0.035),
      0 14.5px 17.9px rgba(0, 0, 0, 0.042),
      0 27.2px 33.4px rgba(0, 0, 0, 0.05),
      0 65px 80px rgba(0, 0, 0, 0.07);
    border: 1px solid var(--color-border-subtle);
    position: relative;
    overflow: hidden;
}

@media (max-width: 768px) {
    .form-container {
        width: 95%;
        min-width: 0;
        margin: var(--space-5xl) auto var(--space-3xl) auto;
        padding: var(--space-xl);
    }
}

.form-header {
    margin-block-end: var(--space-4xl);
    text-align: start; /* Ensures alignment works for both LTR and RTL */
}

.form-title-text {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--color-text-dark);
    margin-bottom: var(--space-md);
}

.form-description {
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
    margin-block-start: var(--space-xs);
}

.form-label {
    display: block;
    color: var(--color-text-dark);
    font-weight: 700;
    font-size: var(--text-lg);
    margin-bottom: var(--space-md);
    letter-spacing: var(--tracking-normal); /* Reduce letter spacing for better readability */
    text-align: start;
    line-height: var(--leading-relaxed);
}

.form-label-container {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-md);
}

.form-field-indicator {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.form-label-description {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    font-weight: 400;
    margin-top: calc(-1 * var(--space-sm));
    margin-bottom: var(--space-md);
    line-height: var(--leading-normal);
    text-align: start;
}

/* --- Base Form Field Class --- */
.form-field {
    width: 100%;
    padding: var(--space-lg) var(--space-xl);
    font-size: var(--text-base);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-xl);
    color: var(--color-text-primary);
    transition: all var(--transition-normal);
    letter-spacing: var(--tracking-normal);
    background-color: var(--color-background);
    outline: none;
    text-align: start;
    line-height: var(--leading-normal);
    box-sizing: border-box; /* Add this line */
}

.form-field::placeholder {
    color: var(--color-text-light);
}

.form-field:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

/* --- Wrapper for custom select styling --- */
.form-select-wrapper {
    position: relative;
    width: 100%;
}

.form-field-hidden {
    display: none;
}

.form-select-display {
    width: 100%;
    padding-block: var(--space-lg);
    padding-inline-start: var(--space-xl);
    padding-inline-end: var(--space-4xl);
    font-size: var(--text-base);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-xl);
    color: var(--color-text-primary);
    transition: all var(--transition-normal);
    background-color: var(--color-background);
    cursor: pointer;
    user-select: none;
    text-align: start;
    box-sizing: border-box; /* Add this line */
}

.form-select-wrapper.is-open .form-select-display {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

.form-select-options {
    position: absolute;
    top: calc(100% + var(--space-sm));
    left: 0;
    right: 0;
    background-color: var(--color-background);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    list-style: none;
    padding: var(--space-sm);
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    opacity: 0;
    transform: translateY(-10px);
    visibility: hidden;
    transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
}

.form-select-wrapper.is-open .form-select-options {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.form-select-option {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: background-color var(--transition-fast);
    text-align: start;
}

.form-select-option:hover {
    background-color: var(--color-primary-light);
}

.form-select-option.is-selected {
    background-color: var(--color-primary);
    color: var(--color-background);
    font-weight: 500;
}

.form-select-icon {
    position: absolute;
    top: 50%;
    inset-inline-end: var(--space-lg);
    transform: translateY(-50%);
    font-size: var(--text-xl);
    color: var(--color-text-light);
    pointer-events: none; /* Allows clicks to pass through to the select element */
    transition: color var(--transition-normal), transform var(--transition-fast);
}

.form-select-wrapper.is-open .form-select-icon {
    transform: translateY(-50%) rotate(180deg);
}

/* Darken the icon on focus to match the border */
.form-select-wrapper.is-open .form-select-icon {
    color: var(--color-primary);
}

/* --- Searchable & Creatable Field --- */
.searchable-creatable-wrapper {
    position: relative;
    width: 100%;
}

.searchable-creatable-hidden-input {
    display: none;
}

.searchable-creatable-wrapper .form-field {
    padding-inline-end: var(--space-4xl); /* Make space for the icon */
}

.searchable-creatable-options {
    /* Uses the same styles as .form-select-options */
    position: absolute;
    top: calc(100% + var(--space-sm));
    left: 0;
    right: 0;
    background-color: var(--color-background);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    list-style: none;
    padding: var(--space-sm);
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none; /* Hidden by default, JS will manage visibility */
}

.searchable-creatable-wrapper.is-open .searchable-creatable-options {
    display: block;
}

.searchable-creatable-options li {
    /* Uses the same styles as .form-select-option */
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: background-color var(--transition-fast);
    text-align: start;
}

.searchable-creatable-options li:hover,
.searchable-creatable-options li.is-highlighted {
    background-color: var(--color-primary-light);
}

.searchable-creatable-options li.create-new-option {
    font-style: italic;
    color: var(--color-primary);
}


/* --- Specific Form Field Types --- */

.form-radio {
    width: var(--space-lg);
    height: var(--space-lg);
    color: var(--color-primary);
    background-color: var(--color-background-light);
    border-color: var(--color-border-gray);
    padding: 0;
    border-radius: var(--radius-full);
}

.form-radio:focus {
    --tw-ring-color: var(--color-primary);
    --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
    --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
    box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
}

.form-section {
    background-color: var(--color-background);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-2xl);
    padding: var(--space-3xl);
    margin-bottom: var(--space-3xl);
    box-shadow: 0 4px 12px var(--color-shadow-primary-light);
    transition: all var(--transition-normal);
}

.form-section-header {
    margin-bottom: var(--space-2xl);
}

.form-section-title {
    font-size: var(--text-2xl);
    font-weight: 600;
    color: var(--color-text-dark);
    display: flex;
    align-items: center;
    margin-bottom: var(--space-lg);
    text-align: start; /* Ensures alignment works for both LTR and RTL */
}

.form-section-description {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-2xl);
}

.form-prompt-label {
    font-size: var(--text-lg);
    font-weight: 500;
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--space-sm);
}

/* --- Grid System --- */
.form-grid {
    display: grid;
    gap: var(--space-2xl);
}

/* --- Checkbox Style --- */
.form-checkbox-group {
    position: relative;
    display: block;
}

.form-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.form-checkbox-label {
    display: flex;
    align-items: center;
    padding: var(--space-lg) var(--space-xl);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px solid var(--color-border-light);
    border-radius: var(--radius-2xl);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.form-checkbox-label:hover {
    border-color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.form-checkbox-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border-muted);
    border-radius: var(--radius-md);
    background: var(--color-background);
    transition: all var(--transition-normal);
    flex-shrink: 0;
    margin-inline-end: var(--space-md);
}

.form-checkbox-icon::after {
    content: "✔";
    font-size: 16px;
    color: var(--color-background);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.form-checkbox:checked + .form-checkbox-label .form-checkbox-icon {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.form-checkbox:checked + .form-checkbox-label .form-checkbox-icon::after {
    opacity: 1;
}

/* 
  Styles for checkboxes where the input is INSIDE the label.
  This is used for SelectMultipleField.
*/
.form-checkbox:checked ~ .form-checkbox-icon {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.form-checkbox:checked ~ .form-checkbox-icon::after {
    opacity: 1;
}

.form-checkbox-text {
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--color-text-primary);
    line-height: var(--leading-normal);
    user-select: none;
}

/* --- Group for multiple checkboxes --- */
.form-checkbox-multiple-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* --- Step Indicator & Progress Bar --- */
.form-step-indicator-container {
    margin-bottom: var(--space-xl);
}

.step-indicator-wrapper {
    display: flex;
    justify-content: center; /* Changed from flex-end */
    margin-bottom: var(--space-md);
}

.step-indicator {
    display: inline-flex;
    align-items: center;
    background-color: var(--color-background-gray);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-lg);
}

.step-indicator-label {
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--color-text-muted);
    margin-inline-start: var(--space-sm);
}

.step-indicator-current {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--space-2xl);
    height: var(--space-2xl);
    border-radius: var(--radius-full);
    background-color: var(--color-primary);
    color: var(--color-background);
    font-weight: 700;
    font-size: var(--text-sm);
}

.step-indicator-divider {
    margin-inline: var(--space-sm);
    color: var(--color-text-light);
}

.step-indicator-total {
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--color-text-light);
}

.progress-bar-container {
    width: 100%;
    height: var(--space-md);
    background-color: var(--color-background-light);
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 1px solid var(--color-border-subtle);

    /* --- Additions --- */
    box-sizing: border-box; /* Ensures padding is included in the element's height */
    padding: 2px; /* Creates space around the inner bar */
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    border-radius: var(--radius-full);
    box-shadow: 0 2px 6px var(--color-shadow-primary);
    transition: width var(--transition-slow), background var(--transition-slow);
}

@media (max-width: 640px) {
    .form-container {
        width: 95%;
        padding: var(--space-2xl);
    }

    .form-label {
        font-size: var(--text-base);
        margin-bottom: var(--space-sm);
    }

    .form-field,
    .form-select-display {
        padding: var(--space-md) var(--space-lg);
        font-size: var(--text-base);
    }

    .step-indicators {
        gap: var(--space-lg);
        padding: var(--space-md);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .step-indicators::-webkit-scrollbar {
        display: none;
    }

    .step-indicator-item {
        min-width: 160px;
    }

    .step-indicator-item:not(:last-child)::after {
        display: none;
    }

    .step-indicator-number {
        width: 36px;
        height: 36px;
    }

    .step-indicator-text {
        font-size: var(--text-sm);
    }
}

@media (max-width: 480px) {
    .progress-bar-container {
        height: var(--space-md);
        position: relative;
        margin-inline: auto;
    }

    .progress-bar {
        min-width: 40%;
    }
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-2xl);
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

/* Standardized hover effect for all buttons */
.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-background);
}

.btn-primary:hover {
    background-color: var(--color-primary-dark);
}

.btn-success {
    background-color: var(--color-success);
    color: var(--color-background);
}

.btn-success:hover {
    background-color: var(--color-success-dark);
}

.btn-secondary {
    background-color: var(--color-border);
    color: var(--color-text-primary);
    border-color: var(--color-border-gray);
}

.btn-secondary:hover {
    background-color: var(--color-border-gray);
    border-color: var(--color-border-dark);
}

.btn-add-item {
    display: inline-flex;
    align-items: center;
    color: var(--color-primary);
    font-weight: 500;
    transition: all var(--transition-fast);
    background-color: transparent;
    border: none;
    padding: var(--space-sm);
    cursor: pointer;
    border-radius: var(--radius-md);
}

.btn-add-item:hover {
    color: var(--color-primary-dark);
    background-color: var(--color-primary-light);
}

.btn-add-item i {
    font-size: var(--text-xl);
    margin-inline-end: var(--space-sm);
}

/* --- Icon Buttons --- */
.button-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    background-color: transparent;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--color-text-muted);
}

.button-icon:hover {
    background-color: var(--color-background-light);
    color: var(--color-text-primary);
}

.button-icon-danger {
    color: var(--color-text-muted);
}

.button-icon-danger:hover {
    background-color: #fee2e2; /* Red-100 */
    color: #b91c1c; /* Red-700 */
}

/* --- Collapsible & Summary Sections --- */
.section-container {
    margin-bottom: var(--space-4xl);
}
.section-summary {
    background-color: var(--color-background-gray);
    padding: var(--space-2xl);
    border-radius: var(--radius-2xl);
    margin-bottom: var(--space-2xl);
}
.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.summary-title-group {
    display: flex;
    align-items: center;
}
.summary-title-group i {
    color: var(--color-primary);
    font-size: var(--text-xl);
    margin-inline-end: var(--space-lg);
}
.summary-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--color-text-primary);
}
.summary-content {
    margin-top: var(--space-lg);
    color: var(--color-text-secondary);
}
.section-content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2xl);
}
.edit-section-btn, .collapse-section-btn {
    color: var(--color-primary);
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-weight: 500;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}
.edit-section-btn:hover, .collapse-section-btn:hover {
    color: var(--color-primary-dark);
    background-color: var(--color-primary-light);
    transform: translateY(-1px);
}

.edit-section-btn i, .collapse-section-btn i {
    margin-inline-end: var(--space-sm);
}

/* --- Boxed Sections --- */
.form-section-box {
    background-color: var(--color-background-gray);
    padding: var(--space-2xl);
    border-radius: var(--radius-2xl);
    border: 1px solid var(--color-border);
}

/* --- Contract Iframe --- */
.contract-iframe {
    width: 100%;
    height: 500px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
}

/* --- Radio Button Group --- */
.form-radio-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* --- Custom Radio Button Styles --- */

/* The container for each radio button, similar to the checkbox label */
.form-radio-container {
    display: flex;
    align-items: center;
    padding: var(--space-lg) var(--space-xl);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px solid var(--color-border-light);
    border-radius: var(--radius-2xl);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    position: relative; /* Needed for positioning the input */
}

.form-radio-container:hover {
    border-color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* The native input is visually hidden but still accessible */
.form-radio-container .form-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* The custom radio icon */
.form-radio-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border-muted);
    border-radius: var(--radius-full); /* Make it a circle */
    background: var(--color-background);
    transition: all var(--transition-normal);
    flex-shrink: 0;
    margin-inline-end: var(--space-md);
}

/* The inner dot of the radio button, hidden by default */
.form-radio-icon::after {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: var(--radius-full);
    background-color: var(--color-primary);
    opacity: 0;
    transition: all var(--transition-fast);
    transform: scale(0.5);
}

/* Changes when the radio button is checked */
.form-radio:checked ~ .form-radio-icon {
    border-color: var(--color-primary);
}

.form-radio:checked ~ .form-radio-icon::after {
    opacity: 1;
    transform: scale(1);
}

/* The text label for the radio button */
.form-radio-text {
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--color-text-primary);
    line-height: var(--leading-normal);
    user-select: none;
}

/* --- Section Add Button --- */
.btn-add-section {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md) var(--space-2xl);
    border: 2px solid var(--color-border-muted);
    color: var(--color-text-secondary);
    border-radius: var(--radius-xl);
    transition: all var(--transition-fast);
    background-color: transparent;
    font-weight: 500;
}

.btn-add-section:hover {
    background-color: var(--color-primary-light);
    color: var(--color-primary-dark);
    border-color: var(--color-primary);
}

.btn-add-section i {
    margin-inline-end: var(--space-sm);
}

/* --- Summary Box --- */
.form-summary-box {
    background-color: var(--color-primary-lighter);
    padding: var(--space-2xl);
    border-radius: var(--radius-xl);
    margin-top: var(--space-lg);
}

.summary-box-label {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xs);
}

.summary-box-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-primary);
}

#invoice-items-container > * + * {
    margin-top: var(--space-lg);
}

.add-item-container {
    margin-top: var(--space-lg);
    margin-bottom: var(--space-2xl);
}

/* --- Form Actions (Submit Button) --- */
.form-actions {
    margin-top: var(--space-2xl);
    display: flex;
    justify-content: flex-end;
}
.form-actions .btn {
    width: 100%;
}

@media (min-width: 768px) { /* md */
    .form-actions {
        justify-content: flex-start;
    }
    [dir="rtl"] .form-actions {
        justify-content: flex-end;
    }
    .form-actions .btn {
        width: 25%;
    }
}
@media (min-width: 1024px) { /* lg */
        .form-actions {
        margin-top: var(--space-5xl);
    }
}

@media (min-width: 1024px) {
    .form-select {
        background-position: var(--dir-bg-position-end) var(--space-lg) center;
    }
}
/* Add these styles to your existing CSS file */

/* Enhanced Error States */
.form-field-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2) !important;
}

.step-error-message {
    background-color: #fee2e2;
    color: #dc2626;
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    border: 1px solid #fecaca;
    font-weight: 500;
    display: block;
}

/* Step Indicators */
.step-indicators {
    display: flex;
    justify-content: space-between;
    gap: var(--space-2xl);
    margin-bottom: var(--space-2xl); /* More vertical space */
    padding: var(--space-lg);
    background-color: var(--color-background-gray);
    border-radius: var(--radius-2xl);
    border: 1px solid var(--color-border-subtle);
}

.step-indicator-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.step-indicator-item:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -50%;
    width: 100%;
    height: 3px; /* Make the progress line thicker */
    background-color: var(--color-border);
    z-index: 1;
    transition: background-color var(--transition-normal); /* Add smooth transition */
    transform: translateY(-50%);
}

.step-indicator-item.completed:not(:last-child)::after {
    background-color: var(--color-success); /* Use success color for completed steps */
}

[dir="rtl"] .step-indicator-item:not(:last-child)::after {
    right: auto;
    left: -50%;
}

.step-indicator-number {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background-color: var(--color-background); /* Use main background color */
    color: var(--color-text-muted);
    border: 2px solid var(--color-border); /* Add a border for default state */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    transition: all var(--transition-normal);
    z-index: 2;
    position: relative;
}

.step-indicator-item.active .step-indicator-number {
    background-color: var(--color-primary);
    color: var(--color-background);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-lighter); /* Add a 'glow' for active state */
}

.step-indicator-item.completed .step-indicator-number {
    background-color: var(--color-success);
    color: transparent; /* Hide number to show checkmark */
    border-color: var(--color-success);
    font-size: 0; /* Fallback for hiding number */
}

.step-indicator-item.completed .step-indicator-number::before {
    content: '✔';
    color: var(--color-background);
    font-size: var(--text-lg);
    font-weight: 700;
}

.step-indicator-item.completed:hover .step-indicator-number {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.step-indicator-text {
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--color-text-muted);
    text-align: center;
    transition: all var(--transition-normal);
}

.step-indicator-item.active .step-indicator-text {
    color: var(--color-primary);
    font-weight: 600;
}

.step-indicator-item.completed .step-indicator-text {
    color: var(--color-text-secondary);
}

.step-indicator-item.completed:hover .step-indicator-text {
    color: var(--color-text-primary);
}

/* Form Steps */
.form-steps-container {
    min-height: 400px;
}

.form-step {
    display: none; /* Hide steps by default */
    width: 100%;
    padding-block-start: var(--space-2xl);
    padding-block-end: var(--space-xl);
}

.form-step.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Navigation */
.form-navigation {
    display: flex;
    justify-content: flex-end; /* Default to LTR (right side) */
    align-items: center;
    gap: var(--space-md); /* Add space between the buttons */
    margin-top: var(--space-4xl);
    padding-top: var(--space-2xl);
    border-top: 1px solid var(--color-border);
}

[dir="rtl"] .form-navigation {
    justify-content: flex-start; /* For RTL, move to the left side */
}

.navigation-spacer {
    display: none; /* No longer needed */
}

/* Step Titles */
.step-title {
    margin-block-end: var(--space-4xl);
    text-align: start; /* Ensures alignment works for both LTR and RTL */
}

.step-title-text {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--color-text-dark);
    margin-bottom: var(--space-md);
}

.step-title-description {
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
    margin-block-start: var(--space-xs);
}

.form-checkbox-description {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    font-weight: 400;
    margin-top: var(--space-xs);
    line-height: var(--leading-normal);
    user-select: none;
}

/* --- Utility Classes --- */
.hidden {
    display: none;
}

.button-block-center {
    display: block;
    text-align: center;
}

.flex-grow-1 {
    flex-grow: 1;
}

.discount-note {
    font-size: 0.9em;
    color: #6c757d;
    margin-top: 5px;
}

.margin-top-15 {
    margin-top: 15px;
}

.grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.signature-box {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #ccc;
}

.button-add-dynamic {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    border: 2px dashed var(--color-border-gray);
    background-color: transparent;
    color: var(--color-text-muted);
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    margin-top: var(--space-md);
    width: 100%;
    justify-content: center;
}

.button-add-dynamic:hover {
    background-color: var(--color-background-light);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* --- Invoice Specific Styles --- */

/* Main container for a single invoice item row */
.invoice-item {
    display: flex;
    align-items: flex-start; /* Align items to the top */
    gap: var(--space-md);
    border-bottom: 1px solid var(--color-border-subtle);
    padding-bottom: var(--space-lg);
}

/* Flex container for all the input fields in a row */
.invoice-item-fields {
    flex-grow: 1;
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: var(--space-md);
}

/* Individual column wrappers for sizing */
.invoice-item-col--description {
    flex: 1 1 40%; /* Grow and shrink, with a base of 40% */
    min-width: 200px; /* Prevent it from getting too small */
}

.invoice-item-col--quantity {
    flex: 1 1 10%;
    min-width: 60px;
}

.invoice-item-col--price {
    flex: 1 1 15%;
    min-width: 100px;
}

.invoice-item-col--total {
    flex: 1 1 15%;
    min-width: 100px;
}

/* For the total field, we want to visually indicate it's read-only */
.invoice-item-col--total .form-field[readonly] {
    background-color: var(--color-background-gray);
    border-style: dashed;
    cursor: not-allowed;
    color: var(--color-text-muted);
}

/* Container for the remove button */
.invoice-item-actions {
    padding-top: calc(var(--text-lg) + var(--space-md) + var(--space-sm)); /* Align button with inputs */
}

.btn-remove-item {
    background: transparent;
    border: none;
    color: var(--color-text-light);
    cursor: pointer;
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.btn-remove-item:hover {
    color: #dc2626; /* Red on hover */
    transform: scale(1.1);
}

.button-danger-text {
    background: transparent;
    border: none;
    color: #dc2626; /* red-600 */
    cursor: pointer;
    font-weight: 500;
    text-decoration: underline;
    transition: color var(--transition-fast);
}

.button-danger-text:hover {
    color: #b91c1c; /* red-700 */
}


/* --- Invoice Totals Section --- */
.invoice-totals-container {
    margin-top: var(--space-3xl);
    padding-top: var(--space-2xl);
    border-top: 2px solid var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* Align all total rows to the right */
    gap: var(--space-lg);
}

.invoice-total-row {
    width: 100%;
    max-width: 350px; /* Constrain the width for a cleaner look */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.invoice-total-label {
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 0; /* Override default form-label margin */
}

/* Style for the grand total, making it stand out */
.invoice-total-row--grand-total {
    margin-top: var(--space-md);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

.invoice-total-row--grand-total .invoice-total-label {
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--color-text-dark);
}

.invoice-grand-total-amount {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-primary);
}

.invoice-total-row--conditional {
    width: 100%;
    max-width: 450px; /* Wider to accommodate checkbox and label */
    display: flex;
    justify-content: flex-start; /* Align checkbox to the left */
    padding-right: var(--space-lg); /* Add some padding */
    margin-bottom: var(--space-sm);
}

#discount-amount-wrapper,
#paid-amount-wrapper {
    width: 100%;
    max-width: 450px;
    padding-right: var(--space-lg);
}

/* --- Iframe with Tabs --- */
.iframe-container {
    position: relative;
    width: 100%;
    transition: all var(--transition-slow);
    padding: 0;
    margin: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

/* Adjustments for sidebar expansion */
[dir="ltr"] #iframe-main-container.sidebar-expanded {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}

[dir="rtl"] #iframe-main-container.sidebar-expanded {
    margin-right: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}

.iframe-tabs {
    display: flex;
    /* flex-direction: column; Remove this to stack horizontally */
    background-color: var(--color-background-gray);
    border-bottom: 2px solid var(--color-border);
    flex-shrink: 0;
    width: 100%;
    flex-wrap: wrap; /* Allow tabs to wrap on smaller screens */
}

.iframe-tab {
    flex-grow: 1;
    padding: 0 var(--space-lg);
    border: none;
    background-color: transparent;
    cursor: pointer;
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
    border-bottom: 3px solid transparent;
    position: relative;
    top: 2px;
}

.iframe-tab:hover {
    background-color: var(--color-background-light);
    color: var(--color-text-primary);
}

.iframe-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.iframe-content-wrapper {
    width: 100%;
    flex-grow: 1;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.iframe-content {
    width: 100%;
    height: 100%; /* Make the iframe content 50% taller than its container */
    border: none;
}

/* --- Share/Action Buttons --- */

.primary-button, .secondary-button {
    padding: 0.875rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none; /* Ensure links look like buttons */
    cursor: pointer;
    border: none;
}

.primary-button {
    background-color: #294b6a;
    color: #fff;
}

.secondary-button {
    background-color: #e7f0f7;
    color: #294b6a;
}

.primary-button:hover, .secondary-button:hover {
    opacity: 0.9;
}

.share-actions {
   display: flex;
   flex-direction: column;
   gap: 0.75rem;
}

.share-actions .primary-button,
.share-actions .secondary-button {
   width: 100%;
}

@media (min-width: 640px) {
   .share-actions {
       flex-direction: row;
       gap: 1rem;
   }
   .share-actions .primary-button,
   .share-actions .secondary-button {
       width: auto;
   }
}

/* --- Comment Thread --- */
.comment-thread {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.comment {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    background-color: var(--color-background-gray);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 1px solid var(--color-border-subtle);
}

.comment-meta {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-xs);
}

.comment-meta strong {
    color: var(--color-text-primary);
    font-weight: 600;
}

.comment-content {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    line-height: var(--leading-relaxed);
    margin: 0;
}

.comment-thread textarea.form-field {
    margin-top: var(--space-md);
}

/* --- Recipient Display Card --- */
.recipient-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: #fff;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--color-border-subtle);
    box-shadow: 0 2px 4px var(--color-shadow-primary-light);
    transition: box-shadow var(--transition-fast);
    justify-content: space-between;
}

.recipient-info {
    flex-grow: 1;
}

.recipient-status-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    flex-shrink: 0;
}

.recipient-status-time {
    font-size: 0.75rem;
    color: #718096; /* gray-500 */
}

.recipient-card:hover {
    box-shadow: 0 4px 8px var(--color-shadow-primary);
}

/* Accordion Styles */
.recipient-accordion summary {
    list-style: none; /* Remove default marker */
    cursor: pointer;
}
.recipient-accordion summary::-webkit-details-marker {
    display: none; /* Hide arrow in Chrome */
}
.recipient-summary-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-grow: 1;
}
.accordion-icon {
    margin-left: 1rem;
    transition: transform 0.2s ease-in-out;
}
.recipient-accordion[open] .accordion-icon {
    transform: rotate(180deg);
}

/* Timeline Styles */
.recipient-timeline {
    padding: 1rem;
    background-color: #f7fafc; /* gray-50 */
    border-top: 1px solid #e2e8f0; /* gray-200 */
}
.timeline-event {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    position: relative;
    padding-left: 1.5rem; /* Space for the line */
    margin-bottom: 1rem;
}
.timeline-event:last-child {
    margin-bottom: 0;
}
.timeline-icon {
    position: absolute;
    left: 0;
    top: 5px; /* Align with text */
    font-size: 0.5rem;
    color: #cbd5e0; /* gray-400 */
}
/* Vertical line for the timeline */
.timeline-event::before {
    content: '';
    position: absolute;
    left: 4px; /* Center the line */
    top: 5px;
    bottom: -5px; /* Extend line between events */
    width: 2px;
    background-color: #e2e8f0; /* gray-200 */
}
.timeline-event:last-child::before {
    display: none; /* Don't draw line after last event */
}
.timeline-content {
    display: flex;
    flex-direction: column;
}
.timeline-details {
    font-weight: 500;
    color: #2d3748; /* gray-800 */
}
.timeline-timestamp {
    font-size: 0.75rem;
    color: #718096; /* gray-500 */
}

/* Sub-events for sessions */
.sub-events {
    margin-top: 0.5rem;
    padding-left: 1rem;
    border-left: 2px solid #e2e8f0; /* gray-200 */
}
.sub-event {
    margin-bottom: 0.5rem;
}
.sub-event .timeline-details {
    font-weight: normal;
    font-size: 0.875rem;
}
.sub-event .sub-icon {
    font-size: 0.75rem;
    color: #a0aec0; /* gray-500 */
}

/* --- Dynamic Recipient Item --- */
.recipient-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}

.recipient-item .btn-remove-item {
    margin-left: 1rem;
}

.recipient-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.contract-dashboard {
    position: relative;
    z-index: 1;
}

/* --- Comments & Sharing --- */

.comment-author-avatar, .recipient-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    background: linear-gradient(to bottom right, #3b82f6, #4c77d1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    flex-shrink: 0; /* Prevent avatar from shrinking */
}

.comment-author-avatar .avatar-image, .recipient-avatar .avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.comment-thread {
    max-height: 400px;
    overflow-y: auto;
}

.comment {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    background-color: var(--color-background-gray);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 1px solid var(--color-border-subtle);
}
.comment-details {
    flex-grow: 1;
}

/* --- Iframe Responsiveness --- */
.iframe-content-wrapper {
    flex-grow: 1;
    height: calc(100vh - 50px); /* Full viewport height minus the tabs height */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.iframe-content {
    width: 100%;
    height: 100%;
    border: none;
}

/* --- Component Accordion --- */
.component-accordion {
    border: none;
    background-color: var(--color-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin: var(--space-sm);
    flex-basis: 200px; /* Give a base width */
    flex-grow: 0;
}

.accordion-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background-color: transparent;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s ease-in-out; /* Smooth transition for color change */
    position: relative;
}

.accordion-header::after {
    content: '▼';
    font-size: var(--text-xs);
    color: var(--color-text-light);
    transition: transform var(--transition-fast);
}

.component-accordion.open .accordion-header::after {
    transform: rotate(180deg);
}


.accordion-header:hover {
    background-color: var(--color-background-light);
}

.accordion-header.active {
    background-color: #e0e8f0; /* A light, non-intrusive blue */
    border-left-color: #3b82f6; /* Accent color for the active state */
}

.component-name {
    font-weight: 600;
    color: var(--color-text-primary);
}

.component-status {
    font-size: var(--text-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    background-color: var(--color-primary-lighter);
    color: var(--color-primary-dark);
}

.accordion-content {
    display: none;
    padding: var(--space-sm) var(--space-lg) var(--space-lg);
    background-color: transparent;
    border-top: 1px solid var(--color-border-subtle);
}

.component-accordion.open .accordion-content {
    display: block;
}

.accordion-content .iframe-tab {
    width: 100%;
    margin-top: var(--space-sm);
    background-color: var(--color-background-gray);
    border-radius: var(--radius-md);
    text-align: left;
}

.accordion-content .iframe-tab.active {
    background-color: var(--color-primary-light);
    color: var(--color-primary-dark);
    font-weight: 600;
}

.consultant-decision-label {
    font-size: var(--text-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    background-color: var(--color-primary);
    color: var(--color-background);
    margin-left: var(--space-sm);
    font-weight: 500;
    text-transform: capitalize;
}

.revision-snapshots {
    padding: var(--space-sm) 0;
}

/* --- Add Component Button --- */
.add-component-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border: 2px dashed var(--color-border-muted);
    border-radius: var(--radius-lg);
    background-color: transparent;
    cursor: pointer;
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
    align-self: center;
    margin: 0 var(--space-sm);
}

.add-component-btn:hover {
    color: var(--color-primary);
    background-color: var(--color-primary-light);
    border-color: var(--color-primary);
    border-style: solid;
}

/* --- Consultant Status Buttons --- */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.status-btn {
    padding: var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-background);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.status-btn:hover {
    background-color: var(--color-primary-light);
    border-color: var(--color-primary);
}

/* --- File Upload & List --- */
.upload-form {
    display: flex;
    gap: var(--space-md);
}

.file-input {
    flex-grow: 1;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm);
    background-color: var(--color-background-gray);
    border-radius: var(--radius-sm);
}

.download-btn {
    font-size: var(--text-sm);
    color: var(--color-primary);
    text-decoration: none;
}

/* --- File Uploader & Display --- */

.file-dropzone {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--space-4xl) var(--space-2xl);
    border: 2px dashed var(--color-border-muted);
    border-radius: var(--radius-2xl);
    background-color: var(--color-background-gray);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.file-dropzone:hover,
.file-dropzone.is-dragover {
    border-color: var(--color-primary);
    background-color: var(--color-primary-lighter);
}

.file-dropzone-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.file-dropzone-icon {
    font-size: var(--text-4xl);
    color: var(--color-primary);
}

.file-dropzone-text {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text-primary);
}

.file-dropzone-specs {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.file-uploader-input {
    display: none;
}

.file-upload-progress-container {
    margin-top: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.uploaded-files-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.uploaded-file-item {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-md);
    background-color: var(--color-background-gray);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-xl);
    transition: all var(--transition-fast);
}

.uploaded-file-item:hover {
    border-color: var(--color-border-muted);
    box-shadow: var(--shadow-sm);
}

.uploaded-file-icon {
    font-size: var(--text-2xl);
    color: var(--color-text-secondary);
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

.uploaded-file-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    min-width: 0; /* Prevents overflow */
}

.uploaded-file-name {
    font-weight: 600;
    color: var(--color-text-dark);
    text-decoration: none;
    transition: color var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uploaded-file-name:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.uploaded-file-size {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.uploaded-file-actions {
    flex-shrink: 0;
}

.no-files-message {
    padding: var(--space-2xl);
    text-align: center;
    color: var(--color-text-muted);
    background-color: var(--color-background-gray);
    border-radius: var(--radius-xl);
}
/* --- Component Creation Modal --- */
.modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
  padding-top: 60px;
}

.modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  max-width: 700px;
  border-radius: 8px;
  position: relative;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.close-button {
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close-button:hover,
.close-button:focus {
  color: black;
  text-decoration: none;
}

.modal-body {
  padding: 20px 16px;
}

#component-name-input {
    width: 100%;
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.modal-divider {
    margin: 20px 0;
    border: 0;
    border-top: 1px solid #eee;
}

.component-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    max-height: 40vh;
    overflow-y: auto;
    padding: 5px;
}

.component-type-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.component-type-card:hover {
    border-color: #294b6a;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.component-type-card.selected {
    border-color: #294b6a;
    background-color: #f0f5fa;
    border-width: 2px;
}

.component-type-card .card-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: #294b6a;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.component-type-card h4 {
    margin: 0 0 5px 0;
    font-size: 1rem;
    font-weight: 600;
}

.component-type-card p {
    margin: 0;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
}


.modal-footer {
  padding: 15px 16px;
  border-top: 1px solid #eee;
  text-align: right;
}

.modal-button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#submit-component-btn {
    background-color: #294b6a;
    color: white;
}

#submit-component-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#cancel-component-btn {
    background-color: #f1f1f1;
    color: black;
}

/* --- Sequence Builder --- */
.sequence-builder-container {
    margin-top: var(--space-xl);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--color-border-subtle);
}

.sequence-builder {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-xl);
    margin-top: var(--space-lg);
}

@media (min-width: 768px) {
    .sequence-builder {
        grid-template-columns: 1fr 1fr;
    }
}

.sequence-list {
    list-style: none;
    padding: var(--space-sm);
    margin: 0;
    min-height: 150px;
    background-color: var(--color-background-gray);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    max-height: 200px;
    overflow-y: auto;
}

.sequence-list--clickable .sequence-list-item {
    cursor: pointer;
}

.sequence-list--clickable .sequence-list-item:hover {
    background-color: var(--color-primary-lighter);
    border-color: var(--color-primary);
}

.sequence-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background-color: var(--color-background);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    box-shadow: var(--shadow-sm);
}

.sequence-list-item:last-child {
    margin-bottom: 0;
}

.sequence-item-name {
    font-weight: 500;
    color: var(--color-text-primary);
}

.sequence-controls {
    margin-top: var(--space-xl);
}

/* --- Iframe Header Toggle --- */
.iframe-header-toggle {
    position: absolute;
    top: 10px;
    right: 20px;
    z-index: 100;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.iframe-header-toggle:hover {
    background-color: var(--color-background-light);
    color: var(--color-primary);
    transform: translateY(-1px);
}

.iframe-header-toggle i {
    transition: transform var(--transition-fast);
}

.iframe-container.header-collapsed .iframe-header {
    display: none;
}

.iframe-container.header-collapsed .iframe-header-toggle i {
    transform: rotate(180deg);
}

.iframe-container.header-collapsed .iframe-content-wrapper {
    height: 100vh;
}

.slide-out-right {
    transform: translateX(100%);
}

.contract-selection-container {
    max-width: 900px;
    margin: 4rem auto 0 auto;
}