/* ==========================================================================
   Login page (appCore/homepage/show.html.twig inside home.html.twig).
   Layout-level rules use body:has(.lh-login) so register / lost password
   pages, which share home.html.twig, keep their current look.
   ========================================================================== */

:root {
    --lg-blue: #0284c7;
    --lg-blue-dark: #0369a1;
    --lg-orange: #f97316;
    --lg-orange-hover: #ea580c;
    --lg-amber: #f59e0b;
    --lg-ink: #1e293b;
    --lg-ink-2: #334155;
    --lg-muted: #64748b;
    --lg-faint: #94a3b8;
    --lg-line: #e2e8f0;
    --lg-night: #0f172a;
}

/* --------------------------------------------------------------------------
   Page shell
   -------------------------------------------------------------------------- */
html:has(.lh-login) {
    background: var(--lg-night) !important;
}

body:has(.lh-login) {
    margin: 0 !important;
    padding: 0 !important;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--lg-night) !important;
    color: var(--lg-ink);
    overflow-x: hidden;
}

body:has(.lh-login),
body:has(.lh-login) :is(h1, h2, h3, p, a, span, div, label, input, button, nav):not(.fa):not([class*="icon"]) {
    font-family: "Tajawal", "Plus Jakarta Sans", "DroidArabicKufi", Tahoma, sans-serif;
}

body:has(.lh-login) .homepage__content {
    position: relative;
    z-index: 1;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    max-width: none;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
}

.lh-login__ambient,
.lh-login__grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.lh-login__ambient {
    background: radial-gradient(circle at 50% 20%, rgba(2, 132, 199, .16) 0%, rgba(249, 115, 22, .08) 45%, transparent 75%);
}

.lh-login__grid {
    opacity: .4;
    background-size: 32px 32px;
    background-image: radial-gradient(circle, rgba(2, 132, 199, .12) 1.5px, transparent 1.5px);
}

/* top bar (logo moves into the card; language + catalogue stay on top) */
body:has(.lh-login) .homepage__row--header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px;
    background: transparent !important;
    border: 0;
    box-shadow: none;
}

body:has(.lh-login) .homepage__row--header > a:first-child {
    display: none;
}

body:has(.lh-login) .homepage__row--header .pull-right {
    float: none !important;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

body:has(.lh-login) .select-language {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 4px 12px;
    border: 1px solid rgba(51, 65, 85, .7);
    border-radius: 12px;
    background: rgba(30, 41, 59, .9);
    color: #cbd5e1;
    font-size: 12px;
    backdrop-filter: blur(8px);
}

body:has(.lh-login) .select-language > span {
    color: #94a3b8;
    padding-inline-start: 8px;
}

body:has(.lh-login) .select-language #change_language {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    background: var(--lg-blue);
    color: #fff !important;
    font-weight: 700;
    text-decoration: none;
}

body:has(.lh-login) .select-language #change_language .fa {
    font-size: 10px;
}

body:has(.lh-login) .select-language .dropdown-menu {
    min-width: 140px;
    padding: 6px;
    border: 1px solid rgba(51, 65, 85, .8);
    border-radius: 12px;
    background: #1e293b;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
}

body:has(.lh-login) .select-language .dropdown-item {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 13px;
    text-decoration: none;
}

body:has(.lh-login) .select-language .dropdown-item:hover {
    background: rgba(51, 65, 85, .7);
    color: #fff;
}

body:has(.lh-login) .homepage__row--header .learnyhome-button,
.lh-login__catalogue .learnyhome-button {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border: 1px solid rgba(51, 65, 85, .8);
    border-radius: 12px;
    background: rgba(30, 41, 59, .6);
    color: #cbd5e1 !important;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    height: auto;
    min-height: 0;
    text-decoration: none;
    box-shadow: none;
}

body:has(.lh-login) .homepage__row--header .learnyhome-button:hover {
    border-color: #475569;
    color: #fff !important;
}

/* --------------------------------------------------------------------------
   Card
   -------------------------------------------------------------------------- */
.lh-login {
    position: relative;
    z-index: 1;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
    padding: 24px 16px 48px;
}

.lh-login__card {
    width: 100%;
    max-width: 576px;
    overflow: hidden;
    border: 1px solid #f1f5f9;
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .5);
    transition: box-shadow .3s ease;
}

.lh-login__card:hover {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .5), 0 0 35px -5px rgba(2, 132, 199, .25);
}

.lh-login__brand {
    padding: 32px 48px 24px;
    text-align: center;
    background: linear-gradient(to bottom, rgba(240, 249, 255, .7), transparent);
    border-bottom: 1px solid #f1f5f9;
}

.lh-login__logo {
    display: block;
    height: 64px;
    width: auto;
    max-width: 100%;
    margin: 0 auto 12px;
    object-fit: contain;
    transition: transform .2s ease;
}

