/* ==========================================================================
   Donation Form Styles (V2)
   ========================================================================== */

/* --- Variables --- */
:root {
    --df-input-height: 52px;
    --df-border-color: #e1e1e1;
    --df-border-radius: 12px;
    --df-transition: all 0.3s ease;
    --df-bg-gray: #f8f9fa;
    /* Uses existing global variables where possible, fallbacks provided */
    --df-primary: var(--primary-blue, #021242);
    --df-accent: var(--accent-gold, #c9ab65);
    --df-accent-light: var(--accent-gold-light, #e0ca96);
    --df-white: var(--white, #ffffff);
    --df-error: var(--error-red, #dc3545);
}

body,
html {
    max-width: 100% !important;
    overflow-x: hidden !important;
    position: relative !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ==========================================================================
   1. Animations & Steps
   ========================================================================== */

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-step {
    display: none;
    animation: slideUp 0.4s ease-out;

    &.active {
        display: block;
    }
}

/* ==========================================================================
   2. Layout & Grids
   ========================================================================== */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.donation-wrapper .input-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
    width: 100%;
}

.form-row-flex {
    display: flex;
    gap: 15px;
    width: 100%;
    align-items: center;
}

#step-3 .donation-wrapper .input-group {
    margin-bottom: 12px;
}

/* ==========================================================================
   3. Input Containers (The wrappers around fields)
   ========================================================================== */

.input-container {
    position: relative;
    border: 1px solid var(--df-border-color);
    border-radius: var(--df-border-radius);
    height: var(--df-input-height);
    flex: 1;
    /* Default: take available space */
    min-width: 120px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--df-white);
    transition: var(--df-transition);
    box-sizing: border-box;

    /* States */
    &:focus-within {
        border-color: var(--df-accent) !important;
        box-shadow: 0 0 8px rgba(201, 171, 101, 0.2);
    }

    &[hidden] {
        display: none !important;
    }

    &.read-only {
        background: #f0f0f0;
        border-color: #ddd;
    }

    &.invalid {
        border-color: var(--df-error);
    }

    /* Sizing Modifiers */
    &.full-width,
    &.new-row {
        flex: 0 0 100% !important;
    }

    &.expanded-group {
        height: auto;
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
        border-color: var(--df-border-color);
        background: var(--df-white);

        &:focus-within {
            border-color: var(--df-accent);
            box-shadow: 0 0 8px rgba(201, 171, 101, 0.2);
        }
    }

    &.w-200 input {
        max-width: 200px !important;
    }

    &.w-300 input {
        max-width: 300px !important;
    }

    &.tiny-field {
        flex: 0 0 auto !important;
        width: fit-content !important;
        min-width: 0 !important;
    }

    &.small-field {
        flex: 0 0 140px !important;
        width: 140px !important;
        min-width: 140px !important;
    }

    /* Label Styling */
    label:not(.toggle-field label, .checkbox-layout label) {
        position: absolute;
        right: 12px;
        color: var(--df-primary);
        font-weight: 500;
        pointer-events: none;
        font-size: 12px;
        background: var(--df-white);
        padding: 0 5px;
        top: -10px;
        z-index: 10;
    }

    /* Base Input & Textarea inside container */
    input,
    textarea {
        width: 100%;
        border: none !important;
        background: transparent !important;
        text-align: right;
        color: var(--df-primary);
        font-size: 15px;
        font-weight: 600;
        outline: none !important;
        box-shadow: none !important;
        margin-top: 5px;
    }

    /* Textarea Specifics */
    &:has(textarea) {
        height: auto;
        padding: 6px 12px;
    }

    textarea {
        padding: 12px;
        height: 100px;
        resize: none !important;
    }

    /* Toggle Field Specifics (Switches) */
    &.toggle-field {
        justify-content: center;
        gap: 12px;
        background: var(--df-bg-gray) !important;
        border-color: #eee;

        label:not(.switch) {
            position: static !important;
            padding: 0 !important;
            font-size: 14px !important;
            font-weight: 600 !important;
            color: var(--df-primary) !important;
            background: transparent !important;
            pointer-events: auto !important;
            margin: 0 !important;
            top: auto !important;
            right: auto !important;
        }

        .switch {
            position: relative !important;
            flex: none !important;
            margin: 0 !important;
            rotate: 180deg;
        }
    }
}

/* ==========================================================================
   4. Custom Select API
   ========================================================================== */

.donation-wrapper select,
.donation-wrapper select::picker(select) {
    appearance: base-select !important;
}

.input-container select {
    width: 100%;
    border: none !important;
    background: transparent !important;
    height: 100%;
    cursor: pointer;
    outline: none !important;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;

    &:focus {
        box-shadow: none !important;
    }

    /* Closed State Button */
    button {
        width: 100%;
        height: 100%;
        background: transparent;
        border: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 10px;
        color: var(--df-primary);
        font-size: 15px;
        font-weight: 600;
        text-align: right;
    }

    /* Picker Icon (Arrow) */
    &::picker-icon {
        color: #999;
        transition: 0.3s rotate ease;
        rotate: 0deg;
    }

    &:open::picker-icon {
        color: var(--df-accent);
        rotate: 180deg;
    }
}


/* Popup Picker (Customizable Select API) */
::picker(select) {
    background-color: rgba(2, 18, 66, 0.98);
    /* Rich Brand Blue */
    backdrop-filter: blur(12px);
    border: 1px solid rgba(201, 171, 101, 0.5);
    /* Softer Gold */
    border-radius: 16px;
    padding: 10px;
    box-shadow: 0 15px 45px rgba(2, 18, 66, 0.25);
    margin-top: 10px;
}

/* Custom Scrollbar for Picker */
::picker(select)::-webkit-scrollbar {
    width: 6px;
}

::picker(select)::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin: 8px 0;
}

::picker(select)::-webkit-scrollbar-thumb {
    background: var(--df-accent);
    border-radius: 10px;
}

::picker(select)::-webkit-scrollbar-thumb:hover {
    background: #e6c875;
    /* Lighter gold for hover */
}

/* Option Elements */
.donation-wrapper option {
    padding: 12px 16px;
    margin-bottom: 5px;
    border-radius: 10px;
    color: var(--df-white);
    background-color: rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 14px;

    &:hover,
    &:focus {
        background-color: rgba(201, 171, 101, 0.2);
    }

    &:checked {
        background-color: var(--df-accent);
        color: var(--df-primary);
        font-weight: 600;
    }

    /* Remove checkmark */
    &::checkmark {
        content: none;
    }
}

selectedcontent {
    /* display: flex; */
    /* flex: 1; */

    .icon {
        display: none;
    }
}

/* ==========================================================================
   5. Buttons & Navigation
   ========================================================================== */

.action-btn {
    width: 100%;
    height: 55px;
    background-color: var(--df-primary);
    border: 2px solid var(--df-accent);
    border-radius: var(--df-border-radius);
    color: var(--df-white);
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--df-transition);
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    &:hover {
        background-color: #041b5e;
        box-shadow: 0 5px 15px rgba(2, 18, 66, 0.3);
    }

    &.outline {
        background-color: var(--df-bg-gray);
        color: #333;
        border: 1px solid #ddd;

        &:hover {
            background-color: #e9ecef;
            border-color: #ccc;
            box-shadow: none;
        }
    }
}

.step-navigation {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    width: 100%;

    .action-btn {
        flex: 1;
        margin-top: 0;
    }
}

.prev-step-link {
    display: block;
    text-align: center;
    margin-top: 15px;
    color: #666;
    text-decoration: none;
    cursor: pointer;
    font-size: 12px;
    transition: color 0.2s;

    &:hover {
        color: var(--df-primary);
    }
}

/* Unified Payment Button */
.unified-payment-container {
    margin-top: 20px;
    text-align: center;
}

.unified-pay-btn {
    background-color: var(--df-accent) !important;
    border: 2px solid var(--df-primary) !important;
    height: auto !important;
    padding: 15px 20px !important;
    flex-direction: column !important;
    line-height: 1.2;

    &:hover {
        background-color: var(--df-accent-light) !important;
        transform: translateY(-2px);
    }

    .btn-top {
        font-size: 18px;
        margin-bottom: 8px;
        color: var(--df-primary);
    }

    .payment-icons {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        opacity: 0.9;

        img {
            height: 22px;
            width: auto;
            object-fit: contain;
        }
    }

    .apple-pay-label {
        font-size: 12px;
        color: var(--df-primary);
        font-weight: 500;
    }
}

/* ==========================================================================
   6. Checkboxes & Switches
   ========================================================================== */

.checkbox-layout {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: 100%;

    label {
        line-height: 1.4 !important;
        position: static !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        pointer-events: auto !important;
        color: var(--df-primary) !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        cursor: pointer;
    }

    input[type="checkbox"] {
        flex: none;
        width: 22px !important;
        height: 22px !important;
        margin: 0;
        cursor: pointer;
        appearance: none;
        -webkit-appearance: none;
        background-color: var(--df-white) !important;
        border: 1px solid var(--df-border-color) !important;
        border-radius: 6px;
        position: relative;
        transition: var(--df-transition);
        display: flex;
        align-items: center;
        justify-content: center;


        &:hover {
            border-color: var(--df-accent) !important;
            box-shadow: 0 0 8px rgba(201, 171, 101, 0.2) !important;
        }

        &:checked {
            border-color: var(--df-accent) !important;
            background-color: rgba(201, 171, 101, 0.05) !important;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c9ab65' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") !important;
            background-size: 14px;
            background-position: center;
            background-repeat: no-repeat;

            &::before {
                content: "";
            }
        }
    }
}

.switch {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 16px;
    flex: none;
    /* Prevent stretching */

    input {
        opacity: 0;
        width: 0;
        height: 0;

        &:checked+.slider {
            background-color: var(--df-primary);
        }

        &:checked+.slider:before {
            transform: translateX(14px);
        }
    }

    .slider {
        position: absolute;
        cursor: pointer;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #eee;
        transition: .4s;

        &:before {
            position: absolute;
            content: "";
            height: 12px;
            width: 12px;
            left: 2px;
            bottom: 2px;
            background-color: white;
            transition: .4s;
        }

        &.round {
            border-radius: 24px;

            &:before {
                border-radius: 50%;
            }
        }
    }
}

/* ==========================================================================
   7. Specific Components & Extras
   ========================================================================== */

.total-display {
    background: rgba(201, 171, 101, 0.1);
    border: 1px solid var(--df-accent);
    border-radius: var(--df-border-radius);
    padding: 15px;
    margin-top: 15px;
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.summary-row {
    gap: 8px;
    color: var(--df-primary);
}

.total-text {
    font-size: 14px;
    font-weight: 500;
}

.payment-options-grid {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.payment-option {
    cursor: pointer;
    border: 2px solid var(--df-border-color);
    border-radius: var(--df-border-radius);
    padding: 10px;
    transition: var(--df-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--df-white);
    min-width: 100px;

    &:hover {
        border-color: var(--df-accent-light);
    }

    &.selected {
        border-color: var(--df-accent);
        background: rgba(201, 171, 101, 0.05);
        box-shadow: 0 4px 12px rgba(201, 171, 101, 0.2);
    }
}

#receipt-fields-container {
    display: none;
    animation: fadeIn 0.3s ease;
}

.payment-iframe-container iframe {
    width: 100%;
    height: 500px;
    background: var(--df-white);
}

.payment-icons-small {
    display: flex;
    justify-content: center;
    gap: 8px;
    align-items: center;
    margin-top: 5px;

    img {
        height: 18px;
        opacity: 0.8;
    }
}

/* ==========================================================================
   V1 Form — Column Width Utilities (scoped to #simple-payment)
   xs  ~110px  : מטבע, מס' בית, מיקוד, כמות
   sm  ~130px  : סכום (10 ספרות), ת.ז
   md  ~210px  : שם פרטי/משפחה, נייד, טלפון, עיר
   lg  ~300px  : יעד, מטרה, תשלומים, אימייל, רחוב, שם/ת.ז לקבלה
   ========================================================================== */

#simple-payment .dv1-col-xs { max-width: 110px; }
#simple-payment .dv1-col-sm { max-width: 130px; }
#simple-payment .dv1-col-md { max-width: 210px; }
#simple-payment .dv1-col-lg { max-width: 300px; }

/* ==========================================================================
   8. Responsive (Mobile)
   ========================================================================== */

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .unified-pay-btn .payment-icons {
        gap: 8px;

        img {
            height: 18px;
        }
    }

    .input-container {
        margin-bottom: 12px;
    }

    #receipt-fields-container {
        flex-direction: column;
    }

    input[type=checkbox] {
        width: 20px !important;
        height: 20px !important;
    }

    /* Hide Number Input Arrows on Mobile */
    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button {
        -webkit-appearance: none;
        appearance: none;
        margin: 0;
    }


    input[type=number] {
        -moz-appearance: textfield;
        appearance: textfield;
    }
}