/* ─── Login — Apple-style Design System ─────────────────────────────────────── */

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --login-bg: #f5f5f7;
  --login-card-bg: #ffffff;
  --login-shadow: 0 2px 10px rgba(0, 0, 0, 0.05), 0 10px 40px rgba(0, 0, 0, 0.08);
  --login-input-border: #d2d2d7;
  --login-input-focus: #0071e3;
  --login-btn-bg: #0071e3;
  --login-btn-hover: #0077ED;
  --login-btn-active: #006edb;
  --login-btn-text: #ffffff;
  --login-text-primary: #1d1d1f;
  --login-text-secondary: #86868b;
  --login-error: #ff3b30;
  --login-font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  --login-radius-card: 16px;
  --login-radius-input: 10px;
  --login-radius-btn: 10px;
  --login-height-input: 48px;
}

/* ─── Page ──────────────────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  background: var(--login-bg);
  font-family: var(--login-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Wrapper ───────────────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ─── Card ──────────────────────────────────────────────────────────────────── */
.login-card {
  background: var(--login-card-bg);
  border-radius: var(--login-radius-card);
  box-shadow: var(--login-shadow);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

/* ─── Logo ──────────────────────────────────────────────────────────────────── */
.login-logo {
  margin-bottom: 20px;
}

.login-logo-icon {
  width: 40px;
  height: 40px;
}

/* ─── Title & Subtitle ─────────────────────────────────────────────────────── */
.login-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--login-text-primary);
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  line-height: 1.2;
}

.login-subtitle {
  font-size: 16px;
  font-weight: 400;
  color: var(--login-text-secondary);
  margin-bottom: 32px;
  line-height: 1.4;
}

/* ─── Error Message ─────────────────────────────────────────────────────────── */
.login-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 59, 48, 0.08);
  border: 1px solid rgba(255, 59, 48, 0.2);
  border-radius: var(--login-radius-input);
  color: var(--login-error);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  animation: fadeInError 0.2s ease;
}

.login-error svg {
  flex-shrink: 0;
}

.login-error.hidden {
  display: none;
}

@keyframes fadeInError {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Form ──────────────────────────────────────────────────────────────────── */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

/* ─── Input Group ───────────────────────────────────────────────────────────── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--login-text-primary);
  letter-spacing: -0.01em;
}

.login-input {
  width: 100%;
  height: var(--login-height-input);
  padding: 0 16px;
  border: 1px solid var(--login-input-border);
  border-radius: var(--login-radius-input);
  background: var(--login-card-bg);
  color: var(--login-text-primary);
  font-family: var(--login-font);
  font-size: 16px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.login-input::placeholder {
  color: #c7c7cc;
}

.login-input:focus {
  border-color: var(--login-input-focus);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

/* ─── Password Toggle ──────────────────────────────────────────────────────── */
.input-password-wrapper {
  position: relative;
}

.input-password-wrapper .login-input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--login-text-secondary);
  border-radius: 8px;
  transition: color 150ms ease, background-color 150ms ease;
}

.password-toggle:hover {
  color: var(--login-text-primary);
  background: rgba(0, 0, 0, 0.04);
}

.password-toggle svg.hidden {
  display: none;
}

/* ─── Submit Button ─────────────────────────────────────────────────────────── */
.login-btn {
  width: 100%;
  height: var(--login-height-input);
  margin-top: 8px;
  border: none;
  border-radius: var(--login-radius-btn);
  background: var(--login-btn-bg);
  color: var(--login-btn-text);
  font-family: var(--login-font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, transform 100ms ease, box-shadow 150ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.login-btn:hover {
  background: var(--login-btn-hover);
  box-shadow: 0 2px 12px rgba(0, 113, 227, 0.3);
}

.login-btn:active {
  background: var(--login-btn-active);
  transform: scale(0.98);
}

.login-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ─── Spinner ───────────────────────────────────────────────────────────────── */
.login-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: loginSpin 0.6s linear infinite;
}

.login-spinner.hidden {
  display: none;
}

@keyframes loginSpin {
  to { transform: rotate(360deg); }
}

/* ─── Toggle Link ──────────────────────────────────────────────────────────── */
.login-toggle {
  margin-top: 20px;
  font-size: 14px;
  color: var(--login-text-secondary);
}

.login-toggle a {
  color: var(--login-btn-bg);
  text-decoration: none;
  font-weight: 600;
}

.login-toggle a:hover {
  text-decoration: underline;
}

/* ─── Google Auth Section ───────────────────────────────────────────────────── */
.google-auth-section.hidden {
  display: none;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--login-input-border);
}

.login-divider-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--login-text-secondary);
  text-transform: lowercase;
}

.google-btn-container {
  display: flex;
  justify-content: center;
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */
.login-footer {
  margin-top: 16px;
  font-size: 13px;
  color: var(--login-text-secondary);
  letter-spacing: 0.04em;
}

/* ─── Shake Animation ───────────────────────────────────────────────────────── */
@keyframes shakeCard {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(7px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(2px); }
}

.login-card.shake {
  animation: shakeCard 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ─── Focus Ring ────────────────────────────────────────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--login-input-focus);
  outline-offset: 2px;
}

/* Input has its own focus style, override the outline */
.login-input:focus-visible {
  outline: none;
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .login-card {
    padding: 32px 24px;
    border-radius: 12px;
  }

  .login-title {
    font-size: 24px;
  }

  .login-subtitle {
    font-size: 15px;
    margin-bottom: 24px;
  }
}

/* ─── Small height screens ──────────────────────────────────────────────────── */
@media (max-height: 600px) {
  .login-wrapper {
    align-items: flex-start;
    padding-top: 40px;
  }
}
