/* ==========================================================================
   Habuild Register Flow SE — popup.css
   Breakpoints: mobile-first
   Desktop  ≥ 1024px  → 468 px wide modal, centered
   Tablet   ≥  600px  → 360 px wide modal, centered
   Mobile   <  600px  → full-width minus 32px margins, bottom-anchored
   ========================================================================== */

/* Google Fonts import — Poppins + Montserrat */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&family=Montserrat:wght@400;700&display=swap');

/* --------------------------------------------------------------------------
   Custom properties (design tokens) — scoped to popup elements only
   -------------------------------------------------------------------------- */
#hb-se-reg-popup-overlay,
.hb-se-reg-country-dropdown,
.hb-se-reg-country-backdrop {
    --hb-se-reg-orange:       #f99434;
    --hb-se-reg-dark:         #1f1f1f;
    --hb-se-reg-dark-mid:     #303030;
    --hb-se-reg-gray:         #6c6c6c;
    --hb-se-reg-border:       #6c6c6c;
    --hb-se-reg-white:        #ffffff;
    --hb-se-reg-radius-modal: 16px;
    --hb-se-reg-radius-input: 12px;
    --hb-se-reg-radius-btn:   16px;
    --hb-se-reg-font-primary: 'Poppins', sans-serif;
    --hb-se-reg-font-accent:  'Montserrat', sans-serif;
    --hb-se-reg-transition:   220ms ease;
    --hb-se-reg-z-overlay:    99999;
}

/* --------------------------------------------------------------------------
   Overlay / backdrop
   -------------------------------------------------------------------------- */
.hb-se-reg-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--hb-se-reg-z-overlay);
    display: flex;
    align-items: flex-end;      /* mobile: bottom-anchored */
    justify-content: center;
    padding: 0;
    /* hidden by default — JS removes [hidden] and adds .hb-se-reg-open */
}

/* Tablet and up: center the modal */
@media (min-width: 600px) {
    .hb-se-reg-overlay {
        align-items: center;
        padding: 16px;
    }
}

.hb-se-reg-overlay[hidden] {
    display: none !important;
}

.hb-se-reg-overlay.hb-se-reg-open {
    display: flex;
    animation: hb-se-reg-overlay-in var(--hb-se-reg-transition) both;
}

@keyframes hb-se-reg-overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Mobile modal slides up from bottom */
@keyframes hb-se-reg-slide-up {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Semi-transparent dark backdrop */
.hb-se-reg-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Modal card
   -------------------------------------------------------------------------- */
.hb-se-reg-modal {
    position: relative;
    z-index: 1;
    background: var(--hb-se-reg-white);
    border-radius: var(--hb-se-reg-radius-modal);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.24);
    overflow: visible;

    /* Mobile: full-width edge-to-edge, pinned to bottom, flat bottom corners */
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    animation: hb-se-reg-slide-up 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Tablet: centered, fixed width, spring animation */
@media (min-width: 600px) {
    .hb-se-reg-modal {
        width: 100%;
        max-width: 360px;
        margin: 0;
        border-bottom-left-radius: var(--hb-se-reg-radius-modal);
        border-bottom-right-radius: var(--hb-se-reg-radius-modal);
        animation: hb-se-reg-modal-in 280ms cubic-bezier(0.34, 1.4, 0.64, 1) both;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .hb-se-reg-modal {
        max-width: 468px;
    }
}

@keyframes hb-se-reg-modal-in {
    from { opacity: 0; transform: scale(0.88) translateY(16px); }
    to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

/* --------------------------------------------------------------------------
   Close button
   -------------------------------------------------------------------------- */
.hb-se-reg-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--hb-se-reg-dark);
    transition: background var(--hb-se-reg-transition), color var(--hb-se-reg-transition);
    padding: 0;
    z-index: 2;
}

.hb-se-reg-close:hover,
.hb-se-reg-close:focus-visible {
    background: rgba(0, 0, 0, 0.07);
    outline: none;
}

.hb-se-reg-close svg {
    display: block;
    width: 20px;
    height: 20px;
}

/* --------------------------------------------------------------------------
   Body padding — 24px all screens (Figma spec)
   -------------------------------------------------------------------------- */
.hb-se-reg-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* --------------------------------------------------------------------------
   Tag / subtitle — 20px SemiBold all screens (Figma spec)
   -------------------------------------------------------------------------- */
.hb-se-reg-tag {
    font-family: var(--hb-se-reg-font-primary);
    font-weight: 600;
    font-size: 20px;
    line-height: 28px;
    color: var(--hb-se-reg-orange);
    text-align: center;
    margin-bottom: 8px;
}

/* --------------------------------------------------------------------------
   Heading — 24px mobile / 28px tablet / 40px desktop
   -------------------------------------------------------------------------- */
.hb-se-reg-heading {
    font-family: var(--hb-se-reg-font-primary);
    font-weight: 600;
    font-size: 24px;
    line-height: 1.25;
    color: var(--hb-se-reg-dark);
    text-align: center;
    letter-spacing: -0.5px;
    margin: 0 0 24px;
}

@media (min-width: 600px) {
    .hb-se-reg-heading {
        font-size: 28px;
        letter-spacing: -0.84px;
        line-height: 1.29;
        margin-bottom: 32px;
    }
}

@media (min-width: 1024px) {
    .hb-se-reg-heading {
        font-size: 40px;
        letter-spacing: -1.2px;
        line-height: 50px;
        margin-bottom: 40px;
    }
}

/* --------------------------------------------------------------------------
   Form — 24px gap all screens (Figma spec)
   -------------------------------------------------------------------------- */
.hb-se-reg-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* --------------------------------------------------------------------------
   Generic field wrapper
   -------------------------------------------------------------------------- */
.hb-se-reg-field {
    width: 100%;
}

/* Text input shared styles — 50px height, 16px all screens (Figma spec) */
.hb-se-reg-field input[type="text"],
.hb-se-reg-field input[type="tel"] {
    width: 100%;
    height: 50px;
    padding: 12px;
    border: 1px solid var(--hb-se-reg-border);
    border-radius: var(--hb-se-reg-radius-input);
    font-family: var(--hb-se-reg-font-primary);
    font-weight: 400;
    font-size: 16px;
    color: var(--hb-se-reg-dark);
    background: var(--hb-se-reg-white);
    outline: none;
    box-sizing: border-box;
    transition: border-color var(--hb-se-reg-transition), box-shadow var(--hb-se-reg-transition);
    -webkit-appearance: none;
    appearance: none;
}

.hb-se-reg-field input::placeholder {
    color: var(--hb-se-reg-gray);
}

.hb-se-reg-field input:focus {
    border-color: var(--hb-se-reg-dark);
    box-shadow: 0 0 0 3px rgba(31, 31, 31, 0.08);
}

.hb-se-reg-field input.hb-se-reg-invalid {
    border-color: #e53935;
    box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.1);
}

