/* ================================================================
   cfb-form.css  v2.1
   Colors via CSS variables from CFB_Settings
   ================================================================ */

/* ----------------------------------------------------------------
   Fields
   ---------------------------------------------------------------- */
.cfb-form-wrap { max-width: 680px; margin: 0 auto; }
.cfb-form      { width: 100%; }
.cfb-field     { margin-bottom: 18px; }

.cfb-label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 14px;
    color: #1d2327;
}
.cfb-required    { color: #d63638; margin-inline-start: 2px; }
.cfb-description { font-size: 12px; color: #787c82; margin: 4px 0 0; }

/* ----------------------------------------------------------------
   Inputs
   ---------------------------------------------------------------- */
.cfb-input,
.cfb-textarea,
.cfb-select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 14px;
    color: #1d2327;
    background: #fff;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.cfb-input:focus,
.cfb-textarea:focus,
.cfb-select:focus {
    outline: none;
    border-color: var(--cfb-primary, #e05540);
    box-shadow: 0 0 0 3px rgba(224,85,64,.15);
}
.cfb-textarea { resize: vertical; min-height: 90px; }

/* ----------------------------------------------------------------
   Choice fields
   ---------------------------------------------------------------- */
.cfb-radio-group,
.cfb-checkbox-group  { display: flex; flex-direction: column; gap: 8px; }
.cfb-radio-label,
.cfb-checkbox-label  { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.cfb-radio-label input,
.cfb-checkbox-label input {
    width: 16px; height: 16px; flex-shrink: 0;
    accent-color: var(--cfb-primary, #e05540);
    cursor: pointer;
}

/* ----------------------------------------------------------------
   File
   ---------------------------------------------------------------- */
.cfb-file      { font-size: 13px; }
.cfb-file-hint { font-size: 11px; color: #787c82; margin: 4px 0 0; }

/* ----------------------------------------------------------------
   Rating
   ---------------------------------------------------------------- */
.cfb-rating { display: flex; gap: 4px; }
.cfb-star {
    background: none; border: none; cursor: pointer;
    font-size: 28px; color: #d0d5dd; padding: 0;
    transition: color .1s, transform .1s; line-height: 1;
}
.cfb-star--active { color: #f0b429; }
.cfb-star--hover  { color: #f7c948; transform: scale(1.15); }

/* ----------------------------------------------------------------
   Signature
   ---------------------------------------------------------------- */
.cfb-signature-wrap    { border: 1px solid #d0d5dd; border-radius: 6px; overflow: hidden; }
.cfb-signature-canvas  { display: block; width: 100%; height: 150px; background: #fafafa; cursor: crosshair; touch-action: none; }
.cfb-signature-actions { padding: 6px 10px; background: #f5f5f5; display: flex; justify-content: flex-end; }
.cfb-sig-clear         { font-size: 12px; color: #d63638; background: none; border: none; cursor: pointer; }

/* ----------------------------------------------------------------
   Submit
   ---------------------------------------------------------------- */
.cfb-field--submit { margin-top: 8px; }
.cfb-btn-submit {
    display: inline-block;
    padding: 10px 28px;
    background: var(--cfb-submit, #e05540);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s;
}
.cfb-btn-submit:hover    { background: var(--cfb-submit-hover, #c04030); }
.cfb-btn-submit:disabled { background: #a7aaad; cursor: not-allowed; }

/* ----------------------------------------------------------------
   Messages
   ---------------------------------------------------------------- */
.cfb-msg          { padding: 12px 16px; border-radius: 6px; font-size: 14px; margin-top: 14px; }
.cfb-msg--success { background: #d1e7dd; color: #155724; border: 1px solid #badbcc; }
.cfb-msg--error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c2c7; }
.cfb-field-error  { display: block; color: #d63638; font-size: 12px; margin-top: 4px; }

/* ================================================================
   Floating Window
   ================================================================ */

/* Trigger button */
.cfb-win-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 26px;
    background: var(--cfb-primary, #e05540);
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(224,85,64,.3);
    transition: background .18s, transform .12s;
}
.cfb-win-trigger:hover {
    background: var(--cfb-primary-hover, #c04030);
    transform: translateY(-1px);
}

/* Window container
   KEY: no fixed height — grows with content
   scrollbar only appears when content exceeds max-height */
.cfb-window {
    position: fixed;
    /* width set inline from shortcode */
    max-width: calc(100vw - 32px);
    background: #fff;
    border-radius: 10px;
    box-shadow:
        0 4px 6px -1px rgba(0,0,0,.08),
        0 12px 36px -4px rgba(0,0,0,.2),
        0 0 0 1px rgba(0,0,0,.06);
    z-index: 99990;
    display: flex;
    flex-direction: column;
    /* Centered by JS */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    /* No animation delay — instant */
}

/* Title bar */
.cfb-window-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    height: 46px;
    min-height: 46px;
    background: var(--cfb-primary, #e05540);
    border-radius: 10px 10px 0 0;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
}
.cfb-window-titlebar:active { cursor: grabbing; }

.cfb-window-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--cfb-title-text, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.cfb-window-close {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.18);
    color: var(--cfb-title-text, #fff);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-inline-start: 10px;
    transition: background .15s;
    line-height: 1;
}
.cfb-window-close:hover { background: rgba(0,0,0,.32); }

/* Body:
   - auto height by default (grows with content)
   - scrollbar only when content > 70vh              */
.cfb-window-body {
    padding: 22px 24px 24px;
    overflow-y: auto;
    max-height: 70vh;
    /* Force LTR by default */
    direction: ltr;
    text-align: left;
}
.cfb-window-body .cfb-form { max-width: 100%; }

/* ----------------------------------------------------------------
   RTL window
   ---------------------------------------------------------------- */
.cfb-window.cfb-rtl .cfb-window-titlebar { flex-direction: row-reverse; }
.cfb-window.cfb-rtl .cfb-window-title    { text-align: right; }
.cfb-window.cfb-rtl .cfb-window-body     { direction: rtl; text-align: right; }
.cfb-window.cfb-rtl .cfb-input,
.cfb-window.cfb-rtl .cfb-textarea,
.cfb-window.cfb-rtl .cfb-select          { direction: rtl; text-align: right; }
.cfb-window.cfb-rtl .cfb-radio-label,
.cfb-window.cfb-rtl .cfb-checkbox-label  { flex-direction: row-reverse; justify-content: flex-end; }
.cfb-window.cfb-rtl .cfb-rating          { flex-direction: row-reverse; }
.cfb-window.cfb-rtl .cfb-field-error,
.cfb-window.cfb-rtl .cfb-msg             { direction: rtl; text-align: right; }
.cfb-window.cfb-rtl .cfb-signature-actions { justify-content: flex-start; }

/* ----------------------------------------------------------------
   Mobile: bottom sheet
   ---------------------------------------------------------------- */
@media (max-width: 520px) {
    .cfb-window {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        transform: none !important;
    }
    .cfb-window-body { max-height: 80vh; }
    .cfb-btn-submit  { width: 100%; text-align: center; }
    .cfb-win-trigger { width: 100%; justify-content: center; }
}
