/* ============================================
   JR Form Builder - Modern Form Styles
   ============================================ */

.jr-form-wrapper {
    background: #ffffff;
    width: 100%;
    box-sizing: border-box;
}

.jr-form-wrapper *,
.jr-form-wrapper *::before,
.jr-form-wrapper *::after {
    box-sizing: border-box;
}

.jr-form-empty {
    padding: 40px;
    background: #fef3c7;
    border: 1px dashed #f59e0b;
    color: #92400e;
    text-align: center;
    border-radius: 8px;
    font-family: inherit;
}

/* ── Header ────────────────────────────── */
.jr-form-header {
    margin-bottom: 30px;
}

.jr-form-title {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 10px 0;
    line-height: 1.3;
}

.jr-form-subtitle {
    font-size: 15px;
    color: #666;
    margin: 0;
    line-height: 1.6;
}

/* ── Form ──────────────────────────────── */
.jr-form {
    position: relative;
}

.jr-form-fields {
    display: flex;
    flex-direction: column;
    row-gap: 20px;
}

/* ── Row Layout ────────────────────────── */
.jr-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
}

.jr-form-field {
    display: flex;
    flex-direction: column;
    flex: 1 1 100%;
    min-width: 0;
}

/* Width classes */
.jr-form-row .jr-field-w-100 { flex: 1 1 100%; }
.jr-form-row .jr-field-w-75  { flex: 0 0 calc(75% - 10px); max-width: calc(75% - 10px); }
.jr-form-row .jr-field-w-66  { flex: 0 0 calc(66.66% - 10px); max-width: calc(66.66% - 10px); }
.jr-form-row .jr-field-w-50  { flex: 0 0 calc(50% - 10px); max-width: calc(50% - 10px); }
.jr-form-row .jr-field-w-33  { flex: 0 0 calc(33.33% - 14px); max-width: calc(33.33% - 14px); }
.jr-form-row .jr-field-w-25  { flex: 0 0 calc(25% - 15px); max-width: calc(25% - 15px); }

/* ── Labels ────────────────────────────── */
.jr-form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
    line-height: 1.4;
}

.jr-required {
    color: #FF8C00;
    font-weight: 700;
    margin-left: 2px;
}

/* ── Input Wrapper ─────────────────────── */
.jr-form-input-wrap {
    position: relative;
    width: 100%;
}

/* ── Inputs / Textarea / Select ─────────── */
.jr-form-input,
.jr-form-textarea,
.jr-form-select {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.5;
    color: #1a1a1a;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-family: inherit;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    box-shadow: none;
}

.jr-form-input:focus,
.jr-form-textarea:focus,
.jr-form-select:focus {
    border-color: #FF8C00;
    box-shadow: 0 0 0 4px rgba(255, 140, 0, 0.15);
    outline: none;
}

.jr-form-input::placeholder,
.jr-form-textarea::placeholder {
    color: #999;
    opacity: 1;
}

.jr-form-textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

/* Error state */
.jr-form-field.jr-has-error .jr-form-input,
.jr-form-field.jr-has-error .jr-form-textarea,
.jr-form-field.jr-has-error .jr-form-select {
    border-color: #dc2626;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1);
}

/* ── Select Wrapper (custom arrow) ─────── */
.jr-form-select-wrap {
    position: relative;
    width: 100%;
}

.jr-form-select {
    padding-right: 40px;
    cursor: pointer;
    background-image: none;
}

.jr-form-select-arrow {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Radio Group ───────────────────────── */
.jr-form-radio-group,
.jr-form-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.jr-form-radio-item,
.jr-form-checkbox-item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    user-select: none;
    line-height: 1.4;
}

.jr-form-radio-item input[type="radio"],
.jr-form-checkbox-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.jr-radio-mark,
.jr-checkbox-mark {
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e1;
    background: #ffffff;
    flex-shrink: 0;
    transition: all 0.2s ease;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.jr-radio-mark {
    border-radius: 50%;
}

.jr-checkbox-mark {
    border-radius: 4px;
}

.jr-form-radio-item input[type="radio"]:checked + .jr-radio-mark {
    border-color: #FF8C00;
}

.jr-form-radio-item input[type="radio"]:checked + .jr-radio-mark::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #FF8C00;
}

.jr-form-checkbox-item input[type="checkbox"]:checked + .jr-checkbox-mark {
    background: #FF8C00;
    border-color: #FF8C00;
}

.jr-form-checkbox-item input[type="checkbox"]:checked + .jr-checkbox-mark::after {
    content: '';
    width: 6px;
    height: 11px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg) translate(-1px, -1px);
}

.jr-form-radio-item input:focus-visible + .jr-radio-mark,
.jr-form-checkbox-item input:focus-visible + .jr-checkbox-mark {
    box-shadow: 0 0 0 4px rgba(255, 140, 0, 0.15);
}

.jr-form-radio-item:hover .jr-radio-mark,
.jr-form-checkbox-item:hover .jr-checkbox-mark {
    border-color: #FF8C00;
}

.jr-checkbox-label,
.jr-radio-label {
    flex: 1;
}

/* Single checkbox spacing */
.jr-form-checkbox-single {
    align-items: flex-start;
}

.jr-form-checkbox-single .jr-checkbox-mark {
    margin-top: 2px;
}

/* ── File Upload Box ───────────────────── */
.jr-form-file-box {
    position: relative;
    background: #f9fafb;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    overflow: hidden;
}

.jr-form-file-box:hover {
    border-color: #FF8C00;
    background: rgba(255, 140, 0, 0.03);
}

