/* Arya Form Builder — front styles (scoped under .afb, theme-agnostic, RTL aware) */
.afb { --afb-primary: #3644d2; --afb-radius: 10px; --afb-text: #1f2937; --afb-muted: #6b7280; --afb-border: #d1d5db; --afb-bg: #fff; --afb-danger: #dc2626; --afb-ok: #16a34a;
    position: relative; color: var(--afb-text); font-family: inherit; line-height: 1.7; box-sizing: border-box; }
.afb *, .afb *::before, .afb *::after { box-sizing: border-box; }
.afb [hidden], .afb .afb-hidden { display: none !important; }
.afb-title { margin: 0 0 .4rem; font-size: 1.5rem; font-weight: 800; }
.afb-desc { margin: 0 0 1.2rem; color: var(--afb-muted); }
.afb-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem 1rem; }
.afb-field { grid-column: span 12; min-width: 0; position: relative; }
@media (min-width: 640px) {
    .afb-col-9 { grid-column: span 9; } .afb-col-8 { grid-column: span 8; } .afb-col-6 { grid-column: span 6; }
    .afb-col-4 { grid-column: span 4; } .afb-col-3 { grid-column: span 3; }
}
.afb-label { display: block; margin-bottom: .35rem; font-weight: 600; font-size: .95rem; }
.afb-label-inline { margin: 0 .5rem; display: inline; }
.afb-req { color: var(--afb-danger); margin-inline-start: .2rem; }
.afb-input { width: 100%; padding: .65rem .85rem; border: 1px solid var(--afb-border); border-radius: var(--afb-radius); background: var(--afb-bg);
    color: inherit; font: inherit; transition: border-color .15s, box-shadow .15s; min-height: 2.75rem; }
.afb-input:focus { outline: none; border-color: var(--afb-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--afb-primary) 20%, transparent); }
textarea.afb-input { resize: vertical; min-height: 6rem; }
.afb-field.has-error .afb-input, .afb-field.has-error .afb-drop, .afb-field.has-error .afb-sign { border-color: var(--afb-danger); }
.afb-error { color: var(--afb-danger); font-size: .85rem; margin-top: .3rem; min-height: 0; }
.afb-error:empty { display: none; }
.afb-help { color: var(--afb-muted); font-size: .85rem; margin-top: .3rem; }

/* choices */
.afb-choices { display: flex; flex-direction: column; gap: .5rem; }
.afb-choices.afb-inline { flex-direction: row; flex-wrap: wrap; gap: .5rem 1.4rem; }
.afb-choice { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; margin: 0; }
.afb-choice input { position: absolute; opacity: 0; pointer-events: none; }
.afb-choice-mark { width: 1.25rem; height: 1.25rem; border: 2px solid var(--afb-border); border-radius: 50%; flex: none; display: grid; place-items: center; transition: .15s; background: var(--afb-bg); }
.afb-type-checkbox .afb-choice-mark { border-radius: 6px; }
.afb-choice input:checked + .afb-choice-mark { border-color: var(--afb-primary); background: var(--afb-primary); }
.afb-choice input:checked + .afb-choice-mark::after { content: ''; width: .45rem; height: .45rem; background: #fff; border-radius: 50%; }
.afb-type-checkbox .afb-choice input:checked + .afb-choice-mark::after { width: .3rem; height: .6rem; border-radius: 0; background: transparent; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.afb-choice input:focus-visible + .afb-choice-mark { box-shadow: 0 0 0 3px color-mix(in srgb, var(--afb-primary) 30%, transparent); }
.afb-price-tag { color: var(--afb-muted); }

/* switch */
.afb-switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; }
.afb-switch input { position: absolute; opacity: 0; }
.afb-switch-track { width: 2.8rem; height: 1.5rem; border-radius: 999px; background: #cbd5e1; position: relative; transition: .2s; flex: none; }
.afb-switch-track::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.afb-switch input:checked + .afb-switch-track { background: var(--afb-primary); }
.afb-switch input:checked + .afb-switch-track::after { inset-inline-start: calc(100% - 1.1rem - 3px); }
.afb-switch input:focus-visible + .afb-switch-track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--afb-primary) 30%, transparent); }
.afb-switch-text { font-weight: 600; color: var(--afb-muted); min-width: 2rem; }

