/**
 * BareBonesForms — Default Styles  v2.0
 *
 * THEMING: Override the --bbf-* CSS variables below to customize colors,
 * fonts, spacing, and more. All visual properties use these variables.
 *
 * Three ways to customize:
 *   1. Override --bbf-* variables in your stylesheet (easiest)
 *   2. Override individual .bbf-* classes
 *   3. Delete this file and write your own from scratch
 *
 * See bbf-theme.css for example themes (dark mode, branded, etc.)
 *
 * AI models: Search for "--bbf-" to find all customizable variables.
 * All form classes use the ".bbf-" prefix — grep ".bbf-" for full list.
 */

/* ═══════════════════════════════════════════════════════
   THEME VARIABLES — Override these to customize the form
   ═══════════════════════════════════════════════════════ */

:root {
    /* ── Typography ─────────────────── */
    --bbf-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --bbf-font-size: 15px;

    /* ── Layout ─────────────────────── */
    --bbf-max-width: 540px;
    --bbf-radius: 5px;
    --bbf-spacing: 16px;         /* vertical gap between fields */

    /* ── Colors: text ───────────────── */
    --bbf-text: #1a1a1a;         /* main text */
    --bbf-text-muted: #666;      /* descriptions, labels */
    --bbf-text-light: #6b6b6b;      /* hints, placeholders */

    /* ── Colors: backgrounds ────────── */
    --bbf-bg: #fff;              /* input backgrounds */
    --bbf-bg-alt: #f0f0f0;       /* prefix/suffix, nav buttons */
    --bbf-bg-readonly: #f5f5f5;  /* readonly fields */
    --bbf-bg-hover: #f0f4ff;     /* autocomplete hover */

    /* ── Colors: borders ────────────── */
    --bbf-border: #d0d0d0;       /* input borders */
    --bbf-border-light: #e0e0e0; /* section dividers */

    /* ── Colors: focus ──────────────── */
    --bbf-focus: #4a90d9;        /* focus ring color */
    --bbf-focus-shadow: rgba(74, 144, 217, 0.15);

    /* ── Colors: buttons ────────────── */
    --bbf-btn-bg: #1a1a1a;
    --bbf-btn-text: #fff;
    --bbf-btn-hover: #333;
    --bbf-btn-disabled: #999;

    /* ── Colors: validation ─────────── */
    --bbf-error: #dc3545;
    --bbf-error-bg: #fdecea;
    --bbf-error-border: #f5c6cb;
    --bbf-error-shadow: rgba(220, 53, 69, 0.15);
    --bbf-success: #1a7a1a;
    --bbf-success-bg: #eafbe7;
    --bbf-success-border: #b8e6b0;

    /* ── Colors: rating stars ───────── */
    --bbf-star: #d0d0d0;
    --bbf-star-active: #f5a623;
    --bbf-star-hover: #ffc107;
}

/* ═══════════════════════════════════════════════════════
   FORM STRUCTURE
   ═══════════════════════════════════════════════════════ */

.bbf-form-container {
    max-width: var(--bbf-max-width);
    margin: 0 auto;
    font-family: var(--bbf-font);
    font-size: var(--bbf-font-size);
    color: var(--bbf-text);
}

.bbf-title {
    font-size: 1.4em;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.bbf-description {
    color: var(--bbf-text-muted);
    margin: 0 0 20px 0;
    font-size: 0.93em;
}

/* ─── Fields ─────────────────────────── */

.bbf-field {
    margin-bottom: var(--bbf-spacing);
}

.bbf-label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
    font-size: 0.93em;
}

.bbf-required {
    color: var(--bbf-error);
}

.bbf-field-desc {
    display: block;
    color: var(--bbf-text-light);
    font-size: 0.82em;
    margin-bottom: 4px;
}

.bbf-input,
.bbf-form select,
.bbf-form textarea {
    display: block;
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--bbf-border);
    border-radius: var(--bbf-radius);
    font-size: var(--bbf-font-size);
    font-family: inherit;
    color: var(--bbf-text);
    background: var(--bbf-bg);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.bbf-input:focus,
