/* ════════════════════════════════════════════════════════════
   Custom Form — Frontend Styles
   Inspired by Drupal Webform clean layout
   ════════════════════════════════════════════════════════════ */

/* ── Base wrap ──────────────────────────────────────────────── */
.cf-form-wrap {
    max-width: 700px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: #1a1a1a;
    line-height: 1.5;
}
.cf-form-title {
    font-size: 22px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid #0d1b4b;
}

/* ── Notices ────────────────────────────────────────────────── */
.cf-notices {
    padding: 14px 18px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}
.cf-notices--success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}
.cf-notices--error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}
.cf-notice--error {
    color: #991b1b;
    font-size: 14px;
}

/* ── Form layout ────────────────────────────────────────────── */
.cf-form {
    /* 1.0.3: a wrapping row layout so fields with a Width (Half, One-third...)
       really sit side by side. As inline-blocks, the spaces between them in
       the HTML pushed the second of two 50% fields onto the next line. */
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
}
.cf-form > * {
    flex: 0 0 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.cf-form > .cf-field[style*="width"] {
    flex: 0 0 auto;
}
@media (max-width: 600px) {
    .cf-form > .cf-field[style*="width"] {
        flex-basis: 100% !important;
        width: 100% !important;
        padding-right: 0 !important;
    }
}

/* ── Field wrapper ──────────────────────────────────────────── */
.cf-field {
    margin-bottom: 20px;
}
.cf-field--divider {
    margin: 24px 0;
}
.cf-field--html {
    margin-bottom: 16px;
    font-size: 14px;
    color: #374151;
    line-height: 1.6;
}
.cf-field--submit {
    margin-top: 28px;
}
.cf-hr {
    border: none;
    border-top: 1px solid #d1d5db;
}

/* ── Labels ─────────────────────────────────────────────────── */
.cf-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}
.cf-req {
    color: #dc2626;
    margin-left: 3px;
}

/* ── Inputs (text, email, tel, number, url, textarea, select) ─ */
.cf-input {
    display: block;
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    color: #1a1a1a;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
}
.cf-input:focus {
    outline: none;
    border-color: #0d1b4b;
    box-shadow: 0 0 0 3px rgba(13, 27, 75, .12);
}
.cf-input:hover:not(:focus) {
    border-color: #9ca3af;
}
.cf-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

/* ── Select with arrow ──────────────────────────────────────── */
.cf-select-wrap {
    position: relative;
    display: block;
}
.cf-select-wrap .cf-select {
    padding-right: 36px;
    cursor: pointer;
}
.cf-select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 11px;
    color: #6b7280;
}

/* ── Radio & Checkbox options ───────────────────────────────── */
.cf-fieldset {
    border: none;
    padding: 0;
    margin: 0;
    min-width: 0;
}
.cf-options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.cf-option-label {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    padding: 7px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fafafa;
    transition: background .12s, border-color .12s;
}
.cf-option-label:hover {
    background: #f0f4ff;
    border-color: #c7d2fe;
}
.cf-radio,
.cf-checkbox {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    accent-color: #0d1b4b;
    cursor: pointer;
    margin: 0;
}
.cf-other-inline {
    border: none;
    border-bottom: 1px solid #d1d5db;
    padding: 2px 6px;
    font-size: 13px;
    outline: none;
    flex: 1;
    background: transparent;
    color: #1a1a1a;
}
.cf-other-input {
    display: none;
    margin-top: 8px;
}

/* ── Date / time input icons ────────────────────────────────── */
.cf-input-icon-wrap {
    position: relative;
    display: block;
}
.cf-input-icon-wrap .cf-input {
    padding-right: 38px;
    cursor: pointer;
}
.cf-input-icon {
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 16px;
    color: #9ca3af;
}

