/* ==========================================================================
   Qado RFQ — Native Submission Form Styles
   Appended to rfq.css or loaded separately as rfq-form.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   Form wrapper
   -------------------------------------------------------------------------- */
.qado-rfq-form-wrap {
    font-family: var(--rfq-font);
    color: var(--rfq-text);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Success state
   -------------------------------------------------------------------------- */
.qado-form-success {
    text-align: center;
    padding: 56px 24px;
    background: var(--rfq-white);
    border: 1px solid var(--rfq-border);
    border-radius: var(--rfq-radius-lg);
}

.qado-form-success__icon {
    margin-bottom: 20px;
}

.qado-form-success__title {
    font-size: clamp(20px, 3vw, 26px);
    font-weight: 800;
    color: var(--rfq-navy);
    margin: 0 0 12px;
}

.qado-form-success__text {
    font-size: 15px;
    color: var(--rfq-text-light);
    max-width: 520px;
    margin: 0 auto 24px;
    line-height: 1.7;
}

/* --------------------------------------------------------------------------
   Alert banners
   -------------------------------------------------------------------------- */
.qado-form-alert {
    padding: 12px 16px;
    border-radius: var(--rfq-radius);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.qado-form-alert::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
}

.qado-form-alert--error {
    background: #fdf0ef;
    color: #b03a2e;
    border: 1px solid #f5b7b1;
}

.qado-form-alert--error::before {
    background: #e74c3c;
    mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 8v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z'/%3E%3C/svg%3E");
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 8v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z'/%3E%3C/svg%3E");
}

.qado-form-alert--success {
    background: #eafaf1;
    color: #1e8449;
    border: 1px solid #a9dfbf;
}

/* --------------------------------------------------------------------------
   Form layout
   -------------------------------------------------------------------------- */
.qado-rfq-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Honeypot — visually hidden, screen-reader accessible */
.qado-hp-field {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --------------------------------------------------------------------------
   Form sections (fieldsets)
   -------------------------------------------------------------------------- */
.qado-form-section {
    border: 0;
    padding: 0;
    margin: 0 0 32px;
}

.qado-form-section__title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--rfq-text-light);
    padding: 0;
    margin: 0 0 20px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
}

.qado-form-section__title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--rfq-border);
}

/* --------------------------------------------------------------------------
   Row helpers
   -------------------------------------------------------------------------- */
.qado-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.qado-form-row--3col {
    grid-template-columns: 1fr 1fr 1fr;
}

.qado-form-row--4col {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

@media (max-width: 900px) {
    .qado-form-row--3col { grid-template-columns: 1fr 1fr; }
    .qado-form-row--4col { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
    .qado-form-row,
    .qado-form-row--3col,
    .qado-form-row--4col { grid-template-columns: 1fr; }
}

/* Grow: takes remaining space in a flex/grid context */
.qado-field-group--grow { grid-column: span 1; }
.qado-field-group--full { grid-column: 1 / -1; }

/* --------------------------------------------------------------------------
   Field groups
   -------------------------------------------------------------------------- */
.qado-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.qado-field-group:last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   Labels
   -------------------------------------------------------------------------- */
.qado-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--rfq-text);
    display: flex;
    align-items: baseline;
    gap: 5px;
    flex-wrap: wrap;
}

.qado-required {
    color: var(--rfq-primary);
    font-size: 15px;
    line-height: 1;
}

.qado-label-hint {
    font-size: 11px;
    font-weight: 400;
    color: var(--rfq-text-light);
    margin-left: auto;
}

/* --------------------------------------------------------------------------
   Text inputs & textarea
   -------------------------------------------------------------------------- */
.qado-input,
.qado-select,
.qado-textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--rfq-border);
    border-radius: var(--rfq-radius);
    font-size: 14px;
    font-family: var(--rfq-font);
    color: var(--rfq-text);
    background: var(--rfq-white);
    transition: border-color var(--rfq-transition), box-shadow var(--rfq-transition);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    line-height: 1.4;
}

.qado-input::placeholder,
.qado-textarea::placeholder {
    color: var(--rfq-muted);
    font-size: 13px;
}

.qado-input:focus,
.qado-select:focus,
.qado-textarea:focus {
    border-color: var(--rfq-primary);
    box-shadow: 0 0 0 3px rgba(229, 115, 37, .12);
}

.qado-textarea {
    resize: vertical;
    min-height: 120px;
}