.bbf-form select:focus,
.bbf-form textarea:focus {
    outline: none;
    border-color: var(--bbf-focus);
    box-shadow: 0 0 0 3px var(--bbf-focus-shadow);
}

/* ─── Field sizes ────────────────────── */

.bbf-size-small {
    max-width: 25%;
    min-width: 120px;
}

.bbf-size-medium {
    max-width: 50%;
    min-width: 180px;
}

/* large = default 100%, no class needed */

/* ─── Label position: left ───────────── */

.bbf-label-left {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
}

.bbf-label-left > .bbf-label {
    flex: 1 1 auto;
    min-width: 100px;
    margin-bottom: 0;
}

.bbf-label-left > .bbf-input,
.bbf-label-left > .bbf-input-group,
.bbf-label-left > select.bbf-input {
    flex: 1 1 auto;
    min-width: 0;
}

.bbf-label-left > .bbf-field-desc {
    flex-basis: 100%;
}

.bbf-label-left > .bbf-field-error {
    flex-basis: 100%;
}

/* ─── Input prefix / suffix ──────────── */

.bbf-input-group {
    display: flex;
    align-items: stretch;
}

.bbf-input-group > .bbf-input {
    flex: 1 1 auto;
    min-width: 0;
    border-radius: 0;
}

.bbf-input-prefix,
.bbf-input-suffix {
    display: flex;
    align-items: center;
    padding: 0 10px;
    background: var(--bbf-bg-alt);
    border: 1px solid var(--bbf-border);
    color: var(--bbf-text-muted);
    font-size: 0.9em;
    white-space: nowrap;
}

.bbf-input-prefix {
    border-right: none;
    border-radius: var(--bbf-radius) 0 0 var(--bbf-radius);
}

.bbf-input-suffix {
    border-left: none;
    border-radius: 0 var(--bbf-radius) var(--bbf-radius) 0;
}

.bbf-input-group > .bbf-input:first-child {
    border-radius: var(--bbf-radius) 0 0 var(--bbf-radius);
}

.bbf-input-group > .bbf-input:last-child {
    border-radius: 0 var(--bbf-radius) var(--bbf-radius) 0;
}

.bbf-input-group > .bbf-input:only-child {
    border-radius: var(--bbf-radius);
}

/* ─── Readonly ───────────────────────── */

.bbf-readonly {
    background: var(--bbf-bg-readonly);
    color: var(--bbf-text-muted);
    cursor: not-allowed;
}

/* ─── Errors ─────────────────────────── */

.bbf-has-error .bbf-input,
.bbf-has-error select,
.bbf-has-error textarea {
    border-color: var(--bbf-error);
}

.bbf-has-error .bbf-input:focus {
    box-shadow: 0 0 0 3px var(--bbf-error-shadow);
}

.bbf-field-error {
    color: var(--bbf-error);
    font-size: 0.82em;
    margin-top: 4px;
    min-height: 0;
}

/* ─── Fieldset (radio, checkbox groups) ─ */

.bbf-fieldset {
    border: none;
    padding: 0;
    margin: 0 0 var(--bbf-spacing) 0;
}

.bbf-fieldset legend.bbf-label {
    padding: 0;
    margin-bottom: 5px;
}

/* ─── Options (radio, checkbox) ──────── */

.bbf-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bbf-option {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-weight: normal;
}

.bbf-option input {
    margin: 0;
}

/* ─── Custom radio & checkbox ────────── */

.bbf-option input[type="radio"],
.bbf-option input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--bbf-border);
    background: var(--bbf-bg);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.bbf-option input[type="radio"] {
    border-radius: 50%;
}

.bbf-option input[type="checkbox"] {
    border-radius: 3px;
}

.bbf-option input[type="radio"]:checked,
.bbf-option input[type="checkbox"]:checked {
    border-color: var(--bbf-focus);
    background: var(--bbf-focus);
}

.bbf-option input[type="radio"]:checked {
    background: radial-gradient(circle, var(--bbf-bg) 30%, var(--bbf-focus) 32%);
}