/* ── Rating stars ───────────────────────────────────────────── */
.cf-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}
.cf-rating-star {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 26px;
    color: #d1d5db;
    padding: 2px;
    transition: color .1s, transform .1s;
    line-height: 1;
}
.cf-rating-star--on {
    color: #f59e0b;
}
.cf-rating-star--hover {
    color: #fbbf24;
    transform: scale(1.15);
}
.cf-rating-star:focus {
    outline: 2px solid #0d1b4b;
    border-radius: 3px;
}

/* ── Range slider ───────────────────────────────────────────── */
.cf-range {
    width: 100%;
    accent-color: #0d1b4b;
    cursor: pointer;
    height: 6px;
    margin: 6px 0 4px;
}
.cf-range-display {
    font-weight: 400;
    color: #6b7280;
    font-size: 13px;
    margin-left: 4px;
}
.cf-range-val {
    font-weight: 600;
    color: #0d1b4b;
}
.cf-range-minmax {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

/* ── Color picker ───────────────────────────────────────────── */
.cf-color-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}
.cf-color-swatch {
    width: 46px;
    height: 36px;
    padding: 3px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    background: none;
}
.cf-color-hex {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #374151;
}

/* ── Signature pad ──────────────────────────────────────────── */
.cf-sig-container {
    border: 1px solid #d1d5db;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}
.cf-sig-canvas {
    display: block;
    width: 100%;
    cursor: crosshair;
    touch-action: none;
    background: #fff;
}
.cf-sig-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}
.cf-sig-hint {
    font-size: 11px;
    color: #9ca3af;
}
.cf-sig-clear {
    padding: 3px 10px;
    font-size: 11px;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    color: #6b7280;
    transition: all .12s;
}
.cf-sig-clear:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ── Terms ──────────────────────────────────────────────────── */
.cf-terms-box {
    max-height: 120px;
    overflow-y: auto;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #f9fafb;
    font-size: 13px;
    color: #374151;
    line-height: 1.6;
    margin-bottom: 10px;
}
.cf-terms-check {
    border: none;
    background: none;
    padding: 0;
    font-weight: 500;
}