/* range / rating */
.afb-range { display: flex; align-items: center; gap: .8rem; }
.afb-range input { flex: 1; accent-color: var(--afb-primary); }
.afb-range output { min-width: 3rem; font-weight: 700; text-align: center; }
.afb-rating { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; gap: .15rem; }
.afb-rating input { position: absolute; opacity: 0; }
.afb-rating label { font-size: 1.9rem; line-height: 1; color: #d1d5db; cursor: pointer; transition: color .15s; }
.afb-rating label:hover, .afb-rating label:hover ~ label, .afb-rating input:checked ~ label { color: #f59e0b; }
.afb-rating input:focus-visible + label { outline: 2px solid var(--afb-primary); border-radius: 4px; }

/* file drop */
.afb-drop { position: relative; border: 2px dashed var(--afb-border); border-radius: var(--afb-radius); padding: 1.4rem 1rem; text-align: center; background: color-mix(in srgb, var(--afb-primary) 3%, #fff); transition: .15s; }
.afb-drop.is-over, .afb-drop:hover { border-color: var(--afb-primary); background: color-mix(in srgb, var(--afb-primary) 8%, #fff); }
.afb-drop input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.afb-drop-text strong { display: block; }
.afb-drop-text small { color: var(--afb-muted); }
.afb-files { list-style: none; margin: .5rem 0 0; padding: 0; }
.afb-files li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .35rem .7rem; background: #f3f4f6; border-radius: 8px; margin-bottom: .3rem; font-size: .88rem; }
.afb-files button { border: 0; background: transparent; color: var(--afb-danger); font-size: 1.2rem; cursor: pointer; line-height: 1; }

/* signature */
.afb-sign { border: 1px solid var(--afb-border); border-radius: var(--afb-radius); background: #fff; overflow: hidden; margin-bottom: .4rem; }
.afb-sign canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }

/* price / headings */
.afb-price-line { display: flex; justify-content: space-between; padding: .7rem 1rem; background: color-mix(in srgb, var(--afb-primary) 8%, #fff); border-radius: var(--afb-radius); font-weight: 600; }
.afb-heading { margin: .6rem 0 0; font-weight: 800; }
.afb-paragraph { color: var(--afb-muted); }
.afb-paragraph p:first-child { margin-top: 0; } .afb-paragraph p:last-child { margin-bottom: 0; }
.afb-divider { border: 0; border-top: 1px solid var(--afb-border); margin: .4rem 0; }
.afb-total { display: flex; gap: .6rem; align-items: baseline; margin-top: 1rem; padding: .9rem 1.1rem; background: color-mix(in srgb, var(--afb-primary) 8%, #fff); border-radius: var(--afb-radius); }
.afb-total strong { font-size: 1.4rem; color: var(--afb-primary); }

/* steps */
.afb-progress { margin-bottom: 1.4rem; position: relative; }
.afb-progress::before { content: ''; display: block; height: 6px; background: #e5e7eb; border-radius: 99px; }
.afb-progress-bar { position: absolute; top: 0; inset-inline-start: 0; height: 6px; background: var(--afb-primary); border-radius: 99px; transition: width .3s; }
.afb-progress-steps { list-style: none; display: flex; justify-content: space-between; margin: .7rem 0 0; padding: 0; gap: .4rem; }
.afb-progress-steps li { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--afb-muted); flex: 1; min-width: 0; }
.afb-progress-steps li span { width: 1.7rem; height: 1.7rem; border-radius: 50%; background: #e5e7eb; display: grid; place-items: center; font-weight: 700; flex: none; }
.afb-progress-steps li em { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.afb-progress-steps li.is-current { color: var(--afb-text); font-weight: 700; }
.afb-progress-steps li.is-current span, .afb-progress-steps li.is-done span { background: var(--afb-primary); color: #fff; }
@media (max-width: 560px) { .afb-progress-steps em { display: none; } }
.afb-step-title { margin: 0 0 .3rem; font-size: 1.15rem; font-weight: 800; }
.afb-step-desc { margin: 0 0 1rem; color: var(--afb-muted); }
.afb-step:not([hidden]) { animation: afb-in .25s ease; }
@keyframes afb-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* buttons & alerts */
.afb-nav { display: flex; gap: .6rem; margin-top: 1.4rem; justify-content: flex-end; flex-wrap: wrap; }
.afb-btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .7rem 1.6rem; border: 1px solid var(--afb-primary); background: var(--afb-primary); color: #fff; border-radius: var(--afb-radius); cursor: pointer; font: inherit; font-weight: 700; text-decoration: none; transition: .15s; }
.afb-btn:hover { filter: brightness(1.08); }
.afb-btn:disabled { opacity: .6; cursor: not-allowed; }
.afb-btn.is-loading { pointer-events: none; }
.afb-btn-ghost { background: transparent; color: var(--afb-primary); }
.afb-btn-sm { padding: .3rem .8rem; font-size: .85rem; margin-top: .3rem; }
.afb-alert { margin-top: 1rem; padding: .75rem 1rem; border-radius: var(--afb-radius); background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.afb-alert-ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.afb-alert-warn { background: #fffbeb; color: #92400e; border-color: #fde68a; margin-bottom: 1rem; }
.afb-captcha { margin-top: 1rem; max-width: 320px; }
.afb-captcha-q { color: var(--afb-primary); font-size: 1.1rem; }
.afb-link { margin-inline-start: .6rem; color: var(--afb-primary); }

/* success */
.afb-success { text-align: center; padding: 2rem 1rem; }
.afb-success-icon { width: 4rem; height: 4rem; margin: 0 auto 1rem; border-radius: 50%; background: var(--afb-ok); color: #fff; display: grid; place-items: center; font-size: 2rem; }
.afb-success-msg { font-size: 1.1rem; margin-bottom: 1rem; }
.afb-track { display: inline-flex; gap: .6rem; align-items: center; flex-wrap: wrap; justify-content: center; padding: .8rem 1.2rem; background: #f3f4f6; border-radius: var(--afb-radius); margin-bottom: 1rem; }

/* calendar popup */
.afb-cal { position: absolute; z-index: 50; top: calc(100% + 4px); inset-inline-start: 0; width: 290px; max-width: 100%; background: #fff; border: 1px solid var(--afb-border); border-radius: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: .7rem; }
.afb-cal-head { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-bottom: .5rem; }
.afb-cal-head button { border: 0; background: #f3f4f6; width: 2rem; height: 2rem; border-radius: 8px; cursor: pointer; font-size: 1.2rem; }
.afb-cal-title { display: flex; gap: .3rem; flex: 1; }
.afb-cal-title select { flex: 1; padding: .25rem; border: 1px solid var(--afb-border); border-radius: 8px; background: #fff; font: inherit; font-size: .85rem; min-width: 0; }
.afb-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.afb-cal-wd { font-size: .75rem; color: var(--afb-muted); padding: .2rem 0; }
.afb-cal-day { border: 0; background: transparent; padding: .45rem 0; border-radius: 8px; cursor: pointer; font: inherit; font-size: .88rem; }
.afb-cal-day:hover:not(:disabled) { background: color-mix(in srgb, var(--afb-primary) 12%, #fff); }
.afb-cal-day.is-today { outline: 1px solid var(--afb-primary); }
.afb-cal-day.is-sel { background: var(--afb-primary); color: #fff; }
.afb-cal-day:disabled { color: #d1d5db; cursor: not-allowed; }
.afb-cal-foot { display: flex; justify-content: space-between; margin-top: .5rem; }
.afb-cal-foot button { border: 0; background: transparent; color: var(--afb-primary); cursor: pointer; font: inherit; font-size: .85rem; }

/* tracking page */
.afb-track-form { display: flex; gap: .6rem; margin: 1rem 0; }
.afb-track-form .afb-input { max-width: 260px; }
.afb-track-card { border: 1px solid var(--afb-border); border-radius: var(--afb-radius); margin: 1rem 0; overflow: hidden; }
.afb-track-row { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem 1rem; border-bottom: 1px solid #f3f4f6; }
.afb-track-row:last-child { border: 0; }
.afb-track-row span { color: var(--afb-muted); }
.afb-track-reply { background: #f9fafb; border-inline-start: 4px solid var(--afb-primary); padding: .8rem 1rem; border-radius: 8px; margin-bottom: .6rem; }
.afb-track-reply small { color: var(--afb-muted); display: block; margin-bottom: .2rem; }

.afb-cal-mode { display: flex; gap: 4px; margin-bottom: .5rem; background: #f3f4f6; border-radius: 8px; padding: 3px; }
.afb-cal-mode button { flex: 1; border: 0; background: transparent; border-radius: 6px; padding: 4px 8px; font: inherit; font-size: .8rem; cursor: pointer; color: inherit; }
.afb-cal-mode button.on { background: var(--afb-primary); color: #fff; }

/* overall form width (setting) — centered, full width on small screens */
.afb[data-afb] { box-sizing: border-box; width: 100%; margin-inline: auto; }
@media (min-width: 768px) { .afb[data-afb] { width: var(--afb-width, 100%); } }
.afb-page-wrap { width: 100%; box-sizing: border-box; padding: 24px 16px; }
.afb-track-page { box-sizing: border-box; width: 100%; max-width: 560px; margin: 24px auto; }
@media (min-width: 768px) { .afb-track-page { width: 100%; } }
.afb-track-form { display: flex; gap: .5rem; justify-content: center; }
.afb-track-form .afb-input { flex: 1; max-width: 320px; }
.afb-track-page .afb-title { text-align: center; }

.afb[data-afb] { position: relative; overflow-x: clip; }