.bbf-option input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2.5-2.5a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3E%3C/svg%3E");
    background-size: 12px;
    background-position: center;
    background-repeat: no-repeat;
}

.bbf-option input[type="radio"]:focus-visible,
.bbf-option input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--bbf-focus-shadow);
}

.bbf-option input[type="radio"]:hover:not(:checked),
.bbf-option input[type="checkbox"]:hover:not(:checked) {
    border-color: var(--bbf-focus);
}

/* ─── Column layout for options ──────── */

.bbf-columns-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.bbf-columns-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
}

.bbf-columns-inline {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px 16px;
}

/* "Other" text input inside options */
.bbf-other-input {
    grid-column: 1 / -1;
}

/* ─── Section break ──────────────────── */

.bbf-section {
    margin-top: 24px;
    margin-bottom: 12px;
    padding-top: var(--bbf-spacing);
    border-top: 1px solid var(--bbf-border-light);
}

.bbf-section:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

.bbf-section-title {
    font-size: 1.15em;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.bbf-section-desc {
    color: var(--bbf-text-muted);
    font-size: 0.9em;
    margin: 0;
}

/* ─── Repeatable groups ──────────────── */

.bbf-repeatable-row {
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid var(--bbf-border-light);
    border-radius: var(--bbf-radius);
}

.bbf-repeatable-row-title {
    padding: 0 4px;
    font-weight: 600;
}

.bbf-repeatable-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bbf-repeatable-add,
.bbf-repeatable-remove {
    padding: 7px 12px;
    border: 1px solid var(--bbf-border);
    border-radius: var(--bbf-radius);
    background: var(--bbf-bg-alt);
    color: var(--bbf-text);
    cursor: pointer;
    font-family: inherit;
}

.bbf-repeatable-add:disabled,
.bbf-repeatable-remove:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.bbf-repeatable-status {
    color: var(--bbf-text-light);
    font-size: 0.85em;
}

/* ─── Rating (stars) ─────────────────── */

.bbf-rating-stars {
    display: flex;
    gap: 4px;
}

.bbf-star {
    font-size: 1.6em;
    color: var(--bbf-star);
    cursor: pointer;
    transition: color 0.1s;
    user-select: none;
    line-height: 1;
}

.bbf-star:focus {
    outline: 2px solid var(--bbf-focus);
    outline-offset: 2px;
    border-radius: 2px;
}

.bbf-star-active {
    color: var(--bbf-star-active);
}

.bbf-star-hover {
    color: var(--bbf-star-hover);
}

/* ─── Multi-page navigation ──────────── */

.bbf-page-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
    flex-wrap: wrap;
}

.bbf-page-indicator {
    font-size: 0.85em;
    color: var(--bbf-text-light);
}

