/* Import Google Fonts - Playfair Display for headings, Lato for body */
/* NEW: Added more Google Fonts for selection */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&family=Playfair+Display:wght@700&family=Roboto:wght@300;400;700&family=Open+Sans:wght@300;400;700&family=Montserrat:wght@300;400;700&family=Oswald:wght@300;400;700&family=Merriweather:wght@300;400;700&family=Lora:wght@300;400;700&family=Nunito:wght@300;400;700&family=Poppins:wght@300;400;700&family=Rubik:wght@300;300;700&display=swap');

/* --- Global Styles & Variables --- */
:root {
    /* Hotel-inspired Color Palette */
    --primary-color: #5A7D7C;
    --primary-dark: #3E5C5B;
    --secondary-color: #B0A9A1;
    --accent-color: #D4AF37;

    --background-light: #F0F2F5;
    --background-dark: #2C3E50;

    /* Card Background (White Box) */
    --card-background-base: 255, 255, 255;
    --card-opacity: 0.95;
    --card-background: rgba(var(--card-background-base), var(--card-opacity));

    /* Text Colors */
    --portal-title-color: #2C3E50;
    --heading-color: #34495E;
    --text-color: #4F5D75;
    --text-light: #868B8E;

    --border-color: #E6E8EB;
    --success-color: #28A745;
    --error-color: #DC3545;
    --info-color: #17A2B8;

    /* Shadows & Radii */
    --shadow-subtle: 0 6px 20px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 10px 40px rgba(0, 0, 0, 0.2);
    --border-radius-card: 16px;
    --border-radius-input: 8px;

    /* Spacing & Typography */
    --padding-base: 2.5rem;
    --font-family-headings: 'Playfair Display', serif;
    --font-family-body: 'Lato', sans-serif;

    /* Custom properties for dynamic styles (set by admin) */
    --portal-bg-color: var(--background-light);
    --p-color: var(--primary-color);
    --p-dark-color: var(--primary-dark);
    --s-color: var(--secondary-color);
    --t-color: var(--text-color);
    --t-light-color: var(--text-light);
    --wrapper-width-desktop: 85%;
    --wrapper-width-mobile: 95%;
    --wrapper-max-width: 550px;
    --wrapper-padding: 3rem;
    /* MODIFIED: Use new --vh variable */
    --wrapper-min-height-desktop: calc(70 * var(--vh));
    --wrapper-min-height-mobile: calc(100 * var(--vh));


    /* Logo related CSS variables - SIMPLIFIED */
    --logo-max-width: 220px; /* Default value, will be overridden by JS */
    --logo-y-offset: 0px;    /* Default value, will be overridden by JS */
    --logo-x-offset: 0px;    /* Default value, will be overridden by JS */


    /* Portal Title Vertical Position */
    --portal-title-y-desktop: 0px;
    --portal-title-y-mobile: 0px;

    /* Portal Message Vertical Position */
    --portal-message-y-desktop: 0px;
    --portal-message-y-mobile: 0px;

    /* Ads Section Message Y-Offset Variables */
    --image-display-message-y-desktop: 0px;
    --image-display-message-y-mobile: 0px;

    /* Container Box Vertical Position */
    --container-y-offset-desktop: 0px;
    --container-y-offset-mobile: 0px;

    /* Voucher Box Position */
    --voucher-box-y-desktop: 0px;
    --voucher-box-y-mobile: 0px;

    /* Terms and Ads Y Position */
    --terms-y-offset-desktop: 0px;
    --terms-y-offset-mobile: 0px;
    --ads-y-offset-desktop: 0px;
    --ads-y-offset-mobile: 0px;

    /* Footer Y-Offset Variables */
    --footer-y-offset-desktop: 0px;
    --footer-y-offset-mobile: 0px;

    /* NEW: Font Styles and Sizes (These will be dynamically set by JS in the iframe) */
    --portal-title-font-style: 'Playfair Display', serif;
    --portal-title-font-size: 28px;
    --portal-message-font-style: 'Lato', sans-serif;
    --portal-message-font-size: 16px;
    --ads-message-font-style: 'Lato', sans-serif;
    --ads-message-font-size: 14px;

    /* REMOVED: CSS Variable for dynamic message height offset - no longer needed */
    /* --top-message-height: 0px; */
}

html, body {
    height: 100%;
    overflow: auto;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family-body);
    color: var(--t-color);
    line-height: 1.6;
    /* MODIFIED: Use new --vh variable */
    min-height: calc(100 * var(--vh));
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    background-color: var(--portal-bg-color);
}

