/*
 * SWC Microfinance — Login Page CSS
 * Scoped to .path-loan-login and #loan-login-form-wrapper
 * Uses BEM-style .swc-lf__ prefix for all login-form elements.
 * Does NOT pollute global styles.
 */

/* ── Page Background ─────────────────────────────────────────────────────── */
body.path-loan-login {
    margin: 0;
    padding: 0;
    background: #f5f0f9;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

body.path-loan-login .dialog-off-canvas-main-canvas {
    padding: 0;
    margin: 0;
}

/* Hide default Drupal regions on login page */
body.path-loan-login header:not(.swc-topnav),
body.path-loan-login .region-header,
body.path-loan-login .region-sidebar-first,
body.path-loan-login .region-sidebar-second,
body.path-loan-login #block-loan-management-theme-page-title {
    display: none !important;
}

body.path-loan-login .region-content {
    margin: 0;
    padding: 0;
}

/* ── Login Page Layout ───────────────────────────────────────────────────── */
.loan-login-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px 40px;
    min-height: calc(100vh - 58px);
    background:
        linear-gradient(135deg, rgba(85, 19, 98, 0.82) 0%, rgba(245, 240, 249, 0.96) 100%),
        url('https://images.unsplash.com/photo-1563013544-824ae1b704d3?auto=format&fit=crop&q=80&w=2000') center/cover no-repeat fixed;
}
.swc-login-layout {
    padding: 0 ;
    margin: 0;
    width: 100%;
}
.swc-login-layout .swc-lf__field, .swc-login-layout .swc-lf .js-form-item {
    padding-bottom: 0;
}

/* ── Login Card ──────────────────────────────────────────────────────────── */
.loan-login-card {
    background: #ffffff;
    width: 100%;
    max-width: 440px;
    border-radius: 20px;
    box-shadow:
        0 4px 6px -2px rgba(85, 19, 98, 0.08),
        0 20px 40px -8px rgba(85, 19, 98, 0.22),
        0 0 0 1px rgba(85, 19, 98, 0.06);
    overflow: hidden;
    position: relative;
    animation: lf-cardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes lf-cardIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }

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

/* ── Card Brand Header ───────────────────────────────────────────────────── */
.loan-login-card__brand {
    background: linear-gradient(135deg, #551362 0%, #7b2d9e 60%, #9439a5 100%);
    padding: 2rem 2rem 1.75rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.loan-login-card__brand::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
}

.loan-login-card__brand::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: -20px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(242, 169, 0, 0.08);
}

.loan-login-brand-icon {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
    backdrop-filter: blur(4px);
    position: relative;
    z-index: 1;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 0.375rem 0;
    letter-spacing: -0.02em;
    position: relative;
    z-index: 1;
}

.auth-subtitle {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.78);
    margin: 0;
    position: relative;
    z-index: 1;
}

/* ── Card Form Wrapper ───────────────────────────────────────────────────── */
.loan-login-card__form-wrapper {
    padding: 1.75rem;
}

/* Hide global Drupal messages on login page (show per-field only) */
.loan-login-card__form-wrapper>.messages--error:not(.inline-error) {
    display: none;
}

