/* ==========================================================================
   Omni Forms design system
   Derived from 13.1-top-menu-and-form-with-validation.html.
   Loaded by the builder canvas and inlined into every exported form.
   ========================================================================== */
/* ==========================================================================
   1. CSS Variables & Reset
   ========================================================================== */
:root {
    --primary: #6366f1;       --primary-hover: #4f46e5; --primary-light: #e0e7ff;
    --bg-color: #f8fafc;      --surface: #ffffff;
    --text-main: #0f172a;     --text-muted: #64748b;
    --border: #cbd5e1;        --border-focus: #a5b4fc;
    --error: #ef4444;         --error-light: #fee2e2;
    --success: #10b981;       --warning: #f59e0b;

    --radius-md: 12px;        --radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
    --shadow-glow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    --shadow-error: 0 0 0 4px rgba(239, 68, 68, 0.15);

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }

/* ==========================================================================
   2. Animations
   ========================================================================== */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.form-section { opacity: 0; animation: fadeInUp 0.5s ease-out forwards; }
.form-section:nth-child(1) { animation-delay: 0.1s; }
.form-section:nth-child(2) { animation-delay: 0.2s; }
.form-section:nth-child(3) { animation-delay: 0.3s; }
.form-section:nth-child(4) { animation-delay: 0.4s; }
.form-section:nth-child(5) { animation-delay: 0.5s; }
.shake-animation { animation: shake 0.3s ease-in-out; }

/* ==========================================================================
   3. Layout
   ========================================================================== */
.enterprise-form-container { max-width: 1100px; margin: 0 auto; background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); border: 1px solid #e2e8f0; }
.form-header { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); color: white; padding: 40px; position: relative; overflow: hidden; border-radius: var(--radius-md) var(--radius-md) 0 0; }
.form-header::after { content: ''; position: absolute; top: -50px; right: -50px; width: 250px; height: 250px; background: linear-gradient(135deg, var(--primary), var(--primary-hover)); border-radius: 50%; opacity: 0.2; filter: blur(40px); }
.form-header h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.025em; position: relative; z-index: 1; }
.form-header p { color: #94a3b8; font-size: 1rem; position: relative; z-index: 1; }
.form-body { padding: 40px; }
.form-section { margin-bottom: 45px; }
.form-section:last-child { margin-bottom: 0; }
.form-section-title { font-size: 1.1rem; font-weight: 600; color: var(--primary); border-bottom: 2px solid var(--primary-light); padding-bottom: 12px; margin-bottom: 25px; text-transform: uppercase; letter-spacing: 0.05em; display: flex; align-items: center; gap: 10px; }

.grid-1 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; }
.grid-1-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 24px; }
@media (max-width: 960px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 768px) { .grid-2, .grid-3, .grid-4, .grid-2-1, .grid-1-2 { grid-template-columns: minmax(0, 1fr); } .form-body, .form-header { padding: 28px 22px; } }

/* Layers: each layer is a row of 1–4 columns; fields stack inside a column */
.form-layer { margin-bottom: 0; }
.form-layer.has-title:not(:first-child) { margin-top: 21px; }
.layer-grid { row-gap: 0; }
.layer-col { min-width: 0; }
.form-section-desc { color: var(--text-muted); font-size: 0.9rem; margin: -12px 0 22px; }
[data-fb-form] [hidden] { display: none !important; } /* .btn and friends set display, which would beat [hidden] */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ==========================================================================
   4. Form Controls & States
   ========================================================================== */
.form-group { display: flex; flex-direction: column; margin-bottom: 24px; position: relative; min-width: 0; }
.form-group label { font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; color: var(--text-main); }
.required::after { content: " *"; color: var(--error); }

