/* ==========================================================
   AI Form Builder — Frontend Form Styles
   ========================================================== */

.clsf-form-wrap { max-width: 720px; margin: 0 auto; font-family: inherit; }
.clsf-form-title { margin-bottom: 20px; }

/* Messages */
.clsf-messages {
    margin-bottom: 16px;
    border-radius: 4px;
    overflow: hidden;
}
.clsf-msg-success {
    background: #d1fae5;
    border-left: 4px solid #10b981;
    color: #065f46;
    padding: 12px 16px;
}
.clsf-msg-error {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
    padding: 12px 16px;
}

/* Full-page success — shown after form hides */
.clsf-msg-full {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    border-radius: 8px;
    border-left: none;
    font-size: 18px;
    font-weight: 600;
    gap: 12px;
}
.clsf-msg-full::before {
    content: '✓';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: #10b981;
    color: #fff;
    border-radius: 50%;
    font-size: 28px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Field wrappers */
.clsf-field { margin-bottom: 20px; }
.clsf-indent-1 { padding-left: 20px; }
.clsf-indent-2 { padding-left: 40px; }
.clsf-indent-3 { padding-left: 60px; }

/* Labels */
.clsf-label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
    color: #374151;
}
.clsf-required-mark { color: #ef4444; margin-left: 2px; }

/* Inputs */
.clsf-input,
.clsf-textarea,
.clsf-select {
    width: 100%;
    padding: 10px 12px;
    font-family: inherit;  /* use theme font, not browser monospace default */
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 15px;
    line-height: 1.5;
    color: #111827;
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.clsf-input:focus,
.clsf-textarea:focus,
.clsf-select:focus {
    border-color: #6366f1;
    outline: 2px solid rgba(99,102,241,0.25);
}

/* Notice / fine print box */
.clsf-notice-box {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 14px 16px;
    font-size: 13px;
    color: #374151;
    line-height: 1.7;
    margin: 4px 0;
}
.clsf-notice-box strong {
    display: block;
    font-size: 14px;
    color: #111827;
    margin-bottom: 8px;
}

/* Character counter */
.clsf-char-counter {
    display: flex;
    justify-content: flex-end;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
    transition: color .2s;
}
.clsf-char-counter.clsf-counter-warn { color: #f59e0b; font-weight: 600; }
.clsf-char-counter.clsf-counter-over { color: #ef4444; font-weight: 600; }
.clsf-char-counter.clsf-counter-over ~ .clsf-textarea,
.clsf-field:has(.clsf-counter-over) .clsf-textarea {
    border-color: #ef4444;
}

/* Section headers & descriptions */
.clsf-section-header { margin: 32px 0 20px; }
.clsf-section-heading {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 10px;
    padding: 0;
    line-height: 1.3;
}
.clsf-section-rule {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 0 0 16px;
}
.clsf-section-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin: 8px 0 0;
}
.clsf-description { color: #6b7280; font-size: 14px; margin-bottom: 8px; }

/* Checkbox group */
.clsf-checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.clsf-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
}
.clsf-checkbox { width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; accent-color: #6366f1; }

/* Option description (shown below individual checkbox labels) */
.clsf-option-desc {
    margin: 4px 0 10px 28px;
    font-size: 13px;
    color: #4b5563;
    line-height: 1.7;
}

/* Conditional children accordion */
.clsf-children {
    border-left: 3px solid #6366f1;
    padding-left: 16px;
    margin-top: 8px;
    animation: clsf-slide-in 0.2s ease;
}
@keyframes clsf-slide-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Signature pad */
.clsf-signature-wrap { }
.clsf-agreement-text {
    font-size: 13px;
    color: #6b7280;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 10px 12px;
    border-radius: 4px;
    margin-bottom: 10px;
}
.clsf-signature-canvas {
    display: block;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: crosshair;
    background: #fff;
    max-width: 100%;
    touch-action: none;
}
.clsf-sig-clear {
    margin-top: 6px;
    padding: 4px 12px;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #6b7280;
}
.clsf-sig-clear:hover { background: #fee2e2; border-color: #ef4444; color: #991b1b; }

/* Upload progress bar */
.clsf-upload-progress-wrap {
    margin-top: 14px;
}
.clsf-upload-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
    margin-bottom: 8px;
}
.clsf-upload-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid #d1d5db;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: clsf-spin .7s linear infinite;
    flex-shrink: 0;
}
.clsf-upload-label { flex: 1; font-weight: 500; }
.clsf-upload-pct   { font-weight: 700; color: #6366f1; min-width: 36px; text-align: right; }
.clsf-upload-bar-track {
    height: 6px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
}
.clsf-upload-bar-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #6366f1, #818cf8);
    border-radius: 99px;
    transition: width 0.3s ease;
}

/* Submit button */
.clsf-submit-row {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}
.clsf-submit-msg { width: 100%; }
.clsf-msg-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    font-size: 15px;
    font-weight: 600;
    color: #065f46;
    padding: 10px 13px;
    background: #d1fae5;
    border-radius: 6px;
}
.clsf-msg-inline::before { content: '✓'; font-size: 18px; }
.clsf-submit-btn {
    display: inline-block;
    padding: 12px 32px;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.clsf-submit-btn:hover  { background: #4f46e5; }
.clsf-submit-btn:active { transform: scale(0.98); }
.clsf-submit-btn:disabled { background: #a5b4fc; cursor: not-allowed; }

/* Loading state */
.clsf-submitting .clsf-submit-btn { background: #a5b4fc; cursor: not-allowed; }

/* Validation error highlight */
.clsf-field.has-error .clsf-input,
.clsf-field.has-error .clsf-textarea,
.clsf-field.has-error .clsf-select,
.clsf-field.has-error .clsf-file-input {
    border-color: #ef4444 !important;
    background: #fff5f5 !important;
    box-shadow: 0 0 0 3px rgba(239,68,68,.1) !important;
}

/* Red left border on the entire field block when invalid */
.clsf-field.has-error {
    border-left: 3px solid #ef4444;
    padding-left: 10px;
    margin-left: -13px;
    border-radius: 0 4px 4px 0;
}

/* Red shake animation on first error */
.clsf-field.has-error {
    animation: clsf-shake .35s ease;
}
@keyframes clsf-shake {
    0%,100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}

/* Inline error message below field */
.clsf-field-error {
    color: #ef4444;
    font-size: 12px;
    margin: 4px 0 0;
    display: flex;
    align-items: center;
    gap: 4px;
}
.clsf-field-error::before {
    content: '⚠';
    font-size: 11px;
}

/* Highlight checkbox label text when group is invalid */
.clsf-field.has-error > .clsf-label {
    color: #ef4444;
}

/* Radio group */
.clsf-radio-group  { display: flex; flex-direction: column; gap: 8px; }
.clsf-radio-item   { display: flex; flex-direction: column; }
.clsf-radio-label  {
    display: flex; align-items: flex-start; gap: 10px;
    cursor: pointer; font-size: 14px; color: #374151;
}
.clsf-radio {
    width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0;
    accent-color: #6366f1; cursor: pointer;
}
/* Radio children (revealed when option selected) — same indent style as checkbox */
.clsf-radio-children {
    border-left: 3px solid #6366f1;
    padding-left: 16px; margin-top: 8px;
    animation: clsf-slide-in 0.2s ease;
}

/* Number / date / time inputs */
.clsf-date-input,
.clsf-time-input { max-width: 240px; }

/* ── Side-by-side field rows ───────────────────────── */
/* Fields grouped by render_fields() into .clsf-field-row */
.clsf-field-row {
    display: grid;
    gap: 0 20px;
    align-items: start;
}
.clsf-row-half  { grid-template-columns: repeat(2, 1fr); }
.clsf-row-third { grid-template-columns: repeat(3, 1fr); }

/* Responsive: stack on narrow screens */
@media (max-width: 600px) {
    .clsf-row-half,
    .clsf-row-third { grid-template-columns: 1fr; }
}

/* File upload field */
.clsf-file-wrap { }
.clsf-file-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.clsf-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 13px;
    color: #374151;
}
.clsf-file-item-warn { background: #fff5f5; border-color: #fecaca; color: #991b1b; }
.clsf-file-icon  { flex-shrink: 0; }
.clsf-file-name  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clsf-file-size  { color: #94a3b8; font-size: 11px; flex-shrink: 0; }
.clsf-file-warn  { color: #ef4444; font-size: 11px; flex-shrink: 0; font-weight: 600; }

.clsf-file-input {
    display: block;
    width: 100%;
    padding: 10px;
    border: 2px dashed #d1d5db;
    border-radius: 6px;
    background: #f9fafb;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    transition: border-color .15s;
    box-sizing: border-box;
}
.clsf-file-input:hover  { border-color: #6366f1; background: #eef2ff; }
.clsf-file-input:focus  { outline: none; border-color: #6366f1; }
.clsf-file-hint { font-size: 12px; color: #9ca3af; margin: 4px 0 0; }

/* Turnstile widget */
.clsf-turnstile { margin: 12px 0; }
.clsf-recaptcha-info { font-size: 11px; color: #9ca3af; margin-top: 6px; }

/* Responsive */
@media (max-width: 480px) {
    .clsf-form-wrap { padding: 0 8px; }
    .clsf-signature-canvas { width: 100%; height: 120px; }
}
