/* ---- Base ---- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background: #e9eef1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    color: #1a1a1a;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* Avoid iOS auto-zoom on input focus by ensuring 16px+ font-size on inputs */
input, button, select, textarea {
    font-size: 16px;
}

/* ---- Card ---- */
.card {
    width: 100%;
    max-width: 560px;
    background: #ffffff;
    border-radius: 4px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* ---- Header ---- */
.card-header {
    background: #ffffff;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid #e6eaec;
}

.logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    line-height: 0;
}

.logo-img {
    height: 28px;
    width: auto;
    display: block;
}

/* ---- Language Selector ---- */
.lang-select {
    position: relative;
}

.lang-button {
    background: transparent;
    border: 0;
    color: #1a1a1a;
    font-size: 15px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 2px;
}

.lang-button:hover,
.lang-button:focus-visible {
    background: rgba(0, 0, 0, 0.05);
    outline: none;
}

.chevron {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.lang-button[aria-expanded="true"] .chevron {
    transform: rotate(180deg);
}

.lang-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 110px;
    background: #ffffff;
    color: #1a1a1a;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    list-style: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.lang-menu li {
    padding: 10px 14px;
    font-size: 14px;
    cursor: pointer;
}

.lang-menu li:hover {
    background: #f3f6f8;
}

.lang-menu li.is-active {
    color: #0a7f8f;
    font-weight: 600;
    background: #eef6f8;
}

/* ---- Body ---- */
.card-body {
    padding: 40px 48px 48px;
}

.title {
    text-align: center;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 36px;
    color: #1a1a1a;
}

/* Tighten the title's bottom margin when a subtitle follows */
.title:has(+ .subtitle) {
    margin-bottom: 10px;
}

.subtitle {
    text-align: center;
    color: #5b6b73;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 28px;
}

/* ---- Form ---- */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    color: #0a4d5c;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    color: #1a1a1a;
    background: #ffffff;
    border: 1px solid #cfd6da;
    border-radius: 2px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
}

.form-input::placeholder {
    color: #b6bcc1;
    font-style: italic;
}

/* Activation / OTP-style code field */
.code-input {
    text-align: center;
    letter-spacing: 3px;
    font-size: 18px;
    font-weight: 600;
    font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

.code-input::placeholder {
    letter-spacing: 3px;
    font-weight: 500;
    font-style: normal;
}

.form-input:focus {
    border-color: #0a7f8f;
    box-shadow: 0 0 0 2px rgba(10, 127, 143, 0.15);
}

/* ---- Phone input with country-code prefix ---- */
.phone-input {
    display: flex;
    align-items: stretch;
    border: 1px solid #cfd6da;
    border-radius: 2px;
    background: #ffffff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    overflow: hidden;
}

.phone-input:focus-within {
    border-color: #0a7f8f;
    box-shadow: 0 0 0 2px rgba(10, 127, 143, 0.15);
}

.phone-prefix {
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    background: #f3f6f8;
    color: #0a4d5c;
    font-weight: 600;
    font-size: 15px;
    border-right: 1px solid #cfd6da;
    user-select: none;
}

.phone-input .form-input {
    flex: 1;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.phone-input .form-input:focus {
    box-shadow: none;
}

/* Error state */
.form-group.has-error .form-input {
    border-color: #d94c3d;
}

.form-group.has-error .form-input:focus {
    box-shadow: 0 0 0 2px rgba(217, 76, 61, 0.15);
}

.form-group.has-error .phone-input {
    border-color: #d94c3d;
}

.form-group.has-error .phone-input:focus-within {
    box-shadow: 0 0 0 2px rgba(217, 76, 61, 0.15);
}

.error-message {
    color: #d94c3d;
    font-size: 13px;
    margin-top: 6px;
}

/* ---- Button ---- */
.btn-primary {
    width: 100%;
    padding: 14px 16px;
    background: #0a7f8f;
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1px;
    border: 0;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-family: inherit;
}

.btn-primary:hover {
    background: #086572;
}

.btn-primary:active {
    background: #074f5a;
}

.btn-primary:focus-visible {
    outline: 2px solid #0a4d5c;
    outline-offset: 2px;
}

/* ---- Responsive ---- */

/* Tablets and small laptops */
@media (max-width: 720px) {
    body {
        padding: 24px 14px;
    }

    .card-body {
        padding: 32px 32px 40px;
    }

    .title {
        font-size: 28px;
        margin-bottom: 30px;
    }

    .logo-img {
        height: 26px;
    }
}

/* Phones */
@media (max-width: 480px) {
    body {
        padding: 0;
        background: #ffffff;
        min-height: 100vh;
        /* Use dynamic viewport height where supported (iOS Safari address bar) */
        min-height: 100dvh;
        align-items: stretch;
    }

    .card {
        max-width: 100%;
        width: 100%;
        box-shadow: none;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .card-header {
        padding: 14px 18px;
    }

    .logo-img {
        height: 24px;
    }

    .lang-button {
        font-size: 14px;
        padding: 8px 10px;
        min-height: 40px;
    }

    .lang-menu {
        min-width: 130px;
    }

    .lang-menu li {
        padding: 12px 14px;
        font-size: 15px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .card-body {
        padding: 32px 22px 36px;
    }

    .title {
        font-size: 24px;
        margin-bottom: 26px;
    }

    .form-input {
        padding: 14px;
    }

    .btn-primary {
        padding: 16px;
        min-height: 52px;
        font-size: 15px;
    }
}

/* Very small devices (e.g. 320px) */
@media (max-width: 360px) {
    .card-body {
        padding: 28px 18px 32px;
    }

    .title {
        font-size: 22px;
        margin-bottom: 22px;
    }

    .logo-img {
        height: 22px;
    }
}

/* Landscape phones — keep things tighter so form fits without scroll */
@media (max-height: 480px) and (orientation: landscape) {
    body {
        padding: 12px;
    }

    .card-body {
        padding: 20px 24px 24px;
    }

    .title {
        font-size: 22px;
        margin-bottom: 18px;
    }

    .form-group {
        margin-bottom: 16px;
    }
}