/* REMOVED: Class to push down the portal wrapper when message is active - no longer needed */
/* body.has-top-message-offset .portal-wrapper {
    margin-top: var(--top-message-height);
} */

.hidden-section {
    display: none !important;
}

.portal-wrapper {
    background-color: var(--card-background);
    border-radius: var(--border-radius-card);
    box-shadow: var(--shadow-medium);
    text-align: center;
    position: relative;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: var(--wrapper-max-width);
    width: var(--wrapper-width-desktop);
    padding: var(--wrapper-padding);
    transform: translateY(var(--container-y-offset-desktop, 0px));
    height: auto;
    /* MODIFIED: Use new --vh variable */
    min-height: var(--wrapper-min-height-desktop);
    max-height: 95vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1;
    /* REMOVED: Add transition for smooth offset - no longer needed */
    /* transition: margin-top 0.3s ease; */

    &::-webkit-scrollbar {
        width: 0;
        background: transparent;
    }
    scrollbar-width: none;
    -ms-overflow-style: none;
}


.portal-header {
    margin-bottom: var(--padding-base);
    display: flex;
    flex-direction: column;
    padding-bottom: 1.5rem;
    border-bottom: none; /* MODIFIED: Removed border to remove white line */
    gap: 1.5rem;
    position: relative;
    min-height: 100px;
    z-index: 2;
}

.portal-header h1 { /* This is #portal-title */
    font-family: var(--portal-title-font-style);
    font-size: var(--portal-title-font-size);
    color: var(--portal-title-color);
    margin: 0;
    margin-bottom: 1.5rem;
    line-height: 1.5 !important; /* Adjusted line-height for better spacing */
    text-align: center;
    flex-grow: 0;
    position: relative;
    z-index: 2;
    white-space: pre-wrap; /* ADDED: To display newlines as line breaks */
    transform: translateY(var(--portal-title-y-desktop, 0px));
}

.logo-area {
    width: 100%;
    position: relative;
    min-height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 1rem;
}


#portal-logo {
    max-width: var(--logo-max-width); /* Uses the unified variable */
    height: auto;
    display: block;
    margin: 0 auto;
    transition: max-width 0.3s ease, transform 0.3s ease, left 0.3s ease, top 0.3s ease, margin 0.3s ease;
    z-index: 10;
    transform: translate(var(--logo-x-offset), var(--logo-y-offset)); /* Uses the unified variables */
    position: static;
}

.portal-header #portal-logo.absolute-pos {
    position: absolute;
    left: 50%;
    transform: translateX(calc(-50% + var(--logo-x-offset))) translateY(var(--logo-y-offset)) scale(var(--portal-scale, 1));
    margin: 0;
}


#portal-title,
#portal-message {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    transition: transform 0.3s ease, margin-bottom 0.3s ease;
    position: static;
}

.portal-message-text { /* This is #portal-message */
    font-family: var(--portal-message-font-style);
    font-size: var(--portal-message-font-size);
    /* NEW: Add margin-top to separate from the message div */
    margin-top: 1.5rem; /* This will create space below the dynamic message */
    margin-bottom: 1.1rem;
    color: var(--t-light-color);
    white-space: pre-wrap; /* ADDED: To display newlines as line breaks */
    transform: translateY(var(--portal-message-y-desktop, 0px));
}

.message {
    /* REVERTED: To be flow-based and within the wrapper */
    position: static; /* Back to normal document flow */
    top: auto;
    left: auto;
    right: auto;
    z-index: auto; /* Remove high z-index */
    box-shadow: none; /* Remove box-shadow */
    background-color: var(--card-background); /* Use card background for consistency */
    border-radius: var(--border-radius-input); /* Consistent border-radius */
    
    /* Flow-based spacing within voucher-form-card */
    margin-top: 0; /* Should be top-most, so no margin above */
    margin-bottom: 1rem; /* Space below the message, pushing heading down */
    padding: 0.75rem 1rem;
    font-weight: 600;
    text-align: center;
    display: none;
    width: auto; /* Allow auto width based on content and parent */
    box-sizing: border-box;
}
.message.success {
    background-color: var(--success-color);
    color: #fff;
}
.message.error {
    background-color: var(--error-color);
    color: #fff;
}
.message.info {
    background-color: var(--info-color);
    color: #fff;
}

/* No specific margin-top on portal-main needed, as message's margin-bottom will push it */
.portal-main {
    /* Existing styles remain */
}


.form-card {
    background-color: var(--card-background);
    padding: var(--padding-base);
    border-radius: var(--border-radius-card);
    box-shadow: var(--shadow-subtle);
    margin-bottom: 2rem;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
    border: none; /* MODIFIED: Removed border to remove white line */
}