/* Read by screen readers, not shown (page-change announcements). */
.bbf-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.bbf-prev,
.bbf-next {
    display: inline-block;
    padding: 9px 22px;
    background: var(--bbf-bg-alt);
    color: var(--bbf-text);
    border: 1px solid var(--bbf-border);
    border-radius: var(--bbf-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.bbf-prev:hover,
.bbf-next:hover {
    background: var(--bbf-border-light);
}

/* ─── Label position variants ────────── */

.bbf-labels-left .bbf-field:not(.bbf-section):not(.bbf-submit-wrap):not(.bbf-page-nav) {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0 12px;
}

.bbf-labels-left .bbf-label {
    flex: 0 0 140px;
    text-align: right;
    padding-top: 9px;
}

.bbf-labels-left .bbf-input,
.bbf-labels-left select,
.bbf-labels-left textarea {
    flex: 1;
    min-width: 0;
}

.bbf-labels-left .bbf-field-desc,
.bbf-labels-left .bbf-field-error {
    flex-basis: 100%;
    margin-left: 152px;
}

.bbf-labels-right .bbf-field:not(.bbf-section):not(.bbf-submit-wrap):not(.bbf-page-nav) {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0 12px;
}

.bbf-labels-right .bbf-label {
    flex: 0 0 140px;
    text-align: left;
    padding-top: 9px;
}

.bbf-labels-right .bbf-input,
.bbf-labels-right select,
.bbf-labels-right textarea {
    flex: 1;
    min-width: 0;
}

.bbf-labels-right .bbf-field-desc,
.bbf-labels-right .bbf-field-error {
    flex-basis: 100%;
    margin-left: 152px;
}

/* ─── Submit ─────────────────────────── */

.bbf-submit {
    display: inline-block;
    padding: 10px 28px;
    background: var(--bbf-btn-bg);
    color: var(--bbf-btn-text);
    border: none;
    border-radius: var(--bbf-radius);
    font-size: var(--bbf-font-size);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}

.bbf-submit:hover {
    background: var(--bbf-btn-hover);
}

.bbf-submit:disabled {
    background: var(--bbf-btn-disabled);
    cursor: not-allowed;
}

.bbf-draft-controls {
    padding: 12px;
    border: 1px solid var(--bbf-border-light);
    border-radius: var(--bbf-radius);
}

.bbf-draft-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.bbf-draft-actions button {
    padding: 7px 12px;
    border: 1px solid var(--bbf-border);
    border-radius: var(--bbf-radius);
    background: var(--bbf-bg-alt);
    color: var(--bbf-text);
    cursor: pointer;
}

.bbf-draft-actions button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.bbf-draft-status {
    margin-top: 8px;
    font-size: 0.9em;
}

/* ─── Messages ───────────────────────── */

.bbf-message {
    padding: 12px 16px;
    border-radius: var(--bbf-radius);
    margin-top: 12px;
    font-size: 0.93em;
}

.bbf-success {
    background: var(--bbf-success-bg);
    color: var(--bbf-success);
    border: 1px solid var(--bbf-success-border);
}

.bbf-error {
    background: var(--bbf-error-bg);
    color: var(--bbf-error);
    border: 1px solid var(--bbf-error-border);
}

/* ─── Autocomplete dropdown ──────────── */

.bbf-autocomplete-list {
    position: absolute;
    z-index: 100;
    left: 0;
    min-width: 100%;
    width: max-content;
    background: var(--bbf-bg);
    border: 1px solid var(--bbf-border);
    border-top: none;
    border-radius: 0 0 var(--bbf-radius) var(--bbf-radius);
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.bbf-autocomplete-item {
    padding: 8px 11px;
    cursor: pointer;
    font-size: 0.93em;
}

.bbf-autocomplete-item:hover,
.bbf-autocomplete-active {
    background: var(--bbf-bg-hover);
    color: var(--bbf-text);
}

/* ─── Loading ────────────────────────── */

.bbf-spinner {
    text-align: center;
    padding: 24px;
    color: var(--bbf-text-light);
}

/* ─── File uploads ─────────────────────────────────────────── */

.bbf-file-list {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
}

.bbf-file {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid var(--bbf-border-light);
    border-radius: var(--bbf-radius);
    margin-bottom: 4px;
    font-size: 0.9em;
}

.bbf-file-name { flex: 1 1 auto; overflow-wrap: anywhere; }
.bbf-file-size { color: var(--bbf-text-muted); }
.bbf-file-progress { flex: 0 0 100px; }
.bbf-file-message { flex-basis: 100%; }

.bbf-file-error {
    border-color: var(--bbf-error-border);
    background: var(--bbf-error-bg);
    color: var(--bbf-error);
}

.bbf-file-remove, .bbf-file-retry {
    border: 1px solid var(--bbf-border);
    background: var(--bbf-bg);
    color: var(--bbf-text);
    border-radius: var(--bbf-radius);
    cursor: pointer;
    padding: 2px 8px;
    font: inherit;
}

.bbf-file-status { font-size: 0.85em; color: var(--bbf-text-muted); margin-top: 4px; }

/* The stored file when editing (embedded mode): preview or link, and "remove" */
.bbf-file-current { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.bbf-file-preview { display: block; max-width: 160px; max-height: 120px; border: 1px solid var(--bbf-border-light); border-radius: var(--bbf-radius); }
.bbf-file-current .bbf-file-link { overflow-wrap: anywhere; }
