/* ── Light theme (default) ────────────────────── */
:root {
  --color-primary:      #1A73E8;
  --color-on-primary:   #FFFFFF;
  --color-surface:      #FFFFFF;
  --color-background:   #F8F9FA;
  --color-on-surface:   #202124;
  --color-secondary:    #5F6368;
  --color-outline:      #747775;
  --color-error:        #B3261E;
  --color-toggle-bg:    rgba(0,0,0,.06);
  --color-toggle-hover: rgba(0,0,0,.10);
  --color-card-border:  transparent;
}

/* ── Dark theme ───────────────────────────────── */
[data-theme="dark"] {
  --color-primary:      #8AB4F8;
  --color-on-primary:   #003063;
  --color-surface:      #303134;
  --color-background:   #202124;
  --color-on-surface:   #E8EAED;
  --color-secondary:    #9AA0A6;
  --color-outline:      #5F6368;
  --color-error:        #F28B82;
  --color-toggle-bg:    rgba(255,255,255,.08);
  --color-toggle-hover: rgba(255,255,255,.13);
  --color-card-border:  rgba(255,255,255,.08);
}

/* ── System preference (no manual override) ───── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-primary:      #8AB4F8;
    --color-on-primary:   #003063;
    --color-surface:      #303134;
    --color-background:   #202124;
    --color-on-surface:   #E8EAED;
    --color-secondary:    #9AA0A6;
    --color-outline:      #5F6368;
    --color-error:        #F28B82;
    --color-toggle-bg:    rgba(255,255,255,.08);
    --color-toggle-hover: rgba(255,255,255,.13);
    --color-card-border:  rgba(255,255,255,.08);
  }
}

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

body {
  font-family: 'Roboto', sans-serif;
  background-color: var(--color-background);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: background-color 250ms ease;
}

/* ── Theme toggle ─────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--color-toggle-bg);
  color: var(--color-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 150ms ease, color 150ms ease;
}

.theme-toggle:hover { background: var(--color-toggle-hover); }

.theme-toggle .icon-moon,
.theme-toggle .icon-sun { display: none; }

[data-theme="dark"]  .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"]  .theme-toggle .icon-moon { display: none;  }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun  { display: none;  }

/* System default: show moon on light, sun on dark */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle .icon-moon { display: block; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
}
/* Fallback: if no system preference reported, show moon */
:root:not([data-theme]) .theme-toggle .icon-moon { display: block; }

/* ── Card ─────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: 28px;
  border: 1px solid var(--color-card-border);
  box-shadow:
    0 1px 2px rgba(0,0,0,.30),
    0 2px 6px 2px rgba(0,0,0,.15);
  padding: 48px 40px 36px;
  width: 100%;
  max-width: 440px;
  animation: card-enter 220ms cubic-bezier(.2, 0, 0, 1) both;
  transition: background-color 250ms ease, border-color 250ms ease;
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ── Logo ─────────────────────────────────────── */
.logo-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.logo-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--color-secondary);
  letter-spacing: .1px;
  transition: color 250ms ease;
}

/* ── Headings ─────────────────────────────────── */
.card-title {
  font-size: 24px;
  font-weight: 400;
  color: var(--color-on-surface);
  margin-bottom: 8px;
  transition: color 250ms ease;
}

.card-subtitle {
  font-size: 16px;
  color: var(--color-secondary);
  margin-bottom: 32px;
  transition: color 250ms ease;
}

/* ── MD3 Outlined Text Field ──────────────────── */
.text-field {
  position: relative;
  margin-bottom: 4px;
}

.text-field input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  font-family: 'Roboto', sans-serif;
  font-size: 16px;
  color: var(--color-on-surface);
  background: transparent;
  border: 1px solid var(--color-outline);
  border-radius: 4px;
  outline: none;
  transition: border-color 150ms ease, border-width 150ms ease, color 250ms ease;
}

.text-field input:focus {
  border: 2px solid var(--color-primary);
}

.text-field input.has-error,
.text-field input.has-error:focus {
  border: 2px solid var(--color-error);
}

/* Floating label */
.text-field label {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--color-outline);
  background: var(--color-surface);
  padding: 0 4px;
  pointer-events: none;
  transition: top 150ms ease, transform 150ms ease, color 150ms ease, background-color 250ms ease;
}

.text-field input:focus ~ label,
.text-field input:not(:placeholder-shown) ~ label {
  top: 0;
  transform: translateY(-50%) scale(.75);
  color: var(--color-primary);
}

.text-field input.has-error ~ label,
.text-field input.has-error:focus ~ label {
  color: var(--color-error);
}

/* ── Supporting / error text ──────────────────── */
.supporting-text {
  min-height: 20px;
  font-size: 12px;
  color: var(--color-error);
  padding: 4px 16px 0;
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.supporting-text svg { flex-shrink: 0; margin-top: 1px; }

/* ── Actions row ──────────────────────────────── */
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 32px;
}

/* MD3 Text button */
.btn-text {
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .1px;
  color: var(--color-primary);
  background: none;
  border: none;
  padding: 10px 12px;
  border-radius: 20px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  transition: background-color 150ms ease, color 250ms ease;
}

.btn-text:hover  { background: rgba(26,115,232,.08); }
.btn-text:active { background: rgba(26,115,232,.12); }

/* MD3 Filled button */
.btn-filled {
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .1px;
  color: var(--color-on-primary);
  background: var(--color-primary);
  border: none;
  padding: 10px 24px;
  border-radius: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: box-shadow 150ms ease, filter 150ms ease, background-color 250ms ease;
}

.btn-filled:hover  { filter: brightness(.92); box-shadow: 0 2px 6px 2px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.3); }
.btn-filled:active { filter: brightness(.88); box-shadow: 0 1px 2px rgba(0,0,0,.3); }

/* Ripple */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: ripple 550ms linear;
  background: rgba(255,255,255,.4);
  pointer-events: none;
}

@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

/* ── Footer ───────────────────────────────────── */
.card-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--color-secondary);
  line-height: 1.6;
  transition: color 250ms ease;
}

.card-footer a { color: var(--color-primary); text-decoration: none; transition: color 250ms ease; }
.card-footer a:hover { text-decoration: underline; }
