/**
 * Frontend Styles for Norisma Gravity Form Checkout Block
 */

.norisma-gf-checkout-wrapper {
    background-color: #f5f5f5;
    padding: 40px;
    border-radius: 8px;
    max-width: 1368px !important;
    width: 100% !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
}

.norisma-gf-checkout-wrapper .gform_wrapper {
    background: transparent;
    max-width: 100% !important;
    width: 100% !important;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gform_body {
    background: transparent;
    max-width: 100% !important;
    width: 100% !important;
}

/* Override Gravity Forms default row-gap to prevent double spacing */
.norisma-gf-checkout-wrapper .gform_wrapper .gform_fields {
    display: grid;
    grid-template-columns: 1fr;
    row-gap: 0 !important;
    column-gap: 0;
    max-width: 100%;
}

.norisma-gf-checkout-wrapper .gform_wrapper input[type="text"],
.norisma-gf-checkout-wrapper .gform_wrapper input[type="email"],
.norisma-gf-checkout-wrapper .gform_wrapper input[type="tel"],
.norisma-gf-checkout-wrapper .gform_wrapper textarea,
.norisma-gf-checkout-wrapper .gform_wrapper select {
    width: 100%;
    max-width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    background-color: #fff;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.norisma-gf-checkout-wrapper .gform_wrapper input[type="text"]:focus,
.norisma-gf-checkout-wrapper .gform_wrapper input[type="email"]:focus,
.norisma-gf-checkout-wrapper .gform_wrapper input[type="tel"]:focus,
.norisma-gf-checkout-wrapper .gform_wrapper textarea:focus,
.norisma-gf-checkout-wrapper .gform_wrapper select:focus {
    border-color: #4a7c59;
    outline: none;
    box-shadow: 0 0 0 2px rgba(74, 124, 89, 0.1);
}

.norisma-gf-checkout-wrapper .gform_wrapper .gfield_label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gfield_required {
    color: #d32f2f;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gform_button,
.norisma-gf-checkout-wrapper .gform_wrapper input[type="submit"] {
    background-color: #cccccc;
    color: #666;
    padding: 16px 32px;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 600;
    cursor: not-allowed;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    transition: background-color 0.3s ease, color 0.3s ease;
    opacity: 0.6;
    box-sizing: border-box;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gform_button.enabled,
.norisma-gf-checkout-wrapper .gform_wrapper input[type="submit"].enabled {
    background-color: #4a7c59 !important;
    color: #fff !important;
    cursor: pointer !important;
    opacity: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gform_button.enabled:hover,
.norisma-gf-checkout-wrapper .gform_wrapper input[type="submit"].enabled:hover {
    background-color: #3d6849 !important;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gfield {
    margin-bottom: 16px;
    max-width: 100%;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gfield_checkbox li,
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_radio li {
    margin-bottom: 10px;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gfield_checkbox input[type="checkbox"],
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_radio input[type="radio"] {
    margin-right: 8px;
    width: auto;
}

.norisma-gf-checkout-wrapper .gform_wrapper .validation_error {
    display: none !important;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gfield_error {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    border-left: none;
    margin-bottom: 16px;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gfield_error .gfield_label {
    color: #ff0000;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gfield_error input[type="text"],
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_error input[type="email"],
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_error input[type="tel"],
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_error textarea,
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_error select {
    border-color: #ff0000;
    background-color: rgba(255, 0, 0, 0.05);
}

.norisma-gf-checkout-wrapper .gform_wrapper .gfield_error input[type="text"]:focus,
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_error input[type="email"]:focus,
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_error input[type="tel"]:focus,
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_error textarea:focus,
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_error select:focus {
    border-color: #ff0000;
    box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.1);
}

.norisma-gf-checkout-wrapper .gform_wrapper .validation_message {
    background-color: transparent;
    border: none;
    color: #ff0000;
    font-size: 12px;
    margin-top: 4px;
    padding: 0;
    border-radius: 0;
}

.norisma-gf-text-above {
    margin-bottom: 24px;
}

.norisma-gf-text-below {
    margin-top: 16px;
    margin-bottom: 16px;
}

.norisma-gf-text-above p,
.norisma-gf-text-below p {
    margin: 0 0 12px 0;
    line-height: 1.6;
}

.norisma-gf-text-below p:last-child {
    margin-bottom: 0;
}

/* Two column layout for name fields */
.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_name {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_name span {
    flex: 1;
    min-width: 200px;
}

.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_name .name_first,
.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_name .name_last {
    margin-bottom: 0;
}

.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_name label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: #666;
    font-weight: 400;
}

/* Address field layout - Poststed and Postnummer side by side */
.norisma-gf-checkout-wrapper .gform_wrapper .ginput_complex.ginput_container_address,
.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address .address_line_1 {
    width: 100% !important;
    margin-bottom: 16px;
    display: block;
}

.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address .address_line_1 input {
    width: 100% !important;
    max-width: 100% !important;
}

/* Two column layout for city and zip */
.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address .address_city,
.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address .address_zip,
.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address span {
    width: calc(50% - 8px) !important;
    margin-bottom: 0;
    display: inline-block;
    vertical-align: top;
    box-sizing: border-box;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address .address_line_1 {
    width: 100% !important;
}

.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address .address_city {
    margin-right: 16px;
}

.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address .address_city input,
.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address .address_zip input {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address span {
    margin-bottom: 0;
}

.norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: #666;
    font-weight: 400;
}

/* Ensure address field container doesn't overflow */
.norisma-gf-checkout-wrapper .gform_wrapper .gfield.gfield_contains_required.field_sublabel_below.field_description_below.gfield_visibility_visible {
    width: 100%;
    max-width: 100%;
}

/* Checkbox label links styling */
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_checkbox label a,
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_radio label a {
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gfield_checkbox label a:hover,
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_radio label a:hover {
    text-decoration: none;
}

/* Prevent label click from toggling checkbox when clicking on link */
.norisma-gf-checkout-wrapper .gform_wrapper .gfield_consent_label {
    pointer-events: none;
}

.norisma-gf-checkout-wrapper .gform_wrapper .gfield_consent_label * {
    pointer-events: auto;
}

/* Modal styling - mirroring norisma-checkout exactly */
.sales-terms-content {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 50px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sales-terms-content .modal-container {
    position: relative;
    max-width: 960px;
    height: calc(100vh - 100px);
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.sales-terms-content .modal-content {
    padding: 20px;
    height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
}

.sales-terms-content .close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    z-index: 10;
}

.sales-terms-content .close-button::before,
.sales-terms-content .close-button::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background-color: #333;
    top: 50%;
    left: 50%;
}

.sales-terms-content .close-button::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.sales-terms-content .close-button::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.sales-terms-content .close-button:hover::before,
.sales-terms-content .close-button:hover::after {
    background-color: #000;
}

.sales-terms-content.active {
    display: block;
}

html.modal-open {
    overflow: hidden;
}

.link-button {
    cursor: pointer;
}

/* Responsive */
@media (max-width: 1400px) {
    .norisma-gf-checkout-wrapper {
        max-width: 100%;
        margin: 0 20px;
    }
}

@media (max-width: 768px) {
    .norisma-gf-checkout-wrapper {
        padding: 24px 16px !important; /* Override inline style from settings */
        margin: 0 10px;
    }

    .norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_name {
        flex-direction: column;
        gap: 12px;
    }

    .norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_name span {
        min-width: 100%;
    }

    /* Keep Poststed and Postnr side by side on mobile */
    .norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address .address_city,
    .norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address .address_zip {
        width: calc(50% - 8px) !important;
        padding: 0 !important;
        display: inline-block !important;
        margin-bottom: 0 !important;
        vertical-align: top;
    }

    .norisma-gf-checkout-wrapper .gform_wrapper .ginput_container_address .address_city {
        margin-right: 16px !important;
    }

    .norisma-gf-checkout-wrapper .gform_wrapper .gform_button,
    .norisma-gf-checkout-wrapper .gform_wrapper input[type="submit"] {
        padding: 14px 24px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .norisma-gf-checkout-wrapper {
        padding: 20px 12px !important; /* Override inline style from settings */
        margin: 0 5px;
        border-radius: 4px;
    }

    .norisma-gf-checkout-wrapper .gform_wrapper input[type="text"],
    .norisma-gf-checkout-wrapper .gform_wrapper input[type="email"],
    .norisma-gf-checkout-wrapper .gform_wrapper input[type="tel"],
    .norisma-gf-checkout-wrapper .gform_wrapper textarea,
    .norisma-gf-checkout-wrapper .gform_wrapper select {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 10px 12px;
    }
}