/* Error state */
.qado-field-error .qado-input,
.qado-field-error .qado-select,
.qado-field-error .qado-textarea,
.qado-field-error .qado-upload-zone {
    border-color: var(--rfq-danger);
}

.qado-field-error .qado-input:focus,
.qado-field-error .qado-select:focus {
    box-shadow: 0 0 0 3px rgba(231, 76, 60, .12);
}

.qado-error-msg {
    font-size: 12px;
    color: var(--rfq-danger);
    display: flex;
    align-items: center;
    gap: 4px;
}

.qado-error-msg::before {
    content: '⚠';
    font-size: 11px;
}

/* --------------------------------------------------------------------------
   Prefix input (budget $)
   -------------------------------------------------------------------------- */
.qado-input-prefix-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.qado-input-prefix {
    position: absolute;
    left: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--rfq-text-light);
    pointer-events: none;
    z-index: 1;
}

.qado-input--prefixed {
    padding-left: 26px;
}

/* --------------------------------------------------------------------------
   Select wrapper (custom arrow)
   -------------------------------------------------------------------------- */
.qado-select-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.qado-select {
    padding-right: 36px;
    cursor: pointer;
}

.qado-select-arrow {
    position: absolute;
    right: 12px;
    color: var(--rfq-text-light);
    pointer-events: none;
    display: flex;
    align-items: center;
    z-index: 1;
}

.qado-select-wrap .qado-select { width: 100%; }

/* --------------------------------------------------------------------------
   Radio group
   -------------------------------------------------------------------------- */
.qado-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    align-items: center;
}

.qado-radio-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.qado-radio-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.qado-radio-custom {
    width: 18px;
    height: 18px;
    border: 2px solid var(--rfq-border);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color var(--rfq-transition), background var(--rfq-transition);
}

.qado-radio-custom::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--rfq-primary);
    opacity: 0;
    transition: opacity var(--rfq-transition);
}

.qado-radio-label input[type="radio"]:checked ~ .qado-radio-custom {
    border-color: var(--rfq-primary);
}

.qado-radio-label input[type="radio"]:checked ~ .qado-radio-custom::after {
    opacity: 1;
}

.qado-radio-label input[type="radio"]:focus-visible ~ .qado-radio-custom {
    box-shadow: 0 0 0 3px rgba(229, 115, 37, .2);
}

/* --------------------------------------------------------------------------
   File upload zones
   -------------------------------------------------------------------------- */
.qado-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 16px;
    border: 2px dashed var(--rfq-border);
    border-radius: var(--rfq-radius);
    background: var(--rfq-bg);
    cursor: pointer;
    transition: border-color var(--rfq-transition), background var(--rfq-transition);
    text-align: center;
    min-height: 96px;
}

.qado-upload-zone:hover,
.qado-upload-zone:focus {
    border-color: var(--rfq-primary);
    background: var(--rfq-primary-light);
    outline: none;
}

.qado-upload-zone--doc {
    flex-direction: row;
    justify-content: flex-start;
    min-height: 56px;
    padding: 14px 16px;
}

.qado-upload-zone--doc .qado-upload-label {
    font-size: 13px;
}

.qado-upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.qado-upload-icon {
    color: var(--rfq-primary);
    flex-shrink: 0;
}

.qado-upload-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--rfq-primary);
}

.qado-upload-filename {
    font-size: 12px;
    color: var(--rfq-text-light);
    word-break: break-all;
    flex: 1;
}

.qado-upload-zone.qado-has-file {
    border-color: var(--rfq-success);
    background: #eafaf1;
}

.qado-upload-zone.qado-has-file .qado-upload-icon { color: var(--rfq-success); }
.qado-upload-zone.qado-has-file .qado-upload-label { color: var(--rfq-success); }

/* The upload zone inside a row needs proper grid handling */
.qado-field-group--upload {
    min-width: 0;
}

/* --------------------------------------------------------------------------
   Section divider (Destination sub-header)
   -------------------------------------------------------------------------- */
.qado-section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0 16px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--rfq-text-light);
}

.qado-section-divider::before,
.qado-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--rfq-border);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.qado-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 28px;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--rfq-font);
    border: none;
    border-radius: var(--rfq-radius);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--rfq-transition), transform var(--rfq-transition), box-shadow var(--rfq-transition);
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.qado-btn--primary {
    background: var(--rfq-primary);
    color: #fff;
}

