/* =========================================================
   AUTH PAGES (mhs/login.php, mhs/register.php)
   Design system sama dengan landing page (index_halamanutama.php)
   ========================================================= */
:root {
    --color-primary: #4F46E5;
    --color-primary-hover: #4338CA;
    --color-primary-soft: #EEF2FF;
    --color-accent: #6366F1;
    --color-text: #0F172A;
    --color-text-2: #334155;
    --color-muted: #64748B;
    --color-placeholder: #94A3B8;
    --color-border: #E2E8F0;
    --color-border-strong: #CBD5E1;
    --color-background: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-hero: #F5F6FF;

    --color-danger: #DC2626;
    --color-danger-soft: #FEF2F2;
    --color-danger-border: #FECACA;
    --color-success: #059669;
    --color-success-soft: #ECFDF5;
    --color-success-border: #A7F3D0;
    --color-info-soft: #F0F9FF;
    --color-info-border: #BAE6FD;
    --color-info: #0369A1;

    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --gutter: clamp(20px, 5vw, 32px);

    --radius-sm: 10px;
    --radius: 12px;
    --radius-lg: 20px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
    --shadow-card: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 32px -8px rgba(15, 23, 42, .08);
    --shadow-primary: 0 1px 2px rgba(67, 56, 202, .25), 0 6px 16px -4px rgba(79, 70, 229, .45);
    --shadow-primary-hover: 0 2px 4px rgba(67, 56, 202, .25), 0 12px 24px -6px rgba(79, 70, 229, .5);

    --ease: cubic-bezier(.2, .7, .2, 1);
    --dur: 200ms;
    --focus-ring: 0 0 0 3px var(--color-surface), 0 0 0 5px var(--color-accent);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-sans);
    font-size: .9375rem;
    line-height: 1.6;
    color: var(--color-text);
    background:
        radial-gradient(circle at 100% 0%, rgba(99, 102, 241, .12), transparent 45%),
        radial-gradient(circle at 0% 100%, rgba(79, 70, 229, .06), transparent 40%),
        var(--color-hero);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
