/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  /* Type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Transitions */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Fonts */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', 'Helvetica Neue', sans-serif;
}

/* Color palette — matched to the cover photo's purple/navy tones */
:root,
[data-theme="light"] {
  /* Surfaces */
  --color-bg: #1a1028;
  --color-surface: rgba(255, 255, 255, 0.95);
  --color-surface-2: #f9fafb;
  --color-divider: #dde1e7;
  --color-border: #c8cdd5;

  /* Text */
  --color-text: #1a1f2e;
  --color-text-muted: #5c6478;
  --color-text-faint: #9ba3b3;
  --color-text-inverse: #ffffff;

  /* Primary: deep purple — matching the cover image */
  --color-primary: #3b1d6e;
  --color-primary-hover: #2d1555;
  --color-primary-active: #1f0e3c;
  --color-primary-highlight: #e3d6f5;

  /* Accent: muted gold — matching the cover's gold elements */
  --color-accent: #c9a84c;
  --color-accent-hover: #b89638;
  --color-accent-active: #a0822d;

  /* Success */
  --color-success: #1b7a3d;
  --color-success-highlight: #d4eddc;

  /* Error */
  --color-error: #b0282a;
  --color-error-highlight: #fce8e8;

  /* Brand panel text — light on the background */
  --brand-text: #e8e0f4;
  --brand-text-muted: rgba(255, 255, 255, 0.6);
  --brand-accent: #c9a84c;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(26, 16, 40, 0.1);
  --shadow-md: 0 4px 16px rgba(26, 16, 40, 0.15);
  --shadow-lg: 0 16px 48px rgba(26, 16, 40, 0.25);
  --shadow-xl: 0 24px 64px rgba(26, 16, 40, 0.35);
}

/* ============================================
   BASE RESET
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}

img, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }

a, button, [role="button"], input, textarea, select {
  transition: color var(--transition-interactive),
              background var(--transition-interactive),
              border-color var(--transition-interactive),
              box-shadow var(--transition-interactive);
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

button { cursor: pointer; background: none; border: none; }

/* ============================================
   LAYOUT — Full background image
   ============================================ */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* Background image layer */
.login-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('../images/coverphoto.jpg') center center / cover no-repeat;
  z-index: 0;
}

/* Dark overlay for readability */
.login-wrapper::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(26, 16, 40, 0.75) 0%,
    rgba(30, 20, 55, 0.65) 40%,
    rgba(20, 15, 45, 0.70) 100%
  );
  z-index: 1;
}

/* Hide the left brand panel — we use the full-bleed background now */
.brand-panel {
  display: none !important;
}

/* Right login panel — now centered over background */
.login-panel {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
  width: 100%;
}

.login-container {
  width: 100%;
  max-width: 520px;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-10);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(8px);
}

/* Mobile logo */
.mobile-logo {
  display: flex;
  justify-content: center;
  color: var(--color-primary);
  margin-bottom: var(--space-8);
}

.mobile-logo svg {
  width: 52px;
  height: 52px;
}

/* Header */
.login-header {
  margin-bottom: var(--space-8);
  text-align: center;
}

.login-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.login-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ============================================
   FORM STYLES
   ============================================ */
.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 0.01em;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: var(--space-4);
  color: var(--color-text-faint);
  pointer-events: none;
  flex-shrink: 0;
}

.form-input {
  width: 100%;
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-12);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  font-size: var(--text-base);
  color: var(--color-text);
  line-height: 1.5;
}

.form-input {
  padding-left: calc(var(--space-4) + 18px + var(--space-3));
}

.form-input::placeholder {
  color: var(--color-text-faint);
}

.form-input:hover {
  border-color: var(--color-text-muted);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-highlight);
}

/* Error state */
.form-group.has-error .form-input {
  border-color: var(--color-error);
}

.form-group.has-error .form-input:focus {
  box-shadow: 0 0 0 3px var(--color-error-highlight);
}

.form-group.has-error .input-icon {
  color: var(--color-error);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-error);
  min-height: 0;
  opacity: 0;
  transition: opacity var(--transition-interactive);
}

.form-group.has-error .form-error {
  opacity: 1;
}

/* Toggle password */
.toggle-password {
  position: absolute;
  right: var(--space-3);
  color: var(--color-text-faint);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}

.toggle-password:hover {
  color: var(--color-text-muted);
}

/* Remember + Forgot row */
.form-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.remember-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
}

.remember-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.custom-checkbox {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-interactive);
  flex-shrink: 0;
}

.remember-checkbox:checked + .custom-checkbox {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.remember-checkbox:checked + .custom-checkbox::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid var(--color-text-inverse);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}

.remember-checkbox:focus-visible + .custom-checkbox {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.forgot-link {
  font-size: var(--text-sm);
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.forgot-link:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* Submit button — deep purple to match the cover image */
.btn-login {
  width: 100%;
  padding: var(--space-4) var(--space-6);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font-size: var(--text-base);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  letter-spacing: 0.02em;
  min-height: 54px;
  position: relative;
}

.btn-login:hover {
  background: var(--color-primary-hover);
}

.btn-login:active {
  background: var(--color-primary-active);
  transform: translateY(1px);
}

.btn-login:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-login:disabled:active {
  transform: none;
}

.btn-spinner {
  animation: none;
}

/* Alert / success boxes */
.form-alert {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-error-highlight);
  color: var(--color-error);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid var(--color-error);
}

.form-alert svg {
  flex-shrink: 0;
}

.form-success {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-success-highlight);
  color: var(--color-success);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid var(--color-success);
}

.form-success svg {
  flex-shrink: 0;
}

/* Footer */
.login-footer {
  margin-top: var(--space-8);
  text-align: center;
}

.login-footer p {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  max-width: 100%;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 900px) {
  .mobile-logo {
    display: flex;
  }
  .login-header {
    text-align: center;
  }
}

@media (max-width: 560px) {
  .login-panel {
    padding: var(--space-4) var(--space-4);
  }
  .login-container {
    padding: var(--space-8) var(--space-6);
    border-radius: var(--radius-lg);
    max-width: 100%;
  }
  .mobile-logo svg {
    width: 44px;
    height: 44px;
  }
  .form-options {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-container {
  animation: fadeInUp 0.6s ease-out;
}

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