.lh-login__logo:hover {
    transform: scale(1.05);
}

.lh-login__title {
    display: block !important;
    float: none !important;
    width: 100%;
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.4;
    color: var(--lg-ink);
    letter-spacing: -.01em;
    text-shadow: none !important;
}

.lh-login :is(h1, h2, h3, p, a, span, label) {
    text-shadow: none !important;
}

.lh-login__subtitle {
    display: block !important;
    float: none !important;
    margin: 6px 0 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--lg-muted);
}

.lh-login__body {
    padding: 28px 48px 40px;
}

.lh-login__catalogue {
    margin-bottom: 16px;
    text-align: center;
}

.lh-login__catalogue .learnyhome-button {
    background: #f8fafc;
    border-color: var(--lg-line);
    color: var(--lg-ink-2) !important;
}

/* --------------------------------------------------------------------------
   Form (markup comes from the FormaAuth plugin; enhanced by the inline script)
   -------------------------------------------------------------------------- */
.lh-login__base form,
.lh-login__base form > div {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
}

.lh-field__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.lh-field__label {
    margin: 0;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--lg-ink-2);
}

.lh-field__head .lh-login__lostpwd {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--lg-orange);
    text-decoration: none;
}

.lh-field__head .lh-login__lostpwd:hover {
    color: var(--lg-orange-hover);
    text-decoration: underline;
}

.lh-field__control {
    position: relative;
}

.lh-field__icon {
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-start: 16px;
    display: flex;
    align-items: center;
    color: var(--lg-faint);
    pointer-events: none;
    transition: color .15s ease;
}

.lh-field__icon svg,
.lh-field__toggle svg {
    width: 20px;
    height: 20px;
}

.lh-login__base input#login_userid,
.lh-login__base input#login_pwd {
    display: block;
    width: 100%;
    height: 52px;
    margin: 0;
    padding-block: 0;
    padding-inline: 44px 16px;
    border: 1px solid var(--lg-line);
    border-radius: 12px;
    background: rgba(248, 250, 252, .5);
    color: #0f172a;
    font-size: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.lh-login__base input#login_pwd {
    padding-inline-end: 48px;
}

.lh-login__base input#login_userid::placeholder,
.lh-login__base input#login_pwd::placeholder {
    color: var(--lg-faint);
}

.lh-login__base input#login_userid:focus,
.lh-login__base input#login_pwd:focus {
    outline: none;
    border-color: var(--lg-blue);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(2, 132, 199, .15);
}

.lh-field__control:focus-within .lh-field__icon {
    color: var(--lg-blue);
}

.lh-field__toggle {
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-end: 6px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    border: 0;
    background: none;
    color: var(--lg-faint);
    cursor: pointer;
    transition: color .15s ease;
}

.lh-field__toggle:hover,
.lh-field__toggle.is-on {
    color: var(--lg-blue);
}

/* reCAPTCHA keeps its own widget, just centered */
.lh-login__base .g-recaptcha {
    display: flex;
    justify-content: center;
}

/* submit */
.lh-submit {
    position: relative;
}

.lh-login__base input#login {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 16px 56px;
    border: 0 !important;
    border-radius: 16px;
    background: linear-gradient(to right, var(--lg-orange), var(--lg-amber)) !important;
    color: #fff !important;
    font-size: 16px;
    font-weight: 700;
    text-transform: none !important;
    letter-spacing: normal;
    text-shadow: none;
    box-shadow: 0 10px 25px -5px rgba(249, 115, 22, .4);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

.lh-login__base input#login:hover {
    transform: translateY(-2px);
    filter: brightness(.96);
    box-shadow: 0 14px 28px -6px rgba(234, 88, 12, .45);
}

.lh-login__base input#login:active {
    transform: translateY(0);
}

.lh-login__base input#login:focus-visible {
    outline: 3px solid rgba(249, 115, 22, .35);
    outline-offset: 2px;
}

.lh-login__base input#login[disabled] {
    cursor: not-allowed;
    opacity: .6;
    transform: none;
    box-shadow: none;
}

/* arrow after the label: --lh-label-w is measured by the inline script */
.lh-submit::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: calc(-1 * (var(--lh-label-w, 100px) / 2) - 30px);
    background: #fff;
    pointer-events: none;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 19l-7-7m0 0l7-7m-7 7h18'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 19l-7-7m0 0l7-7m-7 7h18'/%3E%3C/svg%3E") center / contain no-repeat;
}

.lh-submit[data-dir="ltr"]::after {
    margin-left: calc(var(--lh-label-w, 60px) / 2 + 10px);
    transform: scaleX(-1);
}

/* busy state while the login request runs (.is-loading is set by the inline script) */
.lh-submit > .fa-spin {
    display: none !important;
}

