@font-face {
    font-family: 'MerckRegular';
    src: url('../fonts/Merck-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Merck';
    src: url('../fonts/Merck.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --verde: #149b5f;
    --carne: #FFDCB9;
    --purple: #46317b;
    --magenta: #eb3c96;
    --magenta-light: #2dbecd;
    --white: #ffffff;
    --bg-white: #ffffff;
    --text-dark: #333333;
    --font-main: 'Merck', sans-serif;
    --font-secondary: 'MerckRegular', sans-serif;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--purple);
    color: var(--white);
    overflow-x: hidden;
    min-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header.app-header {
    background-color: var(--purple);
    padding: 1rem 2rem;
    position: relative;
    z-index: 1000; /* Higher than main so logo is clipped by header */
    border-bottom: 5px solid transparent;
    border-image: linear-gradient(to right, #8e2b88, #e81976) 1;
}

.header-content {
    display: flex;
    align-items: center;
    position: relative;
}

.brand-merck {
    color: var(--verde);
    font-weight: 800;
    font-size: 2rem;
    letter-spacing: -1px;
    z-index: 2;
}

.hashtag {
    color: var(--magenta-light);
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 2.2rem;
    font-weight: 800;
    text-transform: lowercase;
    letter-spacing: 1px;
}

/* Gradient line is handled by border-image on header */

/* Main Content */
main.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    text-align: center;
    position: relative;
    z-index: 50; /* Higher than footer */
}

.form-top-logo {
    width: 90%;
    max-width: 850px;
    margin: 0 auto;
    margin-top: -100px;
    /* Negative margin to cut off at the header */
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.form-top-logo img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.content-wrapper {
    position: relative;
    z-index: 2;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.step-container {
    width: 100%;
    max-width: 800px;
}

.step {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.step.active {
    display: block;
}

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

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

h2.question-title {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    line-height: 1.3;
}

/* Form Elements */
.input-group {

    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

input[type="text"],
input[type="email"],
select.native-select {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    width: 100%;
    padding: 1rem 1.5rem;
    border: 3px solid var(--magenta);
    border-radius: 50px;
    font-size: 1.1rem;
    color: var(--text-dark);
    outline: none;
    background: var(--white);
    transition: var(--transition);
}

/* Custom Select Branding */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select {
    position: relative;
    display: flex;
    flex-direction: column;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
}

.custom-select-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-dark);
    height: 60px;
    line-height: normal;
    background: var(--white);
    cursor: pointer;
    border: 3px solid var(--magenta);
    border-radius: 50px;
    transition: all 0.3s ease;
}

.custom-select-trigger:after {
    content: "";
    width: 10px;
    height: 10px;
    border-right: 3px solid var(--magenta);
    border-bottom: 3px solid var(--magenta);
    transform: rotate(45deg);
    margin-right: 5px;
    transition: all 0.3s ease;
}

.custom-select.open .custom-select-trigger {
    border-radius: 25px 25px 0 0;
    border-bottom: 2px solid #eee;
}

.custom-select.open .custom-select-trigger:after {
    transform: rotate(-135deg);
}

.custom-options {
    position: absolute;
    display: block;
    top: 100%;
    left: 0;
    right: 0;
    border: 3px solid var(--magenta);
    border-top: 0;
    background: var(--white);
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-15px);
    border-radius: 0 0 25px 25px;
    z-index: 10000; /* Extremely high to stay on top */
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

/* Scrollbar for custom options */
.custom-options::-webkit-scrollbar {
    width: 8px;
}
.custom-options::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 0 25px 0;
}
.custom-options::-webkit-scrollbar-thumb {
    background: var(--magenta-light);
    border-radius: 10px;
}
.custom-options::-webkit-scrollbar-thumb:hover {
    background: var(--verde);
}

.custom-select.open .custom-options {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: translateY(0);
}

.custom-option {
    position: relative;
    display: block;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f9f9f9;
}

.custom-option:last-of-type {
    border-bottom: 0;
    border-radius: 0 0 22px 22px;
}

.custom-option:hover {
    background-color: var(--magenta-light);
    color: var(--white);
    padding-left: 1.8rem;
}

.custom-option.selected {
    background-color: var(--verde);
    color: var(--white);
}

input[type="text"]:focus,
input[type="email"]:focus,
select:focus {
    box-shadow: 0 0 15px rgba(232, 25, 118, 0.5);
}

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 400px;
    margin: 0 auto;
}

.option-btn {
    background: transparent;
    border: 3px solid var(--white);
    color: var(--white);
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.option-btn:hover,
.option-btn.selected {
    background: var(--magenta);
    border-color: var(--magenta);
}

.terms-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 1.5rem;
    font-size: 1rem;
    cursor: pointer;
}

.terms-container input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    min-width: 24px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: 2px solid var(--white);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.terms-container input[type="checkbox"]:checked {
    background: var(--magenta);
    border-color: var(--magenta);
}

.terms-container input[type="checkbox"]:checked::after {
    content: '✔';
    position: absolute;
    color: var(--white);
    font-size: 16px;
    font-weight: bold;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.terms-container label {
    cursor: pointer;
}

/* Results text */
.results-text {
    font-size: 1.1rem;
    text-align: left;
    line-height: 1.6;
}

.results-text p {
    margin-bottom: 1rem;
}

.results-text .warning {
    font-size: 0.85rem;
    color: #ffd700;
    margin-top: 2rem;
}

/* Footer & Controls */
footer.app-footer {
    background: var(--bg-white);
    color: var(--text-dark);
    padding: 1.5rem 2rem 3rem 2rem;
    position: relative;
    z-index: 1; /* Lower than main */
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logos-left,
.logos-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    opacity: 0.8;
}

.logos-left img,
.logos-right img {
    height: 50px;
    object-fit: contain;
}

.btn-secondary {
    background-color: transparent;
    color: var(--white);
    border: 2px solid var(--white);
    padding: 0.8rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 800;
    border-radius: 50px;
    cursor: pointer;
    text-transform: lowercase;
    transition: var(--transition);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.btn-continue {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    background-color: var(--magenta);
    color: var(--white);
    border: none;
    padding: 0.8rem 3rem;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: 50px;
    cursor: pointer;
    text-transform: lowercase;
    transition: var(--transition);
    box-shadow: 0 5px 15px rgba(232, 25, 118, 0.3);
}

.btn-continue:hover {
    background-color: var(--magenta-light);
    transform: translateY(-2px);
}

.btn-continue:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Restart Button */
.btn-ghost-restart {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.btn-ghost-restart:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--white);
}

/* Progress Bar at the bottom of header */
.progress-container {
    position: absolute;
    bottom: -6px;
    /* Right below the gradient border */
    left: 0;
    right: 0;
    height: 6px;
    background: rgba(232, 25, 118, 0.2);
    z-index: 10;
}

.progress-bar {
    height: 100%;
    background: var(--magenta);
    width: 0%;
    transition: width 0.4s ease;
    position: relative;
    border-radius: 0 4px 4px 0;
}

.runner {
    position: absolute;
    right: -10px;
    top: -15px;
    font-size: 1.2rem;
    transform: scaleX(-1);
}

/* DB status indicator */
.db-status-dot {
    position: fixed;
    bottom: 0.5rem;
    left: 0.5rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    z-index: 2000;
}

.db-status-dot.connected {
    display: none;
}

.db-status-dot.disconnected {
    background: #ff0000;
    box-shadow: 0 0 5px #ff0000;
    animation: blink 1s infinite alternate;
}

@keyframes blink {
    from {
        opacity: 0.5;
    }

    to {
        opacity: 1;
    }
}

/* Form Navigation under Content */
.form-navigation {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 2.5rem;
    width: 100%;
}

@media (max-width: 768px) {
    header.app-header {
        padding: 0.8rem 1rem;
    }

    .hashtag {
        font-size: 1.2rem;
        position: static;
        margin-top: 0.5rem;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .btn-ghost-restart {
        top: 1rem;
        right: 1rem;
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
        transform: none;
    }

    .brand-merck {
        font-size: 1.5rem;
    }

    main.app-main {
        padding: 1rem;
        flex-grow: 1;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .step-container {
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    h2.question-title {
        font-size: 1.35rem;
        margin-bottom: 1rem;
    }

    .input-group {
        margin-bottom: 0.8rem;
    }

    .input-group label,
    input[type="text"],
    input[type="email"],
    select {
        font-size: 0.95rem;
        padding: 0.6rem 0.8rem;
    }

    .option-btn {
        padding: 0.6rem 1rem;
        font-size: 1rem;
    }

    .custom-select-trigger {
        padding: 0.6rem 1rem;
        font-size: 0.95rem;
        height: 45px;
    }

    .custom-option {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    .options-grid {
        gap: 0.5rem;
    }

    .form-navigation {
        margin-top: 1.5rem;
        gap: 10px;
    }

    .btn-continue,
    .btn-secondary {
        padding: 0.6rem 1.2rem;
        font-size: 1rem;
        min-width: 120px;
    }

    footer.app-footer {
        padding: 1rem;
    }

    .footer-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .logos-left,
    .logos-right {
        opacity: 0.9;
    }

    .logos-left img,
    .logos-right img {
        height: 35px;
    }
}

@media (max-width: 480px) {
    header.app-header {
        padding: 0.4rem 1rem;
    }

    .brand-merck {
        font-size: 1.2rem;
    }

    .hashtag {
        font-size: 0.9rem;
        margin-top: 0.2rem;
    }

    h2.question-title {
        font-size: 1.05rem;
        margin-bottom: 0.6rem;
    }

    .logos-left img,
    .logos-right img {
        height: 24px;
    }

    .terms-container {
        font-size: 0.75rem;
        align-items: flex-start;
        gap: 6px;
        margin-top: 0.4rem;
    }

    .terms-container input[type="checkbox"] {
        min-width: 16px;
        width: 16px;
        height: 16px;
    }

    .terms-container input[type="checkbox"]:checked::after {
        font-size: 10px;
    }

    .input-group label,
    input[type="text"],
    input[type="email"],
    select {
        font-size: 0.85rem;
        padding: 0.45rem 0.8rem;
    }

    .option-btn {
        padding: 0.45rem 1rem;
        font-size: 0.85rem;
    }

    .custom-select-trigger {
        padding: 0.45rem 0.8rem;
        font-size: 0.85rem;
        height: 38px;
    }

    .custom-option {
        padding: 0.45rem 0.8rem;
        font-size: 0.8rem;
    }

    .btn-continue,
    .btn-secondary {
        min-width: 90px;
        font-size: 0.85rem;
        padding: 0.4rem 1rem;
    }

    .footer-content {
        gap: 0.4rem;
    }
}