.qado-btn--primary:hover {
    background: var(--rfq-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(229, 115, 37, .28);
    color: #fff;
}

.qado-btn--primary:focus-visible {
    box-shadow: 0 0 0 3px rgba(229, 115, 37, .35);
}

.qado-btn--primary:active {
    transform: translateY(0);
    box-shadow: none;
}

.qado-btn--submit {
    min-width: 200px;
    position: relative;
}

.qado-btn--submit:disabled {
    opacity: .7;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Loading spinner inside button */
.qado-btn__loader {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: qado-spin .7s linear infinite;
    flex-shrink: 0;
}

.qado-btn--loading .qado-btn__loader { display: inline-block; }
.qado-btn--loading .qado-btn__text   { opacity: .8; }

@keyframes qado-spin {
    to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Form footer
   -------------------------------------------------------------------------- */
.qado-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--rfq-border);
    margin-top: 8px;
}

.qado-form-required-note {
    font-size: 12px;
    color: var(--rfq-text-light);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --------------------------------------------------------------------------
   Responsive tweaks
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    .qado-form-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .qado-btn--submit {
        width: 100%;
        justify-content: center;
    }

    .qado-radio-group { gap: 10px; }
}

/* High contrast / forced colors mode */
@media (forced-colors: active) {
    .qado-input, .qado-select, .qado-textarea {
        forced-color-adjust: none;
    }
    .qado-radio-custom {
        forced-color-adjust: none;
        border-color: ButtonText;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .qado-btn,
    .qado-input,
    .qado-select,
    .qado-upload-zone,
    .qado-radio-custom {
        transition: none;
    }
    .qado-btn__loader {
        animation: none;
        border-color: rgba(255,255,255,.6);
    }
}

/* ==========================================================================
   Success Modal — shown after AJAX form submission
   ========================================================================== */

#qado-success-overlay {
    /* position:fixed can break when a parent has transform/will-change/filter.
       We always append to <body> from JS, but belt-and-braces: force stacking
       context independence with all vendor prefixes and explicit coords. */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 20px;
    z-index: 2147483647 !important; /* max safe z-index */
    background: rgba(0, 0, 0, .6);
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    /* Ensure it's never hidden by a parent overflow:hidden */
    transform: none !important;
    will-change: opacity;
}

#qado-success-overlay.qado-success-overlay--visible {
    opacity: 1;
    pointer-events: auto;
}

.qado-success-modal {
    background: #fff;
    border-radius: var(--rfq-radius-lg);
    padding: 48px 40px 40px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .22);
    transform: translateY(16px) scale(.97);
    transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
    position: relative;
}

#qado-success-overlay.qado-success-overlay--visible .qado-success-modal {
    transform: translateY(0) scale(1);
}

.qado-success-modal__icon {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

.qado-success-modal__icon svg {
    animation: qado-check-pop .45s cubic-bezier(.34,1.56,.64,1) .15s both;
}

@keyframes qado-check-pop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.qado-success-modal__title {
    font-size: 22px;
    font-weight: 800;
    color: var(--rfq-navy);
    margin: 0 0 12px;
    line-height: 1.25;
}

.qado-success-modal__body {
    font-size: 15px;
    color: var(--rfq-text-light);
    line-height: 1.65;
    margin: 0 0 28px;
}

/* Prevent body scroll when modal is open (set by JS) */
body.qado-modal-active {
    overflow: hidden;
}

/* Form error alert animation */
.qado-form-alert {
    animation: qado-slide-in .2s ease;
}

@keyframes qado-slide-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Unit search wrapper */
.qado-unit-search-wrap {
    margin-bottom: 6px;
}

.qado-unit-search {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--rfq-border);
    border-radius: var(--rfq-radius);
    font-size: 13px;
    font-family: var(--rfq-font);
    background: var(--rfq-bg);
    box-sizing: border-box;
    outline: none;
    transition: border-color var(--rfq-transition);
}

.qado-unit-search:focus {
    border-color: var(--rfq-primary);
    background: var(--rfq-white);
}

/* Drag-over state for upload zones */
.qado-upload-zone.qado-drag-over {
    border-color: var(--rfq-primary);
    background: var(--rfq-primary-light);
}

@media (max-width: 480px) {
    .qado-success-modal {
        padding: 36px 24px 28px;
    }
    .qado-success-modal__title { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
    #qado-success-overlay,
    .qado-success-modal,
    .qado-success-modal__icon svg {
        transition: none;
        animation: none;
    }
}
