/* ============================================================
   Login Page - Modern & Elegant
   ============================================================ */

/* FIX: Cegah horizontal scroll dari elemen dekoratif di seluruh halaman login */
html {
    overflow-x: hidden;
}

body.login-page {
    background: linear-gradient(135deg, #0d6e3d 0%, #0a5530 50%, #064224 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden; /* FIX: hidden semua arah di desktop, card cukup muat */
    padding: 20px;
    box-sizing: border-box;
    max-width: 100vw;
}

/* Animated background - dikurangi ukuran & dibatasi supaya tidak cause overflow */
body.login-page::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
    top: -150px;
    right: -150px;
    animation: float-bg 12s ease-in-out infinite;
    pointer-events: none;
}
body.login-page::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    bottom: -100px;
    left: -100px;
    animation: float-bg 16s ease-in-out infinite reverse;
    pointer-events: none;
}

@keyframes float-bg {
    0%, 100% { transform: translate(0,0) scale(1); }
    50%      { transform: translate(20px, -20px) scale(1.03); }
}

.login-wrapper {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 940px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    min-height: 540px;
    align-items: stretch;
    box-sizing: border-box;
}

[data-bs-theme="dark"] body.login-page { background: linear-gradient(135deg, #0a5530 0%, #064224 50%, #0f1419 100%); }
[data-bs-theme="dark"] .login-wrapper { background: var(--bg-card); }
[data-bs-theme="dark"] .login-form-inline { background: var(--bg-card); }
[data-bs-theme="dark"] .login-brand .brand-features { background: var(--bg-card); border-top-color: var(--border-color); }
[data-bs-theme="dark"] .login-brand .brand-footer { background: var(--bg-card); border-top-color: var(--border-color); color: var(--text-muted); }

/* LEFT: Branding */
.login-brand {
    background: linear-gradient(135deg, #0d6e3d 0%, #0a5530 100%);
    color: #fff;
    padding: 50px 40px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden; /* FIX: keep hidden, tapi konten diatur supaya tidak terpotong */
    min-width: 0;     /* FIX: mencegah grid item overflow */
    box-sizing: border-box;
}

.login-brand::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
    bottom: -100px;
    right: -100px;
    pointer-events: none;
}

.login-brand .brand-top {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.login-brand .brand-logo {
    width: 72px;
    height: 72px;
    background: rgba(255,255,255,0.15);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    overflow: hidden; /* FIX: logo tidak meluber ke luar */
}
.login-brand .brand-logo img {
    max-width: 44px;
    max-height: 44px;
    width: auto;
    height: auto;
    object-fit: contain;
}
.login-brand .brand-logo svg {
    width: 44px;
    height: 44px;
}

.login-brand .brand-text {
    min-width: 0; /* FIX: izinkan teks wrap di dalam grid */
    overflow-wrap: break-word;
    word-break: break-word;
}
.login-brand .brand-text h1 {
    font-size: clamp(18px, 3vw, 26px); /* FIX: responsive font size */
    font-weight: 800;
    margin: 0 0 8px;
    line-height: 1.2;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}
.login-brand .brand-text p {
    font-size: clamp(12px, 1.8vw, 14px); /* FIX: responsive font size */
    opacity: 0.9;
    margin: 0;
    line-height: 1.6;
    overflow-wrap: break-word;
    word-break: break-word;
}

.login-brand .brand-features {
    position: relative;
    z-index: 2;
    list-style: none;
    padding: 0;
    margin: 30px 0 0;
}
.login-brand .brand-features li {
    display: flex;
    align-items: flex-start; /* FIX: teks panjang wrap rapi */
    gap: 10px;
    margin-bottom: 12px;
    font-size: 13.5px;
    line-height: 1.4;
    min-width: 0;
}
.login-brand .brand-features i {
    color: #75e6a4;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.login-brand .brand-footer {
    position: relative;
    z-index: 2;
    font-size: 12px;
    opacity: 0.7;
    margin-top: auto;
    padding-top: 16px;
    flex-shrink: 0;
}

.login-brand .brand-footer-sub {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 2px;
    font-weight: 500;
}
.login-brand .brand-footer a {
    color: inherit;
    text-decoration: none;
}
.login-brand .brand-footer a:hover {
    text-decoration: underline;
}

/* RIGHT: Form */
.login-form-wrap {
    padding: 50px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    box-sizing: border-box;
}

.login-form-wrap .form-header {
    margin-bottom: 28px;
}
.login-form-wrap .form-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 6px;
}
.login-form-wrap .form-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
}

.login-input-group {
    position: relative;
    margin-bottom: 16px;
}
.login-input-group .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    z-index: 2;
    pointer-events: none;
}
.login-input-group .form-control {
    height: 48px;
    padding-left: 44px;
    padding-right: 44px;
    border-radius: 10px;
    font-size: 14px;
    background: var(--bg-body);
    border: 1.5px solid var(--border-color);
    transition: all 0.2s;
    width: 100%;
    box-sizing: border-box;
}
.login-input-group .form-control:focus {
    background: var(--bg-card);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(13,110,61,0.1);
}
.login-input-group .toggle-password {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    z-index: 2;
}
.login-input-group .toggle-password:hover { color: var(--primary); }