/* NEW: Adjust heading margin inside form-card to make space below the message */
.form-card h2 {
    margin-top: 1rem; /* Push heading down from the message */
    font-family: var(--font-family-headings);
    font-size: 1.6rem;
    color: var(--heading-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: none; /* MODIFIED: Removed border to remove white line */
}


.portal-card {
    background-color: var(--card-background);
    padding: var(--padding-base);
    border-radius: var(--border-radius-card);
    box-shadow: var(--shadow-subtle);
    margin-bottom: 2rem;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
    border: none; /* MODIFIED: Removed border to remove white line */
}

.portal-card:last-of-type {
    margin-bottom: 0;
}

.portal-card h2 {
    font-family: var(--font-family-headings);
    font-size: 1.6rem;
    color: var(--heading-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: none; /* MODIFIED: Removed border to remove white line */
}

.image-display-section img,
.image-display-section video {
    max-width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    height: auto;
    border-radius: var(--border-radius-input);
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-subtle);
}

.image-display-section p { /* Message below media in ads section - #image-display-message */
    font-family: var(--ads-message-font-style);
    font-size: var(--ads-message-font-size);
    color: var(--t-light-color);
    margin-bottom: 0;
    white-space: pre-wrap;
    transform: translateY(var(--image-display-message-y-desktop));
    transition: transform 0.3s ease;
}


.input-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 600;
    color: var(--t-color);
    font-size: 0.95rem;
}

.input-group input[type="text"],
.input-group input[type="password"],
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 1rem 1.2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-input);
    font-size: 1.05rem;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #FDFDFD;
    color: var(--t-color);
    font-family: var(--font-family-body);
}

.input-group input[type="text"]:focus,
.input-group input[type="password"]:focus,
.input-group textarea:focus,
.input-group select:focus {
    border-color: var(--p-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--p-color-rgb, 90, 125, 124), 0.2);
}

.input-group textarea {
    min-height: 60px;
    resize: vertical;
}


.btn {
    display: block;
    width: 100%;
    padding: 1rem 1.5rem;
    margin-top: 2rem;
    border: none;
    border-radius: var(--border-radius-input);
    cursor: pointer;
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background-color: var(--p-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--p-dark-color);
}