.form-control { width: 100%; padding: 12px 16px; font-size: 0.95rem; font-family: inherit; color: var(--text-main); background-color: var(--bg-color); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: var(--transition); box-shadow: var(--shadow-sm); }
.form-control:hover:not(:disabled) { border-color: var(--border-focus); }
.form-control:focus { outline: none; border-color: var(--primary); background-color: var(--surface); box-shadow: var(--shadow-glow); }
.form-control::placeholder { color: #94a3b8; }
textarea.form-control { resize: vertical; }
textarea.form-control:not([rows]) { min-height: 100px; }
textarea.form-control[data-resize="both"] { resize: both; max-width: 100%; }
textarea.form-control[data-resize="none"] { resize: none; }
.form-control:disabled, .form-control[readonly] { background-color: #e2e8f0; color: #64748b; cursor: not-allowed; border-color: #cbd5e1; box-shadow: none; }
.form-control[readonly] { cursor: default; background-color: #f1f5f9; }
.help-text { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }

.password-wrapper { position: relative; width: 100%; }
.password-toggle { position: absolute; right: 14px; top: 12px; cursor: pointer; color: var(--text-muted); transition: color 0.2s; background: none; border: 0; line-height: 0; }
.password-toggle:hover { color: var(--primary); }
.password-wrapper input { padding-right: 45px; }

input[type="color"].form-control { padding: 4px; height: 46px; cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1); }

.radio-group, .checkbox-group { display: flex; gap: 20px; flex-wrap: wrap; padding: 10px 0; }
.choice-label { display: flex; align-items: center; font-weight: 500; cursor: pointer; font-size: 0.95rem; }
.choice-label input { appearance: none; -webkit-appearance: none; margin-right: 10px; width: 20px; height: 20px; flex-shrink: 0; border: 2px solid var(--border); transition: var(--transition); cursor: pointer; position: relative; background: var(--surface); }
.choice-label input[type="checkbox"] { border-radius: 6px; }
.choice-label input[type="radio"] { border-radius: 50%; }
.choice-label:hover input { border-color: var(--primary); }
.choice-label input:focus-visible { outline: none; box-shadow: var(--shadow-glow); border-color: var(--primary); }
.choice-label input:checked { background-color: var(--primary); border-color: var(--primary); box-shadow: var(--shadow-glow); }
.choice-label input[type="checkbox"]:checked::after { content: ''; position: absolute; left: 5px; top: 1px; width: 6px; height: 11px; border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg); animation: checkmark 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.choice-label input[type="radio"]:checked::after { content: ''; position: absolute; top: 4px; left: 4px; width: 8px; height: 8px; background: white; border-radius: 50%; animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
@keyframes checkmark { 0% { height: 0; width: 0; opacity: 0; } 100% { height: 11px; width: 6px; opacity: 1; } }
@keyframes popIn { 0% { transform: scale(0); } 100% { transform: scale(1); } }

/* ==========================================================================
   5. Plugins & Advanced UI
   ========================================================================== */
.select2-container--default .select2-selection--single { height: 46px; border: 1px solid var(--border); border-radius: var(--radius-sm); display: flex; align-items: center; background-color: var(--bg-color); transition: var(--transition); box-shadow: var(--shadow-sm); }
.select2-container--default .select2-selection--single:hover { border-color: var(--border-focus); }
.select2-container--open .select2-selection--single, .select2-container--default .select2-selection--single:focus { outline: none; background-color: var(--surface); border-color: var(--primary) !important; box-shadow: var(--shadow-glow) !important; }
.select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--text-main); padding-left: 16px; font-size: 0.95rem; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 44px; right: 10px; }
.select2-dropdown { border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); overflow: hidden; }
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable { background-color: var(--primary); }
.select2-container--default .select2-results__group { background: #f1f5f9; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }

.ms-container { position: relative; width: 100%; }
.ms-header { width: 100%; padding: 12px 16px; background: var(--bg-color); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 0.95rem; min-height: 46px; transition: var(--transition); box-shadow: var(--shadow-sm); gap: 8px; }
.ms-header:focus-visible { outline: none; border-color: var(--primary); box-shadow: var(--shadow-glow); }
.ms-title { display: flex; flex-wrap: wrap; gap: 4px 0; }
.ms-title.is-placeholder { color: #94a3b8; }
.ms-arrow { font-size: 0.7rem; color: var(--text-muted); }
.ms-container.active .ms-header { border-color: var(--primary); background: var(--surface); box-shadow: var(--shadow-glow); }
.ms-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); margin-top: 8px; z-index: 1000; display: none; overflow: hidden; }
.ms-container.active .ms-dropdown { display: block; animation: fadeInUp 0.2s ease-out forwards; }
.ms-search-box { padding: 12px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.ms-search-box input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none; transition: var(--transition); font: inherit; }
.ms-search-box input:focus { border-color: var(--primary); box-shadow: var(--shadow-glow); }
.ms-options { max-height: 220px; overflow-y: auto; padding: 8px 0; }
.form-group .ms-option, .ms-option { padding: 10px 16px; display: flex; align-items: center; cursor: pointer; font-size: 0.95rem; font-weight: 500; margin: 0; }
.ms-option:hover { background-color: var(--bg-color); }
.ms-option input { margin-right: 12px; accent-color: var(--primary); transform: scale(1.2); }
.ms-option.hidden { display: none; }
.badge { display: inline-flex; align-items: center; background: var(--primary-light); color: var(--primary-hover); font-weight: 600; font-size: 0.8rem; padding: 4px 10px; border-radius: 20px; margin-right: 6px; }