h1, p { margin: 0; }
a { color: var(--color-primary); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
[hidden] { display: none !important; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor;
        stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Top bar ---------- */
.topbar {
    padding: calc(12px + env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 12px max(var(--gutter), env(safe-area-inset-left));
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.back-btn {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 44px; padding: 0 14px 0 10px; margin-left: -10px;
    border-radius: var(--radius-sm);
    font-weight: 600; font-size: .875rem; color: var(--color-text-2); text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.back-btn .icon { width: 18px; height: 18px; stroke-width: 2; }
.back-btn:active { background: rgba(79, 70, 229, .08); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: .875rem;
         color: var(--color-text); text-decoration: none; }
.brand img { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--color-border); background: #fff; }

/* ---------- Layout ---------- */
.auth-main {
    flex: 1;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 8px max(var(--gutter), env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}
.auth-wrap { width: 100%; max-width: 440px; }
.auth-wrap.is-wide { max-width: 520px; }

.auth-head { text-align: center; margin: 8px 0 24px; }
.auth-logo {
    width: 64px; height: 64px; margin: 0 auto 16px; padding: 5px;
    border-radius: 18px; background: var(--color-surface);
    border: 1px solid var(--color-border); box-shadow: var(--shadow-sm);
}
.auth-logo img { width: 100%; height: 100%; border-radius: 13px; object-fit: cover; }
.auth-title { font-size: clamp(1.5rem, 1.3rem + 1vw, 1.875rem); font-weight: 700; line-height: 1.2; letter-spacing: -.022em; }
.auth-sub { margin-top: 8px; color: var(--color-muted); font-weight: 500; text-wrap: pretty; }

.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 24px 20px;
}

.auth-foot { margin-top: 24px; text-align: center; color: var(--color-muted); }
.auth-foot a { font-weight: 600; text-decoration: none; }
.auth-foot .switch { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; border-radius: 8px; }

@media (min-width: 560px) {
    .auth-main { align-items: center; padding-top: 16px; }
    .auth-card { padding: 32px; }
    .auth-head { margin-top: 0; }
}
@media (hover: hover) and (pointer: fine) {
    .back-btn:hover { background: rgba(79, 70, 229, .08); color: var(--color-primary); }
    .auth-foot .switch:hover { background: var(--color-primary-soft); }
}

/* ---------- Form ---------- */
.field { margin-bottom: 18px; }
.field:last-of-type { margin-bottom: 0; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.label { display: block; margin-bottom: 6px; font-size: .875rem; font-weight: 600; color: var(--color-text-2); }
.label-row .label { margin-bottom: 0; }
.label .opt { font-weight: 500; color: var(--color-muted); }

.control { position: relative; }
.control > .icon.lead {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--color-placeholder); pointer-events: none;
    transition: color var(--dur) var(--ease);
}
.input {
    width: 100%;
    min-height: 52px;
    padding: 12px 14px 12px 44px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    font: 500 1rem/1.4 var(--font-sans);   /* 16px: cegah auto-zoom iOS */
    color: var(--color-text);
    -webkit-appearance: none; appearance: none;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.input::placeholder { color: var(--color-placeholder); font-weight: 400; }
.input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 4px rgba(79, 70, 229, .12); }
.control:focus-within > .icon.lead { color: var(--color-primary); }
.input.has-toggle { padding-right: 52px; }
.input:disabled, .input[readonly] { background: var(--color-background); color: var(--color-text-2); cursor: not-allowed; }
.input.is-invalid { border-color: var(--color-danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 4px rgba(220, 38, 38, .12); }
.control:has(.is-invalid) > .icon.lead { color: var(--color-danger); }

@media (hover: hover) and (pointer: fine) {
    .input:not(:focus):not(:disabled):hover { border-color: var(--color-muted); }
}

.pw-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 44px; height: 44px; display: grid; place-items: center;
    border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--color-muted);
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.pw-toggle .icon { width: 20px; height: 20px; }
.pw-toggle .i-hide { display: none; }
.pw-toggle[aria-pressed="true"] .i-show { display: none; }
.pw-toggle[aria-pressed="true"] .i-hide { display: block; }
.pw-toggle:active { background: var(--color-primary-soft); }
@media (hover: hover) and (pointer: fine) {
    .pw-toggle:hover { color: var(--color-primary); background: var(--color-primary-soft); }
}

.hint { display: flex; gap: 6px; margin-top: 6px; font-size: .8125rem; line-height: 1.5; color: var(--color-muted); }
.hint .icon { width: 15px; height: 15px; margin-top: 2px; }
.hint.is-error { color: var(--color-danger); font-weight: 500; }
.hint.is-error a { color: inherit; font-weight: 700; }

/* ---------- Password strength ---------- */
.pw-meter-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.pw-meter { flex: 1; height: 6px; border-radius: 6px; background: var(--color-border); overflow: hidden; }
.pw-meter-bar { height: 100%; width: 0; border-radius: 6px; transition: width .25s, background-color .25s; }
.pw-meter-text { min-width: 84px; text-align: right; font-size: .75rem; font-weight: 600; }

.pw-rules {
    list-style: none; margin: 10px 0 0; padding: 0;
    display: grid; grid-template-columns: 1fr; gap: 6px;
    font-size: .8125rem;
}
.pw-rules li { display: flex; align-items: center; gap: 6px; color: var(--color-muted); transition: color var(--dur) var(--ease); }
.pw-rules .icon { width: 16px; height: 16px; stroke-width: 2; }
.pw-rules .i-ok { display: none; }
.pw-rules li.ok { color: var(--color-success); font-weight: 600; }
.pw-rules li.ok .i-ok { display: block; }
.pw-rules li.ok .i-no { display: none; }
@media (min-width: 400px) { .pw-rules { grid-template-columns: 1fr 1fr; } }

.pw-match { display: flex; align-items: center; gap: 6px; min-height: 1.4em; margin-top: 6px; font-size: .8125rem; font-weight: 600; }
.pw-match .icon { width: 16px; height: 16px; stroke-width: 2; }
.pw-match.ok { color: var(--color-success); }
.pw-match.bad { color: var(--color-danger); }

.section-sep {
    display: flex; align-items: center; gap: 12px; margin: 24px 0 16px;
    font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--color-muted);
}
.section-sep::after { content: ""; flex: 1; height: 1px; background: var(--color-border); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; min-height: 52px; padding: 0 24px;
    border: 1px solid transparent; border-radius: var(--radius);
    font: 600 1rem/1 var(--font-sans);
    text-decoration: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
                background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn .icon { width: 18px; height: 18px; stroke-width: 2; }
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-primary); }
.btn-success { background: var(--color-success); color: #fff; box-shadow: 0 6px 16px -4px rgba(5, 150, 105, .4); }
.btn:active:not(:disabled) { transform: scale(.98); transition-duration: 80ms; }
.btn-primary:active:not(:disabled) { background: var(--color-primary-hover); }
.btn:disabled { background: #A5B4FC; box-shadow: none; cursor: not-allowed; }
.btn.is-loading:disabled { background: var(--color-primary); opacity: .85; cursor: progress; }
@media (hover: hover) and (pointer: fine) {
    .btn:hover:not(:disabled) { transform: translateY(-2px); }
    .btn:hover:active:not(:disabled) { transform: translateY(0) scale(.98); }
    .btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); box-shadow: var(--shadow-primary-hover); }
    .btn-success:hover:not(:disabled) { background: #047857; }
}

.link-btn {
    display: inline-flex; align-items: center; min-height: 32px; padding: 0 6px; margin-right: -6px;
    border: 0; border-radius: 8px; background: none;
    font: 600 .8125rem/1 var(--font-sans); color: var(--color-primary); cursor: pointer;
    position: relative;
}
/* perluas area sentuh tanpa mengubah layout */
.link-btn::after { content: ""; position: absolute; inset: -6px -4px; }
@media (hover: hover) and (pointer: fine) { .link-btn:hover { background: var(--color-primary-soft); } }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45);
           border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Alerts ---------- */
.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px; margin-bottom: 20px;
    border: 1px solid; border-radius: var(--radius);
    font-size: .875rem; line-height: 1.55;
}
.alert .icon { width: 18px; height: 18px; margin-top: 1px; stroke-width: 2; }
.alert-danger { background: var(--color-danger-soft); border-color: var(--color-danger-border); color: #991B1B; }
.alert-danger .icon { color: var(--color-danger); }

.success-state { text-align: center; }
.success-state .badge-icon {
    width: 56px; height: 56px; margin: 0 auto 16px; display: grid; place-items: center;
    border-radius: 16px; background: var(--color-success-soft); color: var(--color-success);
    border: 1px solid var(--color-success-border);
}
.success-state .badge-icon .icon { width: 26px; height: 26px; }
.success-state h2 { margin: 0 0 8px; font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; }
.success-state p { color: var(--color-muted); margin-bottom: 24px; overflow-wrap: anywhere; }
.success-state b { color: var(--color-text); }

/* ---------- Dialog (Lupa password) ---------- */
.dialog {
    width: min(400px, calc(100vw - 32px));
    padding: 28px 24px 24px; border: 0; border-radius: var(--radius-lg);
    background: var(--color-surface); color: var(--color-text);
    box-shadow: 0 24px 48px -12px rgba(15, 23, 42, .25);
    text-align: center;
}
.dialog::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
.dialog[open] { animation: dialog-in 220ms var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.dialog .badge-icon {
    width: 56px; height: 56px; margin: 0 auto 16px; display: grid; place-items: center;
    border-radius: 16px; background: var(--color-primary-soft); color: var(--color-primary);
}
.dialog .badge-icon .icon { width: 26px; height: 26px; }
.dialog h2 { margin: 0 0 8px; font-size: 1.125rem; font-weight: 700; }
.dialog p { margin: 0 0 24px; font-size: .9rem; color: var(--color-muted); }
.dialog b { color: var(--color-text); }
@media (max-width: 559px) {
    /* bottom sheet di smartphone: mudah dijangkau jempol */
    .dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0;
              padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
    .dialog[open] { animation-name: sheet-in; }
    @keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
}

/* ---------- Entrance ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.auth-head { animation: rise 480ms var(--ease) both; }
.auth-card { animation: rise 480ms 80ms var(--ease) both; }
.auth-foot { animation: rise 480ms 160ms var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0s !important; transition-duration: 1ms !important; }
    .spinner { animation-duration: 1.4s !important; }
    .btn:hover, .btn:active { transform: none !important; }
}