.jr-form-file-box.jr-drag-active {
    border-color: #FF8C00;
    background: rgba(255, 140, 0, 0.05);
    transform: scale(1.01);
}

.jr-form-file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.jr-form-file-content {
    position: relative;
    z-index: 1;
    pointer-events: none;
}

.jr-form-file-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    background: #ffffff;
    border-radius: 50%;
    color: #94a3b8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.jr-form-file-icon svg {
    stroke: #94a3b8;
    transition: stroke 0.2s;
}

.jr-form-file-box:hover .jr-form-file-icon svg,
.jr-form-file-box.jr-drag-active .jr-form-file-icon svg {
    stroke: #FF8C00;
}

.jr-form-file-text {
    font-size: 16px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.jr-form-file-subtext {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.jr-form-file-info small {
    font-size: 11px;
    color: #94a3b8;
    letter-spacing: 0.5px;
}

/* File List (after select) */
.jr-form-file-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
    position: relative;
    z-index: 3;
}

.jr-form-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-align: left;
    font-size: 13px;
}

.jr-form-file-item-icon {
    flex-shrink: 0;
    color: #FF8C00;
    display: flex;
    align-items: center;
}

.jr-form-file-item-name {
    flex: 1;
    color: #1a1a1a;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.jr-form-file-item-size {
    color: #94a3b8;
    font-size: 12px;
    flex-shrink: 0;
}

.jr-form-file-item-remove {
    background: none;
    border: none;
    color: #dc2626;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}

.jr-form-file-item-remove:hover {
    background: #fee2e2;
}

/* ── Help Text ─────────────────────────── */
.jr-form-help {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #888;
    line-height: 1.4;
}

/* ── Field Error ───────────────────────── */
.jr-form-field-error {
    display: none;
    margin-top: 6px;
    font-size: 12px;
    color: #dc2626;
    font-weight: 500;
    line-height: 1.4;
}

.jr-form-field-error.jr-show {
    display: block;
}

/* ── HTML Field ────────────────────────── */
.jr-form-html-content {
    padding: 0;
}

/* ── Submit Button ─────────────────────── */
.jr-form-submit-wrap {
    display: flex;
    justify-content: flex-start;
    margin-top: 20px;
}

.jr-form-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 40px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #ffffff;
    background-color: #FF8C00;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
    transition: all 0.25s ease;
    outline: none;
    position: relative;
    overflow: hidden;
}

.jr-form-submit.jr-btn-full {
    width: 100%;
}

.jr-form-submit:hover {
    background-color: #e67e00;
    color: #ffffff;
}

.jr-form-submit.jr-hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 140, 0, 0.3);
}

.jr-form-submit.jr-hover-scale:hover {
    transform: scale(1.03);
}

.jr-form-submit:active {
    transform: translateY(0) scale(1);
}

.jr-form-submit:focus-visible {
    box-shadow: 0 0 0 4px rgba(255, 140, 0, 0.3);
}

.jr-form-btn-icon {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.jr-form-btn-icon svg,
.jr-form-btn-icon i {
    font-size: 16px;
    line-height: 1;
}

.jr-form-btn-spinner {
    display: none;
    align-items: center;
    margin-left: 8px;
}

.jr-form-btn-spinner svg {
    animation: jrFormSpin 0.7s linear infinite;
}

@keyframes jrFormSpin {
    to { transform: rotate(360deg); }
}

/* Loading state */
.jr-form-submit.jr-is-loading {
    cursor: wait;
    opacity: 0.85;
    pointer-events: none;
}

.jr-form-submit.jr-is-loading .jr-form-btn-spinner {
    display: inline-flex;
}

.jr-form-submit.jr-is-loading .jr-form-btn-icon {
    display: none;
}

/* ── Messages ──────────────────────────── */
.jr-form-messages {
    margin-bottom: 20px;
}

.jr-form-messages:empty {
    display: none;
    margin: 0;
}

.jr-form-message {
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    border-left: 4px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: jrFormFadeIn 0.4s ease;
}

.jr-form-message.jr-success {
    background-color: #d1f4d6;
    color: #15803d;
    border-color: #15803d;
}

.jr-form-message.jr-error {
    background-color: #fee2e2;
    color: #dc2626;
    border-color: #dc2626;
}

.jr-form-message-icon {
    flex-shrink: 0;
    line-height: 1;
}

.jr-form-message-text {
    flex: 1;
}

@keyframes jrFormFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form submitted (hide) */
.jr-form.jr-submitted {
    display: none;
}

/* ── Responsive ────────────────────────── */
@media (max-width: 767px) {
    .jr-form-wrapper {
        padding: 24px !important;
    }

    .jr-form-title {
        font-size: 22px;
    }

    .jr-form-subtitle {
        font-size: 14px;
    }

    /* Stack all fields on mobile */
    .jr-form-row .jr-form-field {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }

    .jr-form-submit {
        width: 100%;
        padding: 14px 24px;
    }

    .jr-form-file-box {
        padding: 28px 16px;
    }

    .jr-form-file-icon {
        width: 48px;
        height: 48px;
    }
}

@media (max-width: 480px) {
    .jr-form-row {
        gap: 16px;
    }

    .jr-form-fields {
        row-gap: 16px;
    }
}

/* ── Submitted State ──────────────────── */
.jr-form.jr-submitted,
.jr-form-header.jr-submitted {
    display: none !important;
}

/* Success message container (outside form) */
.jr-form-success-container {
    animation: jrFormFadeIn 0.4s ease;
}

.jr-form-success-container .jr-form-message {
    margin-bottom: 0;
}