.login-form-check {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 18px 0 22px;
    font-size: 13px;
}
.login-form-check .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-login {
    height: 48px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 15px;
    width: 100%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
}
.btn-login:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(13,110,61,0.3);
}
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

.login-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}
.login-hint code {
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11.5px;
}

/* Alerts in login */
.login-alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: flex-start; /* FIX: teks alert panjang wrap rapi */
    gap: 8px;
    line-height: 1.4;
}
.login-alert.danger  { background: rgba(220,53,69,0.1);  color: #b02a37; }
.login-alert.warning { background: rgba(255,193,7,0.15); color: #997404; }
.login-alert.info    { background: rgba(13,202,240,0.1); color: #055160; }

/* Form inline di branding (hidden on desktop) */
.login-form-inline { display: none; }
.login-form-inline .form-header { display: none; }
.login-form-inline .login-form-mobile .login-input-group { margin-bottom: 14px; }

/* ===== Responsive: Tablet (<= 900px) ===== */
@media (max-width: 900px) {
    .login-wrapper {
        max-width: 100%;
    }
    .login-brand {
        padding: 36px 28px;
    }
    .login-form-wrap {
        padding: 36px 28px;
    }
    .login-form-wrap .form-header h2 {
        font-size: 21px;
    }
}

/* ===== Responsive: Mobile (<= 768px) ===== */
@media (max-width: 768px) {
    html {
        overflow-x: hidden;
    }

    body.login-page {
        padding: 12px;
        overflow-x: hidden;
        overflow-y: auto;  /* FIX: vertikal bisa scroll */
        align-items: flex-start; /* FIX: mulai dari atas */
        max-width: 100vw;
    }

    /* FIX: sembunyikan lingkaran dekoratif di mobile supaya tidak cause overflow */
    body.login-page::before,
    body.login-page::after {
        display: none;
    }

    .login-wrapper {
        grid-template-columns: 1fr;
        max-width: 440px;
        min-height: auto;
        overflow: hidden;
        width: 100%;
        margin: 16px auto;
        box-sizing: border-box;
    }
    .login-form-wrap { display: none; }

    /* Reset login-brand untuk mobile */
    .login-brand {
        display: block !important;
        background: none !important;
        padding: 0 !important;
        color: inherit !important;
        overflow: visible !important;
        min-height: auto !important;
        justify-content: initial !important;
        flex-direction: initial !important;
        min-width: 0 !important;
    }
    .login-brand::before { display: none !important; }

    /* Brand top: hijau */
    .login-brand .brand-top {
        position: relative;
        z-index: 2;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 16px;
        padding: 24px;
        background: linear-gradient(135deg, #0d6e3d 0%, #0a5530 100%);
        border-radius: 20px 20px 0 0;
        margin: 0;
        min-width: 0;
        box-sizing: border-box;
        overflow: hidden; /* FIX: clip konten yang meluber di brand-top */
    }
    .login-brand .brand-logo {
        width: 52px;
        height: 52px;
        min-width: 52px;
        margin-bottom: 0;
        background: rgba(255,255,255,0.15);
        flex-shrink: 0;
    }
    .login-brand .brand-logo img {
        max-width: 32px;
        max-height: 32px;
        width: auto;
        height: auto;
        object-fit: contain;
    }
    .login-brand .brand-logo svg {
        width: 32px;
        height: 32px;
    }
    .login-brand .brand-text {
        color: #fff;
        min-width: 0;
        overflow: hidden; /* FIX: clip teks panjang di dalam area ini */
    }
    .login-brand .brand-text h1 {
        font-size: 17px;
        margin-bottom: 2px;
        color: #fff;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    .login-brand .brand-text p {
        font-size: 12.5px;
        margin: 0;
        color: rgba(255,255,255,0.85);
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Form: putih */
    .login-form-inline {
        display: block;
        background: #fff;
        padding: 24px;
        box-sizing: border-box;
    }
    .login-form-inline .form-header { display: block; margin-bottom: 20px; }
    .login-form-inline .form-header h2 { font-size: 20px; font-weight: 700; color: #222831; margin: 0 0 4px; }
    .login-form-inline .form-header p { font-size: 13px; color: #6c757d; margin: 0; }
    .login-form-inline .login-alert.danger  { background: rgba(220,53,69,0.1);  color: #b02a37; }
    .login-form-inline .login-alert.warning { background: rgba(255,193,7,0.15); color: #997404; }
    .login-form-inline .form-check-label { color: #222831; }
    .login-form-inline .login-hint { color: #6c757d; border-top: 1px solid #e6e8eb; }
    .login-form-inline .login-input-group .form-control {
        width: 100%;
        box-sizing: border-box;
    }
    .login-form-inline .btn-login {
        width: 100%;
        box-sizing: border-box;
    }

    /* Features: 2 kolom */
    .login-brand .brand-features {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 6px 16px;
        background: #fff;
        padding: 20px 24px;
        margin: 0 !important;
        border-top: 1px solid #e6e8eb;
        list-style: none;
        position: relative;
        z-index: 2;
        box-sizing: border-box;
    }
    .login-brand .brand-features li {
        font-size: 12px;
        margin-bottom: 0;
        color: #222831;
        display: flex;
        align-items: flex-start;
        gap: 8px;
        min-width: 0;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    .login-brand .brand-features i { font-size: 13px; color: #0d6e3d; flex-shrink: 0; margin-top: 2px; }

    /* Footer */
    .login-brand .brand-footer {
        background: #fff;
        padding: 16px 24px;
        margin: 0 !important;
        border-top: 1px solid #e6e8eb;
        border-radius: 0 0 20px 20px;
        text-align: center;
        color: #6c757d;
        font-size: 12px;
        opacity: 1;
        position: relative;
        z-index: 2;
        box-sizing: border-box;
    }
    .login-brand .brand-footer-sub { display: block; margin-top: 2px; color: #6c757d; }
}

/* ===== Responsive: Mobile kecil (<= 480px) ===== */
@media (max-width: 480px) {
    html {
        overflow-x: hidden;
    }

    body.login-page {
        padding: 8px;
        overflow-x: hidden;
        overflow-y: auto;
        max-width: 100vw;
    }

    .login-wrapper {
        max-width: 100%;
        border-radius: 16px;
        width: 100%;
        box-sizing: border-box;
    }
    .login-brand .brand-top {
        padding: 20px;
        gap: 14px;
        border-radius: 16px 16px 0 0;
    }
    .login-brand .brand-logo {
        width: 46px;
        height: 46px;
        min-width: 46px;
        border-radius: 14px;
    }
    .login-brand .brand-logo img {
        max-width: 30px;
        max-height: 30px;
    }
    .login-brand .brand-logo svg {
        width: 30px;
        height: 30px;
    }
    .login-brand .brand-text h1 { font-size: 15.5px; }
    .login-brand .brand-text p { font-size: 12px; }

    .login-form-inline {
        padding: 20px;
        box-sizing: border-box;
    }
    .login-form-inline .form-header h2 { font-size: 18px; }
    .login-form-inline .login-form-mobile .login-input-group .form-control {
        height: 44px;
        font-size: 13px;
        width: 100%;
        box-sizing: border-box;
    }
    .login-form-inline .btn-login {
        height: 44px;
        font-size: 14px;
        width: 100%;
        box-sizing: border-box;
    }

    .login-brand .brand-features { padding: 16px 20px; gap: 4px 12px; }
    .login-brand .brand-features li { font-size: 11.5px; }
    .login-brand .brand-footer {
        padding: 12px 20px;
        border-radius: 0 0 16px 16px;
        font-size: 11px;
    }
}

/* ===== Responsive: Mobile sangat kecil (<= 360px) ===== */
@media (max-width: 360px) {
    html {
        overflow-x: hidden;
    }

    body.login-page {
        padding: 6px;
        overflow-x: hidden;
        overflow-y: auto;
        max-width: 100vw;
    }

    .login-brand .brand-top { padding: 16px; gap: 12px; }
    .login-brand .brand-logo { width: 42px; height: 42px; min-width: 42px; }
    .login-brand .brand-logo img { max-width: 26px; max-height: 26px; }
    .login-brand .brand-logo svg { width: 26px; height: 26px; }
    .login-brand .brand-text h1 { font-size: 14.5px; }
    .login-brand .brand-text p { font-size: 11px; }

    .login-form-inline { padding: 16px; box-sizing: border-box; }
    .login-form-inline .form-header { margin-bottom: 16px; }
    .login-form-inline .form-header h2 { font-size: 17px; }
    .login-form-inline .login-form-mobile .login-input-group { margin-bottom: 10px; }
    .login-form-inline .login-form-mobile .login-input-group .form-control {
        height: 40px;
        padding-left: 38px;
        font-size: 13px;
        width: 100%;
        box-sizing: border-box;
    }
    .login-form-inline .login-form-mobile .input-icon { left: 10px; font-size: 14px; }
    .login-form-inline .btn-login { height: 40px; width: 100%; box-sizing: border-box; }
    .login-form-inline .login-form-check { margin: 12px 0 16px; }
    .login-form-inline .login-hint { margin-top: 12px; padding-top: 10px; }

    .login-brand .brand-features { padding: 14px 16px; gap: 3px 10px; }
    .login-brand .brand-features li { font-size: 11px; }
    .login-brand .brand-features i { font-size: 12px; }
    .login-brand .brand-footer { padding: 10px 16px; border-radius: 0 0 12px 12px; font-size: 10px; }
}