.lh-submit.is-loading input#login,
.lh-submit.is-loading input#login[disabled] {
    opacity: 1;
    cursor: progress;
    filter: saturate(.9);
    transform: none;
    box-shadow: 0 10px 25px -5px rgba(249, 115, 22, .3);
}

.lh-submit.is-loading::after {
    width: 20px;
    height: 20px;
    margin-top: -10px;
    border: 2.5px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    background: none;
    -webkit-mask: none;
    mask: none;
    transform: none;
    animation: lh-login-spin .7s linear infinite;
}

.lh-submit.is-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: 16px;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .22) 50%, transparent 70%) 0 0 / 220% 100%;
    pointer-events: none;
    animation: lh-login-shine 1.4s ease-in-out infinite;
}

@keyframes lh-login-spin {
    to { transform: rotate(360deg); }
}

@keyframes lh-login-shine {
    from { background-position: 120% 0; }
    to { background-position: -120% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .lh-submit.is-loading::before { animation: none; }
    .lh-submit.is-loading::after { animation-duration: 1.6s; }
}

/* secondary links (register / lost password when JS is off) */
.lh-login__links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 20px;
    margin: 22px 0 0;
    padding: 0;
    border: 0;
    background: none;
}

.lh-login__links a {
    font-size: 13px;
    font-weight: 700;
    color: var(--lg-blue);
    text-decoration: none;
}

.lh-login__links a:hover {
    color: var(--lg-blue-dark);
    text-decoration: underline;
}

/* social logins */
.lh-login__social {
    margin-top: 24px;
}

.lh-divider {
    position: relative;
    margin: 0 0 16px;
    text-align: center;
}

.lh-divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    border-top: 1px solid var(--lg-line);
}

.lh-divider span {
    position: relative;
    padding: 0 16px;
    background: #fff;
    font-size: 12px;
    font-weight: 700;
    color: var(--lg-faint);
}

/* messages */
.lh-alert {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.6;
}

.lh-alert b {
    font-weight: 700;
}

.lh-alert--error {
    border: 1px solid #fecdd3;
    background: #fff1f2;
    color: #be123c;
}

.lh-alert--info {
    border: 1px solid #bae6fd;
    background: #f0f9ff;
    color: #0369a1;
}

.lh-alert--block {
    margin-top: 0;
    text-align: center;
}

.lh-alert--block h3 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 800;
}

.lh-alert--block p,
.lh-alert--block .text {
    margin: 0;
}

/* school strip */
.lh-login__school {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 32px;
    border-top: 1px solid rgba(226, 232, 240, .8);
    background: rgba(248, 250, 252, .9);
}

.lh-login__school-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid rgba(2, 132, 199, .2);
    border-radius: 12px;
    background: rgba(2, 132, 199, .1);
    font-size: 18px;
}

.lh-login__school-badge img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.lh-login__school-badge img + span {
    display: none;
}

.lh-login__school-badge.is-empty span {
    display: inline;
}

.lh-login__school-name {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--lg-ink);
}

/* external pages under the card */
.lh-login__pages {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 24px;
    max-width: 900px;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
}

.lh-login__pages a,
.lh-login__links a {
    padding: 0 !important;
    border: 0 !important;
}

.lh-login__pages a {
    font-size: 12.5px;
    color: #94a3b8 !important;
    text-decoration: none;
}

.lh-login__pages a::before,
.lh-login__pages a::after,
.lh-login__links a::before,
.lh-login__links a::after {
    content: none !important;
    display: none !important;
}

.lh-login__pages a:hover {
    color: #fff !important;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
body:has(.lh-login) .homepage__footer {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 24px;
    border-top: 1px solid rgba(30, 41, 59, .8);
    background: rgba(2, 6, 23, .7) !important;
    color: #94a3b8;
    font-size: 12px;
    text-align: center;
    backdrop-filter: blur(12px);
}

body:has(.lh-login) .homepage__footer a {
    color: #38bdf8 !important;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

body:has(.lh-login) .homepage__footer a:hover {
    color: #7dd3fc !important;
}

body:has(.lh-login) .homepage__footer .powered_by {
    margin: 0;
    line-height: 1.9;
}

body:has(.lh-login) .homepage__footer .ownedby {
    color: #fff;
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */
@media (max-width: 575px) {
    body:has(.lh-login) .homepage__row--header { padding: 12px 16px; justify-content: center; }
    .lh-login { padding: 8px 12px 32px; }
    .lh-login__brand { padding: 24px 24px 20px; }
    .lh-login__logo { height: 54px; }
    .lh-login__title { font-size: 20px; }
    .lh-login__subtitle { font-size: 12.5px; }
    .lh-login__body { padding: 22px 24px 28px; }
    .lh-login__school { padding: 16px 24px; }
}

@media (prefers-reduced-motion: reduce) {
    .lh-login__card,
    .lh-login__logo,
    .lh-login__base input#login { transition: none; }
}