.btn-secondary {
    background-color: var(--s-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #9A938C;
}

.terms-section {
    text-align: left;
}

.terms-summary {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.terms-summary input[type="checkbox"] {
    margin-top: 0.2rem;
    flex-shrink: 0;
    width: 1.2em;
    height: 1.2em;
    cursor: pointer;
}

.terms-summary label {
    font-weight: 400;
    margin-bottom: 0;
    line-height: 1.5;
    cursor: pointer;
    font-size: 0.95rem;
}

.terms-summary a {
    color: var(--p-color);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s ease;
}

.terms-summary a:hover {
    color: var(--p-dark-color);
    text-decoration: underline;
}

.portal-footer {
    margin-top: var(--padding-base);
    padding-top: 1.5rem;
    border-top: none; /* MODIFIED: Removed border to remove white line */
    font-size: 0.85rem;
    color: var(--t-light-color);
    text-align: center;
    width: 100%;
    transform: translateY(var(--footer-y-offset-desktop));
    transition: transform 0.3s ease;
}

.portal-footer p {
    white-space: pre-wrap;
    margin: 0;
}


.voucher-form-card {
    transform: translateY(var(--voucher-box-y-desktop, 0px));
}
.terms-section {
    transform: translateY(var(--terms-y-offset-desktop, 0px));
}
.image-display-section { /* This refers to the whole block */
    transform: translateY(var(--ads-y-offset-desktop, 0px));
}
.image-display-section p {
    transform: translateY(var(--image-display-message-y-desktop));
    transition: transform 0.3s ease;
}


/* --- Modal Styles --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-background);
    padding: var(--padding-base);
    border-radius: var(--border-radius-card);
    width: 80%;
    max-width: 800px;
    box-shadow: var(--shadow-medium);
    position: relative;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-content h3 {
    font-family: var(--font-family-headings);
    color: var(--heading-color);
    margin-bottom: 1.2rem;
    font-size: 1.8rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color); /* Kept for modal headings */
    flex-shrink: 0;
}

.close-button {
    color: var(--t-light-color);
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-button:hover,
.close-button:focus {
    color: var(--error-color);
    text-decoration: none;
}

.modal-body {
    text-align: left;
    flex-grow: 1;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--t-color);
    padding-right: 15px;
    margin-top: 1rem;
}
/* Ensure <pre> tag itself handles whitespace for terms */
.modal-body pre {
    white-space: pre-wrap;
    word-wrap: break-word;
}


.radio-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.radio-group input[type="radio"] {
    width: 1.2em;
    height: 1.2em;
    flex-shrink: 0;
    margin-top: 0;
}

.radio-group label {
    margin-bottom: 0;
    font-weight: 400;
    cursor: pointer;
}


@media (max-width: 768px) {
    body {
        min-height: 100vh;
        overflow-y: auto;
        justify-content: flex-start;
        padding: 0;
    }

    /* REMOVED: Responsive margin offset - no longer needed */
    /* body.has-top-message-offset .portal-wrapper {
        margin-top: var(--top-message-height);
    } */

    .portal-wrapper {
        background-color: var(--card-background);
        width: var(--wrapper-width-mobile);
        transform: translateY(var(--container-y-offset-mobile, 0px));
        padding: 1.5rem;
        border-radius: 0;
        box-shadow: none;
        height: auto;
        /* MODIFIED: Use new --vh variable */
        min-height: var(--wrapper-min-height-mobile);
        max-height: none;
        overflow-y: visible;
        margin-top: 0;
        margin-bottom: 0;
    }

    .portal-header {
        background-color: transparent;
        flex-direction: column;
        text-align: center;
        border-bottom: none; /* MODIFIED: Removed border to remove white line */
        position: relative;
        z-index: 2;
        height: auto !important;
        min-height: auto !important;
        width: 100% !important;
        margin-bottom: 2rem !important;
        padding-bottom: 1rem !important;
        gap: 1rem !important;
    }

    .logo-area {
        background-color: transparent;
        padding-top: 1rem;
        padding-bottom: 0.5rem;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
    }

    #portal-logo {
        max-width: var(--logo-max-width); /* Uses the unified variable for mobile */
        margin-bottom: 0.5rem;
        transform: translate(var(--logo-x-offset, 0px), var(--logo-y-offset, 0px)) !important; /* Uses the unified variables for mobile */
        position: static !important;
        left: auto !important;
        top: auto !important;
        margin-left: auto !important;
        margin-right: auto !important;
        display: block !important;
    }

    #portal-title {
        background-color: transparent;
        font-size: var(--portal-title-font-size);
        margin: 0;
        margin-bottom: 1rem !important;
        transform: translateY(var(--portal-title-y-mobile, 0px)) !important;
        position: static !important;
    }

    .portal-message-text {
        font-size: var(--portal-message-font-size);
        margin: 0;
        /* NEW: Margin-top for mobile below the message div */
        margin-top: 1.5rem !important;
        margin-bottom: 1.5rem !important;
        transform: translateY(var(--portal-message-y-mobile, 0px)) !important;
        position: static !important;
    }

    .form-card, .portal-card {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    /* NEW: Adjust heading margin inside form-card for mobile */
    .form-card h2 {
        margin-top: 1rem; /* Push heading down from the message */
        font-size: 1.4rem; /* Already set, just keeping it consistent */
    }


    .voucher-form-card {
        transform: translateY(var(--voucher-box-y-mobile, 0px));
    }

    .terms-section {
        transform: translateY(var(--terms-y-offset-mobile, 0px));
    }

    .image-display-section {
        transform: translateY(var(--ads-y-offset-mobile, 0px));
    }
    .image-display-section p {
        transform: translateY(var(--image-display-message-y-mobile));
    }

    .portal-footer {
        transform: translateY(var(--footer-y-offset-mobile));
    }


    .input-group input[type="text"],
    .input-group input[type="password"],
    .input-group textarea,
    .input-group select {
        padding: 0.8rem 1rem;
        font-size: 1rem;
    }

    .btn {
        padding: 0.9rem 1.5rem;
        font-size: 1.05rem;
        margin-top: 1.5rem;
    }

    .message {
        padding: 0.8rem;
        font-size: 0.9rem;
        /* Revert margin-top for mobile as well, follow flow */
        margin-top: 0; /* Should be top-most, so no margin above */
    }

    .modal-content {
        width: 95%;
        margin: 2% auto;
        padding: 1rem;
    }
    .modal-content h3 {
        font-size: 1.5rem;
        margin-bottom: 0.8rem;
    }
    .close-button {
        font-size: 1.8rem;
        top: 0.8rem;
        right: 1rem;
    }
    .modal-body {
        font-size: 0.9rem;
        line-height: 1.6;
        padding-right: 10px;
    }
}

