/* ==========================================================
   Laburian — login.css
   Sepadan dengan style.css & register.css
   Display: Space Grotesk · Body: Inter
   ========================================================== */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap");

:root {
  --paper: #f7f5ef;
  --paper-soft: #f1eee5;
  --ink: #14261c;
  --ink-soft: #4b5d52;
  --ink-faint: #7c8a80;
  --line: #e0dccf;
  --line-strong: #cdc8b6;
  --forest: #123528;
  --forest-deep: #0c271d;
  --accent: #1e7a4f;
  --accent-bright: #2f9d68;
  --accent-soft: rgba(30, 122, 79, 0.1);
  --lime: #d8f26a;
  --danger: #b8452f;
  --danger-soft: rgba(184, 69, 47, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-pill: 999px;
  --shadow-card: 0 20px 50px -22px rgba(18, 53, 40, 0.28);
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: "Space Grotesk", var(--font-body);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--lime);
  color: var(--forest-deep);
}

/* ---------- Halaman ---------- */

.auth-page {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px 24px;
  overflow: hidden;
}

.auth-page::before,
.auth-page::after {
  content: "";
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  filter: blur(130px);
  pointer-events: none;
}

.auth-page::before {
  top: -260px;
  right: -200px;
  width: 600px;
  height: 600px;
  background: rgba(216, 242, 106, 0.35);
}

.auth-page::after {
  bottom: -300px;
  left: -240px;
  width: 640px;
  height: 640px;
  background: rgba(30, 122, 79, 0.14);
}

/* ---------- Kad ---------- */

.auth-card {
  position: relative;
  z-index: 1;
  width: min(430px, 100%);
  padding: 44px 40px 40px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  animation: card-in 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

/* ---------- Jenama ---------- */

.brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 34px;
}

.brand-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--forest);
  color: var(--lime);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.brand p {
  margin: 6px 0 0;
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* ---------- Medan borang ---------- */

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field input {
  width: 100%;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 15.5px;
  color: var(--ink);
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

/* Password guna huruf beracuan tetap supaya bulatan lebih kemas */
.field input[type="password"] {
  letter-spacing: 0.08em;
}

.field input[type="password"]:placeholder-shown {
  letter-spacing: normal;
}

.field input::placeholder {
  color: var(--ink-faint);
}

.field input:hover {
  border-color: var(--line-strong);
}

.field input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* Hanya tanda merah selepas pengguna benar-benar salah isi */
.field input:user-invalid {
  border-color: var(--danger);
}

.field input:user-invalid:focus {
  box-shadow: 0 0 0 4px var(--danger-soft);
}

.field input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Buang latar kuning autofill Chrome */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 100px var(--paper-soft) inset;
  caret-color: var(--ink);
}

/* ---------- Mesej status ---------- */
/* login.js hanya tambah kelas "success"; ralat dihantar tanpa kelas,
   jadi keadaan lalai = ralat. */

.message {
  margin: 0;
}

.message:empty {
  display: none;
}

.message:not(:empty) {
  display: block;
  margin-bottom: 20px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: var(--radius-md);
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(184, 69, 47, 0.25);
  animation: message-in 0.25s ease both;
}

.message.success {
  color: #14503a;
  background: var(--accent-soft);
  border-color: rgba(30, 122, 79, 0.25);
}

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

/* ---------- Butang login ---------- */

.submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 30px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--paper);
  background: var(--forest);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  box-shadow: 0 16px 34px -16px rgba(18, 53, 40, 0.55);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease,
    box-shadow 0.2s ease;
}

.submit-btn:hover:not(:disabled) {
  background: var(--forest-deep);
  color: var(--lime);
  transform: translateY(-2px);
}

.submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.submit-btn:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}

.submit-btn:disabled {
  cursor: progress;
  opacity: 0.75;
  box-shadow: none;
  transform: none;
}

/* Spinner muncul automatik bila login.js set submitBtn.disabled = true */
.submit-btn:disabled::before {
  content: "";
  width: 15px;
  height: 15px;
  border: 2px solid rgba(247, 245, 239, 0.3);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Pautan alternatif (jika ditambah kemudian) ---------- */

.alt-link {
  margin: 24px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 14.5px;
  color: var(--ink-soft);
}

.alt-link a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-radius: 4px;
  transition: color 0.2s ease;
}

.alt-link a:hover {
  color: var(--accent-bright);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.alt-link a:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

/* ---------- Responsif ---------- */

@media (max-width: 480px) {
  .auth-page {
    padding: 24px 16px;
  }

  .auth-card {
    padding: 34px 24px 30px;
    border-radius: var(--radius-lg);
  }

  .brand {
    margin-bottom: 28px;
  }

  .brand h1 {
    font-size: 21px;
  }
}

/* ---------- Kurangkan gerakan ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .submit-btn:disabled::before {
    animation: none !important;
    border-top-color: var(--lime);
  }
}