/* --------------------------------------------------------------------------
   Phone row  (flag + dial code  |  number input)
   -------------------------------------------------------------------------- */
.hb-se-reg-phone-row {
    display: flex;
    gap: 24px;
    align-items: stretch;
}

/* Country selector — wrapper */
.hb-se-reg-country-selector {
    position: relative;
    flex-shrink: 0;
}

/* Country selector — trigger button */
/* ID + !important on visual props beats any theme button reset */
#hb-se-reg-country-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    height: 50px !important;
    width: fit-content !important;
    min-width: unset !important;
    max-width: unset !important;
    padding: 12px 8px !important;
    border: 1px solid var(--hb-se-reg-border) !important;
    border-radius: 11px !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    font-family: var(--hb-se-reg-font-accent) !important;
    font-size: 15px !important;
    color: var(--hb-se-reg-gray) !important;
    box-shadow: none !important;
    outline: none !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: normal !important;
    box-sizing: border-box !important;
}

#hb-se-reg-country-btn:hover,
#hb-se-reg-country-btn:focus,
#hb-se-reg-country-btn[aria-expanded="true"] {
    border-color: var(--hb-se-reg-dark) !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: var(--hb-se-reg-gray) !important;
}

#hb-se-reg-country-btn:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* Flag image inside button */
.hb-se-reg-flag-img {
    width: 20px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
    display: block;
    flex-shrink: 0;
}

.hb-se-reg-dial {
    font-family: var(--hb-se-reg-font-accent);
    font-weight: 400;
    font-size: 14px;
    color: var(--hb-se-reg-gray);
}

/* Chevron arrow */
.hb-se-reg-chevron {
    display: block;
    flex-shrink: 0;
    transition: transform var(--hb-se-reg-transition);
}

#hb-se-reg-country-btn[aria-expanded="true"] .hb-se-reg-chevron {
    transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   Country dropdown — backdrop (mobile only)
   -------------------------------------------------------------------------- */
.hb-se-reg-country-backdrop {
    display: none;
}

@media (max-width: 599px) {
    .hb-se-reg-country-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 100000;
    }
    .hb-se-reg-country-backdrop[hidden] {
        display: none !important;
    }
}

/* --------------------------------------------------------------------------
   Country dropdown panel
   -------------------------------------------------------------------------- */

/* Country dropdown — always fixed, centered on mobile, JS-positioned on desktop */
.hb-se-reg-country-dropdown {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100001;
    width: calc(100vw - 48px);
    max-width: 360px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.hb-se-reg-country-dropdown[hidden] {
    display: none !important;
}

/* Modal header */
.hb-se-reg-country-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 8px;
    border-bottom: 1px solid #f0f0f0;
}

.hb-se-reg-country-modal-title {
    font-family: var(--hb-se-reg-font-primary);
    font-size: 16px;
    font-weight: 600;
    color: var(--hb-se-reg-dark);
}