.dropzone { border: 2px dashed var(--border); border-radius: var(--radius-md); padding: 40px 20px; text-align: center; background-color: var(--bg-color); cursor: pointer; transition: var(--transition); position: relative; overflow: hidden; }
.dropzone::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: var(--primary); opacity: 0; transition: var(--transition); z-index: 0; }
.dropzone:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dropzone.dragover { border-color: var(--primary); transform: scale(1.02); }
.dropzone.dragover::before { opacity: 0.05; }
.dropzone * { position: relative; z-index: 1; }
.dropzone input[type="file"] { position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; cursor: pointer; z-index: 2; }
.dropzone-icon { color: var(--primary); margin-bottom: 12px; transition: transform 0.3s; }
.dropzone:hover .dropzone-icon { transform: translateY(-5px); }
.dropzone-title { font-weight: 500; font-size: 1.1rem; margin-bottom: 5px; }
.file-list { margin-top: 15px; list-style: none; }
.file-list:empty { display: none; }
.file-list li { background: var(--surface); padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; font-size: 0.9rem; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow-sm); animation: fadeInUp 0.3s ease-out; gap: 10px; }
.remove-file { color: var(--text-muted); cursor: pointer; padding: 4px 8px; border-radius: 4px; transition: var(--transition); background: var(--bg-color); border: 0; font: inherit; }
.remove-file:hover { color: var(--error); background: var(--error-light); }

.toggle-switch { position: relative; display: inline-block; width: 52px; height: 28px; flex-shrink: 0; }
.form-group .toggle-switch { margin: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--border); transition: 0.4s; border-radius: 28px; box-shadow: inset 0 1px 3px rgba(0,0,0,0.1); }
.toggle-slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: 0.4s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.toggle-switch input:checked + .toggle-slider { background-color: var(--success); }
.toggle-switch input:focus-visible + .toggle-slider { box-shadow: 0 0 1px var(--success), var(--shadow-glow); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(24px); }
.toggle-wrapper { display: flex; align-items: center; gap: 12px; height: 46px; }
.toggle-status { margin-top: 0; font-weight: 600; }
.toggle-status.is-on { color: var(--success); }

.range-wrapper { display: flex; align-items: center; gap: 15px; height: 46px; }
.range-wrapper input[type="range"] { flex-grow: 1; accent-color: var(--primary); cursor: pointer; min-width: 0; }
.range-output { background: var(--primary-light); color: var(--primary-hover); padding: 4px 12px; border-radius: 20px; font-weight: 700; font-size: 0.85rem; min-width: 50px; text-align: center; }