/* Show Drupal status messages (OTP sent) styled nicely */
.loan-login-card__form-wrapper .messages--status {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1.5px solid #a5d6a7;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── The form wrapper div ────────────────────────────────────────────────── */
.swc-lf {
    /* No extra padding — .loan-login-card__form-wrapper handles it */
}

/* ── OTP Notice Banner ───────────────────────────────────────────────────── */
.swc-lf__otp-notice {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    background: linear-gradient(135deg, #f5f0ff 0%, #fdf2f8 100%);
    border: 1.5px solid #e8dff5;
    border-left: 4px solid #7b2d9e;
    border-radius: 12px;
    padding: 1rem 1.125rem;
    margin-bottom: 1.25rem;
    animation: lf-slideDown 0.3s ease both;
}

@keyframes lf-slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

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

.swc-lf__otp-notice-icon {
    font-size: 1.75rem;
    flex-shrink: 0;
}

.swc-lf__otp-notice-title {
    font-size: 0.925rem;
    font-weight: 800;
    color: #3d1a5a;
    margin-bottom: 0.2rem;
}

.swc-lf__otp-notice-sub {
    font-size: 0.8rem;
    color: #6d5a7a;
    line-height: 1.4;
}

.swc-lf__otp-notice-sub strong {
    color: #7b2d9e;
    font-weight: 800;
}

/* ── Form Fields ─────────────────────────────────────────────────────────── */
.swc-lf__field,
.swc-lf .js-form-item {
    margin-bottom: 1.125rem;
    display: flex;
    flex-direction: column;
    /* Reserve space for error messages to prevent layout jump */
    padding-bottom: 1.6rem;
    position: relative;
}

.swc-lf__field:last-of-type,
.swc-lf .js-form-item:last-of-type {
    margin-bottom: 0;
}

/* Labels */
.swc-lf .js-form-item label,
.swc-lf__field label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #3d1a5a;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    letter-spacing: 0.01em;
}

.swc-lf .js-form-item label .form-required {
    color: #c62828;
    font-size: 0.9em;
}

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.swc-lf__input,
.swc-lf .js-form-item input.form-text,
.swc-lf .js-form-item input.form-password,
.swc-lf .js-form-item input.form-number {
    width: 100%;
    box-sizing: border-box;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid #e8dff5;
    border-radius: 12px;
    background: #faf8fc;
    color: #1a0a2e;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.swc-lf__input::placeholder,
.swc-lf .js-form-item input.form-text::placeholder,
.swc-lf .js-form-item input.form-password::placeholder {
    color: #c4b5d4;
    font-weight: 400;
}

/* Focus state */
.swc-lf__input:focus,
.swc-lf .js-form-item input.form-text:focus,
.swc-lf .js-form-item input.form-password:focus {
    border-color: #7b2d9e;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(123, 45, 158, 0.10);
}

/* OTP input – centered large digits */
.swc-lf__input--otp {
    text-align: center !important;
    font-size: 1.75rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.5em !important;
    padding: 0.875rem 1.25rem !important;
    color: #551362 !important;
}

/* ── Validation States ───────────────────────────────────────────────────── */

/* Error input */
.swc-lf .js-form-item.form-item--error input.form-text,
.swc-lf .js-form-item.form-item--error input.form-password,
.swc-lf .js-form-item input.swc-lf__input.error,
.swc-lf input.swc-lf__input.error {
    border-color: #c62828 !important;
    background: #fff8f8 !important;
    box-shadow: 0 0 0 4px rgba(198, 40, 40, 0.10) !important;
}

.swc-lf .js-form-item.form-item--error input:focus {
    border-color: #c62828 !important;
    box-shadow: 0 0 0 4px rgba(198, 40, 40, 0.15) !important;
}

/* Error message */
.swc-lf .form-item--error-message,
.swc-lf .swc-field-error {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #c62828;
    margin-top: 0.375rem;
    padding: 0.4rem 0.75rem;
    background: rgba(198, 40, 40, 0.06);
    border: 1px solid rgba(198, 40, 40, 0.2);
    border-radius: 8px;
    animation: lf-errorIn 0.2s ease both;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

.swc-lf .form-item--error-message::before,
.swc-lf .swc-field-error::before {
    content: '⚠';
    font-size: 0.85rem;
    flex-shrink: 0;
}

@keyframes lf-errorIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

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

/* Field description (OTP timer) */
.swc-lf .js-form-item .description {
    font-size: 0.8rem;
    color: #7b5f99;
    margin-top: 0.4rem;
}

.swc-lf .js-form-item .description strong {
    color: #c62828;
    font-weight: 800;
}

/* ── Form Actions ────────────────────────────────────────────────────────── */
.swc-lf__actions,
.swc-lf .form-actions {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.swc-lf__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 0.75rem 1.5rem;
    font-size: 0.975rem;
    font-weight: 800;
    font-family: inherit;
    border-radius: 14px;
    cursor: pointer;
    text-decoration: none;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    border: 2px solid transparent;
    -webkit-appearance: none;
    appearance: none;
}

/* Primary — solid purple */
.swc-lf__btn--primary,
.swc-lf .form-actions input.form-submit,
.swc-lf .form-actions button.form-submit {
    background: linear-gradient(135deg, #551362 0%, #7b2d9e 60%, #9439a5 100%);
    color: #ffffff !important;
    border: none !important;
    border-radius: 14px !important;
    box-shadow: 0 4px 14px rgba(85, 19, 98, 0.30);
    width: 100% !important;
    min-height: 48px !important;
    font-size: 0.975rem !important;
    font-weight: 800 !important;
    padding: 0.75rem 1.5rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
    cursor: pointer !important;
    font-family: inherit !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.22s ease !important;
}

.swc-lf__btn--primary:hover,
.swc-lf .form-actions input.form-submit:hover,
.swc-lf .form-actions button.form-submit:hover {
    box-shadow: 0 8px 24px rgba(85, 19, 98, 0.45) !important;
    transform: translateY(-2px) !important;
}

.swc-lf__btn--primary:active,
.swc-lf .form-actions input.form-submit:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 8px rgba(85, 19, 98, 0.25) !important;
}

/* Ghost / Back button */
.swc-lf__btn--ghost {
    background: transparent;
    color: #7b5f99 !important;
    border-color: #e8dff5;
    font-size: 0.875rem !important;
    font-weight: 600;
    min-height: 44px;
    text-transform: none;
    letter-spacing: 0;
}

.swc-lf__btn--ghost:hover {
    background: #f5f0f9;
    color: #551362 !important;
}

/* Disabled state */
.swc-lf .form-actions input.form-submit[disabled],
.swc-lf__btn[disabled] {
    background: #e8e0f0 !important;
    color: #b09cc0 !important;
    box-shadow: none !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.swc-global-footer {
    background: rgba(255, 255, 255, 0.93);
    padding: 14px 20px;
    text-align: center;
    font-size: 0.82rem;
    color: #888;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    width: 100%;
    box-sizing: border-box;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .loan-login-page {
        padding: 0;
        align-items: flex-start;
    }

    .loan-login-card {
        border-radius: 0;
        min-height: 92vh;
        box-shadow: none;
        max-width: 100%;
    }

    .loan-login-card__brand {
        padding: 1.5rem 1.25rem 1.35rem;
    }

    .loan-login-card__form-wrapper {
        padding: 1.25rem;
    }

    .auth-title {
        font-size: 1.3rem;
    }
    .loan-login-card__form-wrapper {
        margin-top: 50px;
    }
    .swc-login-layout {
        padding: 0 ;
        margin: 0;
        width: 100%;
    }
}

@media (min-width: 481px) {
    .loan-login-page {
        min-height: calc(100vh - 58px - 50px);
    }
    
}