/* Close X — div, not button, to avoid theme button styles */
.hb-se-reg-country-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    font-size: 22px;
    color: var(--hb-se-reg-gray);
    cursor: pointer;
    border-radius: 50%;
    padding: 0;
    line-height: 1;
    user-select: none;
}

.hb-se-reg-country-modal-close:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* Search input */
.hb-se-reg-country-search-wrap {
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.hb-se-reg-country-search {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-family: var(--hb-se-reg-font-primary);
    font-size: 13px;
    color: var(--hb-se-reg-dark);
    background: #fafafa;
    outline: none;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.hb-se-reg-country-search:focus {
    border-color: var(--hb-se-reg-dark);
    background: var(--hb-se-reg-white);
}

/* Country list */
.hb-se-reg-country-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}

.hb-se-reg-country-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background var(--hb-se-reg-transition);
}

.hb-se-reg-country-item:hover {
    background: #f5f5f5;
}

.hb-se-reg-country-item.hb-se-reg-selected {
    background: #f0f9fa;
}

.hb-se-reg-country-item img {
    width: 20px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
}

.hb-se-reg-country-name {
    flex: 1;
    font-family: var(--hb-se-reg-font-primary);
    font-size: 13px;
    color: var(--hb-se-reg-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hb-se-reg-country-dial {
    font-family: var(--hb-se-reg-font-accent);
    font-size: 13px;
    color: var(--hb-se-reg-gray);
    flex-shrink: 0;
}

.hb-se-reg-country-empty {
    padding: 16px;
    text-align: center;
    font-family: var(--hb-se-reg-font-primary);
    font-size: 13px;
    color: var(--hb-se-reg-gray);
    list-style: none;
}

/* Phone number input takes remaining width */
.hb-se-reg-phone-row input[type="tel"] {
    flex: 1;
    min-width: 0;
}

/* --------------------------------------------------------------------------
   Error message
   -------------------------------------------------------------------------- */
.hb-se-reg-error {
    font-family: var(--hb-se-reg-font-primary);
    font-size: 13px;
    color: #e53935;
    text-align: center;
    margin-top: -8px;
}

/* --------------------------------------------------------------------------
   Submit button
   -------------------------------------------------------------------------- */
/* Submit button — 20px Medium, 24px padding all screens (Figma spec) */
#hb-se-reg-popup-overlay .hb-se-reg-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px;
    background: var(--hb-se-reg-dark) !important;
    color: var(--hb-se-reg-white) !important;
    border: none !important;
    border-radius: var(--hb-se-reg-radius-btn) !important;
    font-family: var(--hb-se-reg-font-primary);
    font-weight: 500;
    font-size: 20px;
    line-height: 1.2;
    letter-spacing: -0.8px;
    cursor: pointer;
    transition: background var(--hb-se-reg-transition), transform 80ms ease;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: none !important;
    outline: none !important;
    margin-top: 0;
}

#hb-se-reg-popup-overlay .hb-se-reg-submit:hover {
    background: #333 !important;
}

#hb-se-reg-popup-overlay .hb-se-reg-submit:active {
    transform: scale(0.98);
}

#hb-se-reg-popup-overlay .hb-se-reg-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

/* Button + social proof sit 8px apart (Figma spec) */
#hb-se-reg-popup-overlay .hb-se-reg-submit + .hb-se-reg-social-proof {
    margin-top: 8px;
}

/* Spinner */
.hb-se-reg-submit-spinner svg {
    animation: hb-se-reg-spin 700ms linear infinite;
    display: block;
}

@keyframes hb-se-reg-spin {
    to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Social proof — 14px all screens (Figma spec)
   -------------------------------------------------------------------------- */
.hb-se-reg-social-proof {
    font-family: var(--hb-se-reg-font-primary);
    font-weight: 500;
    font-size: 14px;
    color: var(--hb-se-reg-dark-mid);
    text-align: center;
    margin: 0;
    line-height: 1.2;
}

.hb-se-reg-social-proof strong {
    font-family: var(--hb-se-reg-font-primary);
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   Success state
   -------------------------------------------------------------------------- */
.hb-se-reg-success {
    text-align: center;
    padding: 16px 0 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.hb-se-reg-success-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #e8f5e9;
    color: #2e7d32;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hb-se-reg-success h3 {
    font-family: var(--hb-se-reg-font-primary);
    font-weight: 600;
    font-size: 22px;
    color: var(--hb-se-reg-dark);
    margin: 0;
}

.hb-se-reg-success p {
    font-family: var(--hb-se-reg-font-primary);
    font-weight: 400;
    font-size: 14px;
    color: var(--hb-se-reg-gray);
    margin: 0;
    line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Accessibility: reduce motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .hb-se-reg-overlay.hb-se-reg-open,
    .hb-se-reg-modal,
    .hb-se-reg-submit-spinner svg {
        animation: none;
    }
}