.star-rating { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 6px; height: 46px; align-items: center; }
.star-rating input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.star-rating label { font-size: 2rem; color: #cbd5e1; cursor: pointer; transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); line-height: 1; margin: 0; }
.star-rating input:checked ~ label, .star-rating label:hover, .star-rating label:hover ~ label { color: var(--warning); transform: scale(1.15); }
.star-rating input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ==========================================================================
   6. Validation & Toasts
   ========================================================================== */
.invalid-feedback { display: none; color: var(--error); font-size: 0.85rem; margin-top: 6px; font-weight: 500; }
.form-control.is-invalid { border-color: var(--error); box-shadow: var(--shadow-error); background-color: var(--error-light); }
.is-invalid + .select2-container--default .select2-selection--single { border-color: var(--error); box-shadow: var(--shadow-error); background-color: var(--error-light); }
.ms-container.is-invalid .ms-header { border-color: var(--error); box-shadow: var(--shadow-error); background-color: var(--error-light); }
.dropzone.is-invalid { border-color: var(--error); background-color: var(--error-light); }
.has-error .choice-label input { border-color: var(--error); }
.has-error .note-editor.note-frame { border-color: var(--error) !important; box-shadow: var(--shadow-error); }
.has-error .star-rating label { color: #fca5a5; }

.toast-container { position: fixed; bottom: 30px; right: 30px; z-index: 9999; display: flex; flex-direction: column; gap: 15px; }
.toast { min-width: 320px; max-width: calc(100vw - 40px); padding: 16px 20px; background: var(--surface); border-radius: var(--radius-md); box-shadow: 0 10px 40px -10px rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: space-between; animation: slideInRight 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; border-left: 6px solid; }
.toast-success { border-color: var(--success); } .toast-warning { border-color: var(--warning); } .toast-error { border-color: var(--error); }
.toast.hiding { animation: fadeOutRight 0.4s ease-out forwards; }
.toast-icon { margin-right: 15px; font-size: 1.4rem; }
.toast-message { font-size: 0.95rem; font-weight: 500; color: var(--text-main); flex-grow: 1; }
.toast-close { cursor: pointer; color: var(--text-muted); background: none; border: none; font-size: 1.5rem; transition: var(--transition); margin-left: 12px; }
.toast-close:hover { color: var(--error); transform: scale(1.1); }
@keyframes slideInRight { 0% { transform: translateX(120%); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
@keyframes fadeOutRight { 0% { transform: translateX(0); opacity: 1; } 100% { transform: translateX(120%); opacity: 0; } }
@media (max-width: 480px) { .toast-container { right: 12px; left: 12px; bottom: 16px; } .toast { min-width: 0; } }

/* ==========================================================================
   7. Buttons & WYSIWYG
   ========================================================================== */
.form-actions { padding: 30px 40px; background: #f8fafc; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 16px; border-radius: 0 0 var(--radius-md) var(--radius-md); flex-wrap: wrap; }
.btn { padding: 12px 28px; font-size: 1rem; font-weight: 600; font-family: inherit; border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); border: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-glow); }
.btn-outline { background: var(--surface); border: 2px solid var(--border); color: var(--text-main); }
.btn-outline:hover { border-color: var(--text-muted); background: var(--bg-color); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); color: white; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.btn-primary:hover { box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4); transform: translateY(-1px); }
.btn[disabled] { opacity: 0.75; cursor: progress; }

.note-editor.note-frame { border-color: var(--border) !important; border-radius: var(--radius-sm) !important; overflow: hidden; box-shadow: var(--shadow-sm); background: var(--surface); }
.note-toolbar { background-color: var(--bg-color) !important; border-bottom: 1px solid var(--border) !important; }

/* ==========================================================================
   8. Table input
   ========================================================================== */
.fb-table-field { width: 100%; }
.fb-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-sm); }
.fb-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 0.9rem; }
.fb-table tr { height: var(--row-h, 48px); }
.fb-table thead tr { height: var(--th-h, 44px); }
.fb-table th { background: var(--th-bg, #eef2ff); color: var(--th-color, #3730a3); text-align: var(--th-align, left); font-weight: var(--th-weight, 700); font-size: 0.8rem; padding: 0 12px; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-table td { padding: 0; border-bottom: 1px solid #e2e8f0; vertical-align: middle; background: var(--surface); }
.fb-table tbody tr:last-child td { border-bottom: 0; }
.fb-table.is-bordered th + th, .fb-table.is-bordered td + td { border-left: 1px solid #e2e8f0; }
.fb-table.is-striped tbody tr:nth-child(even) td { background: #f8fafc; }
.fb-col-num { width: 48px; }
.fb-col-act { width: 44px; }
.fb-table .fb-rownum { text-align: center; color: var(--text-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; padding: 0 4px; }
.fb-table .fb-act { text-align: center; padding: 0; }
.fb-cell-input { display: block; width: 100%; border: 0; background: transparent; padding: 8px 12px; font: inherit; font-size: 0.9rem; color: var(--text-main); text-align: inherit; outline: none; border-radius: 0; min-width: 0; }
.fb-cell-input::placeholder { color: #94a3b8; }
.fb-cell-input:focus { background: var(--surface); box-shadow: inset 0 0 0 2px var(--primary); }
select.fb-cell-input { cursor: pointer; }
.fb-cell-check { width: 18px; height: 18px; margin: 0 12px; vertical-align: middle; accent-color: var(--primary); cursor: pointer; }
.fb-cell-label { display: block; padding: 6px 12px; font-weight: 500; overflow-wrap: anywhere; }
.fb-req { color: var(--error); margin-left: 3px; }
.fb-row-remove { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.fb-row-remove:hover { background: var(--error-light); color: var(--error); }
.fb-row-remove:disabled { opacity: 0.3; cursor: default; background: transparent; color: var(--text-muted); }
.fb-table-add { margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px dashed var(--border-focus); border-radius: var(--radius-sm); background: var(--surface); color: var(--primary-hover); font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.fb-table-add:hover { background: var(--primary-light); border-style: solid; }
.fb-table-add:disabled { opacity: 0.5; cursor: default; background: var(--surface); }
.fb-cell-input.is-invalid, .fb-cell-check.is-invalid { background: var(--error-light); box-shadow: inset 0 0 0 2px var(--error); }
.has-error .fb-table-wrap { border-color: var(--error); box-shadow: var(--shadow-error); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
    .form-section { opacity: 1; }
}