/* ── Name composite ─────────────────────────────────────────── */
.cf-composite {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.cf-composite-part {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cf-composite-part label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.cf-composite-part .cf-input,
.cf-composite-part .cf-select {
    width: 100%;
}

/* ── Address ────────────────────────────────────────────────── */
.cf-address {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.cf-address-line {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cf-address-line label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ── File upload ────────────────────────────────────────────── */
.cf-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}
.cf-file-area {
    position: relative;
}
.cf-file-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px dashed #d1d5db;
    border-radius: 4px;
    background: #f9fafb;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    font-size: 14px;
    color: #374151;
}
.cf-file-label:hover {
    border-color: #0d1b4b;
    background: #f0f4ff;
}
.cf-file-input:focus + .cf-file-label {
    border-color: #0d1b4b;
    box-shadow: 0 0 0 3px rgba(13,27,75,.12);
}
.cf-file-icon {
    font-size: 20px;
    flex-shrink: 0;
}
.cf-file-text {
    flex: 1;
    color: #374151;
}
.cf-file-browse {
    padding: 4px 12px;
    background: #0d1b4b;
    color: #fff;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}
.cf-file-info {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 5px;
}

/* ── Submit button ──────────────────────────────────────────── */
.cf-submit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 28px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s, transform .1s;
}
.cf-submit:disabled {
    opacity: .65;
    cursor: not-allowed;
    transform: none !important;
}
.cf-submit--primary {
    background: #0d1b4b;
    color: #fff;
}
.cf-submit--primary:hover:not(:disabled) {
    background: #1e3a8a;
}
.cf-submit--secondary {
    background: #6b7280;
    color: #fff;
}
.cf-submit--accent {
    background: #22c55e;
    color: #fff;
}
.cf-submit:active:not(:disabled) {
    transform: scale(.98);
}

/* ── Flatpickr theme tweaks ─────────────────────────────────── */
.flatpickr-calendar {
    font-family: inherit;
    box-shadow: 0 4px 24px rgba(0,0,0,.12);
    border: 1px solid #e5e7eb;
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: #0d1b4b;
    border-color: #0d1b4b;
}
.flatpickr-day:hover {
    background: #e8edf8;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 540px) {
    .cf-composite {
        flex-direction: column;
    }
    .cf-composite-part {
        min-width: 100%;
    }
}

/* ══════════════════════════════════════════════════════════
   Multi-step progress bar
══════════════════════════════════════════════════════════ */
.cf-progress {
    margin-bottom: 28px;
}
.cf-progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 16px;
}
.cf-progress-fill {
    height: 100%;
    background: #0d1b4b;
    border-radius: 3px;
    transition: width .3s ease;
}
.cf-progress-steps {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.cf-step-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex: 1;
}
.cf-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    background: #fff;
    color: #9ca3af;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
}
.cf-step-dot.active .cf-step-num {
    border-color: #0d1b4b;
    background: #0d1b4b;
    color: #fff;
}
.cf-step-dot.done .cf-step-num {
    border-color: #22c55e;
    background: #22c55e;
    color: #fff;
}
.cf-step-lbl {
    font-size: 11px;
    color: #9ca3af;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}
.cf-step-dot.active .cf-step-lbl { color: #0d1b4b; font-weight: 600; }
.cf-step-dot.done  .cf-step-lbl  { color: #15803d; }

/* Page nav buttons inside page breaks */
.cf-page-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 0;
    border-top: 1px solid #e5e7eb;
    margin-top: 8px;
}
.cf-page-nav--break { justify-content: space-between; }
.cf-page-next, .cf-page-prev {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .15s;
}
.cf-page-next { background: #0d1b4b; color: #fff; }
.cf-page-next:hover { background: #1e3a8a; }
.cf-page-prev { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; }
.cf-page-prev:hover { background: #e9eaed; }

/* ══════════════════════════════════════════════════════════
   Validation error messages
══════════════════════════════════════════════════════════ */
.cf-input-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .1) !important;
}
.cf-error-msg {
    display: block;
    font-size: 12px;
    color: #dc2626;
    margin-top: 4px;
    font-weight: 500;
}
.cf-error-msg::before {
    content: '⚠ ';
}

/* ── Inline options (gender etc.) ─────────────────────────── */
.cf-options-inline { flex-direction: row !important; flex-wrap: wrap; gap: 8px !important; }
.cf-option-inline  { flex: 0 0 auto !important; }
/* ── Email confirm spacing ──────────────────────────────────── */
.cf-field + .cf-field { margin-top: 0; }

/* ═══════════════════════════════════════════════════════
   Toggle field (frontend)
═══════════════════════════════════════════════════════ */
.cf-toggle-field-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}
/* Hide the real checkbox — visually replaced by the switch */
.cf-toggle-field-cb {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
/* The label that wraps the switch span — this is what the user clicks */
.cf-toggle-switch-label {
    display: inline-block;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}
.cf-toggle-field-switch {
    display: block;
    position: relative;
    width: 48px;
    height: 27px;
    background: #d1d5db;
    border-radius: 14px;
    transition: background .2s;
}
.cf-toggle-field-switch::after {
    content: '';
    position: absolute;
    width: 21px;
    height: 21px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: left .2s cubic-bezier(.34,1.4,.64,1);
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
/* When checkbox is checked, JS adds cf-toggle-on to the wrap div */
.cf-toggle-field-wrap.cf-toggle-on .cf-toggle-field-switch { background: #4f46e5; }
.cf-toggle-field-wrap.cf-toggle-on .cf-toggle-field-switch::after { left: 24px; }
/* Also style via native :checked for fallback (when JS slow/disabled) */
.cf-toggle-field-cb:checked ~ .cf-toggle-switch-label .cf-toggle-field-switch { background: #4f46e5; }
.cf-toggle-field-cb:checked ~ .cf-toggle-switch-label .cf-toggle-field-switch::after { left: 24px; }
/* Labels */
.cf-toggle-off-label { font-size: 14px; color: #6b7280; }
.cf-toggle-on-label  { font-size: 14px; color: #4f46e5; font-weight: 600; }
/* Show/hide labels based on state */
.cf-toggle-field-wrap:not(.cf-toggle-on) .cf-toggle-on-label  { display: none; }
.cf-toggle-field-wrap.cf-toggle-on       .cf-toggle-off-label { display: none; }
/* Fallback via :checked */
.cf-toggle-field-cb:not(:checked) ~ .cf-toggle-on-label  { display: none; }
.cf-toggle-field-cb:checked       ~ .cf-toggle-off-label { display: none; }

/* ═══════════════════════════════════════════════════════
   Word / character counter bar
═══════════════════════════════════════════════════════ */
.cf-counter-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 5px;
    font-size: 12px;
    color: #9ca3af;
    transition: color .15s;
}
.cf-counter-current { font-weight: 600; color: #374151; }
.cf-counter-bar.cf-counter-ok   .cf-counter-current { color: #15803d; }
.cf-counter-bar.cf-counter-over .cf-counter-current { color: #dc2626; }
.cf-counter-bar.cf-counter-over { color: #dc2626; }
.cf-counter-bar.cf-counter-under .cf-counter-current { color: #f59e0b; }

/* ── Multiselect dropdown ──────────────────────────────────── */
.cf-multiselect-wrap {
    display: block;           /* no arrow overlay for multiselect */
}
.cf-multiselect {
    height: auto;
    min-height: 100px;
    padding: 4px 0;
    border-radius: 4px;
    cursor: pointer;
}
.cf-multiselect option {
    padding: 7px 12px;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
}
.cf-multiselect option:checked,
.cf-multiselect option:hover {
    background: #eef2ff;
    color: #4f46e5;
}
.cf-multiselect:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.cf-field-hint kbd {
    display: inline-block;
    padding: 1px 5px;
    font-size: 11px;
    font-family: monospace;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    color: #374151;
}

/* 1.0.2: Likert scale */
.cf-likert-scale{display:flex;flex-wrap:wrap;gap:8px 16px}
.cf-likert-scale .cf-likert-option{flex:1 1 auto;min-width:110px}

/* 1.0.2: standalone form preview page (admin only) */
.miswebform-preview-page{margin:0;background:#f6f7f7}
.miswebform-preview-bar{position:sticky;top:0;z-index:1000;display:flex;flex-wrap:wrap;gap:8px 16px;align-items:center;justify-content:space-between;padding:10px 20px;background:#1d2327;color:#f0f0f1;font:13px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif}
.miswebform-preview-bar a{color:#72aee6}
.miswebform-preview-main{box-sizing:border-box;max-width:760px;margin:32px auto;padding:32px;background:#fff;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,.08)}
@media (max-width:600px){.miswebform-preview-main{margin:0;padding:20px;border-radius:0}}

/* 1.0.3: textarea counter */
.cf-counter{margin-top:4px;font-size:12px;color:#646970;text-align:right}
.cf-counter--over{color:#b32d2e;font-weight:600}

/* 1.0.3: Email (with Confirm) - one field, two boxes */
.cf-confirm-pair{display:grid;grid-template-columns:1fr 1fr;gap:12px 16px}
.cf-confirm-part{min-width:0}
.cf-label--sub{font-weight:500}
@media (max-width:600px){.cf-confirm-pair{grid-template-columns:1fr}}

/* 2.0.0: WooCommerce order pages */
.miswf-order-form{margin-top:2em}

/* 2.0.0: WooCommerce product customization fields (inside the Add to cart form) */
.miswf-customize{margin:0 0 1.25em;width:100%;flex-basis:100%}
.miswf-customize .cf-field{margin-bottom:14px}
