/* ============================================================
   FIREBASE AUTHENTICATION MODAL STYLES
   Implements MassiveMaw Popover Design Specification
   ============================================================ */

:root {
  --auth-shimmer-glow-hue: 222deg;
  --auth-shimmer-spring-easing: linear(
    0, 0.002, 0.01 0.9%, 0.038 1.8%, 0.156, 0.312 5.8%, 0.789 11.1%, 1.015 14.2%,
    1.096, 1.157, 1.199, 1.224 20.3%, 1.231, 1.231, 1.226, 1.214 24.6%,
    1.176 26.9%, 1.057 32.6%, 1.007 35.5%, 0.984, 0.968, 0.956, 0.949 42%,
    0.946 44.1%, 0.95 46.5%, 0.998 57.2%, 1.007, 1.011 63.3%, 1.012 68.3%,
    0.998 84%, 1
  );
  --auth-shimmer-spring-duration: 1.33s;
  --auth-fallback-spring-easing: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --auth-fallback-spring-duration: 0.6s;
}

@property --auth-shimmer {
  syntax: "<angle>";
  inherits: false;
  initial-value: 33deg;
}

/* ============================================================
   SHIMMER EFFECT OVERLAY
   ============================================================ */

.shimmer-shimmer {
  position: absolute;
  inset: calc(var(--inset, 40px) * -1);
  border-radius: inherit;
  pointer-events: none;
  mask-image: conic-gradient(
    from var(--auth-shimmer, 0deg),
    transparent 0%,
    transparent 20%,
    black 36%,
    black 45%,
    transparent 50%,
    transparent 70%,
    black 85%,
    black 95%,
    transparent 100%
  );
  mask-size: cover;
  mix-blend-mode: plus-lighter;
  animation: auth-shimmer-shimmer 1s linear infinite both;
}

.auth-oauth-btn:hover .shimmer-shimmer::before,
.auth-oauth-btn:hover .shimmer-shimmer::after,
.auth-btn-primary:hover .shimmer-shimmer::before,
.auth-btn-primary:hover .shimmer-shimmer::after,
.auth-tab-toggle-btn:hover .shimmer-shimmer::before,
.auth-tab-toggle-btn:hover .shimmer-shimmer::after {
  opacity: 1;
  animation: auth-shimmer-shine 1.2s ease-in 1 forwards;
}

.shimmer-shimmer::before,
.shimmer-shimmer::after {
  transition: all 0.5s ease;
  opacity: 0;
  content: "";
  border-radius: inherit;
  position: absolute;
  mix-blend-mode: color;
  inset: var(--inset, 40px);
  pointer-events: none;
}

.shimmer-shimmer::before {
  box-shadow:
    0 0 calc(var(--inset, 40px) * 0.1) 2px hsl(var(--auth-shimmer-glow-hue) 20% 95%),
    0 0 calc(var(--inset, 40px) * 0.18) 4px hsl(var(--auth-shimmer-glow-hue) 20% 80%),
    0 0 calc(var(--inset, 40px) * 0.33) 4px hsl(var(--auth-shimmer-glow-hue) 50% 70%),
    0 0 calc(var(--inset, 40px) * 0.66) 5px hsl(var(--auth-shimmer-glow-hue) 100% 70%);
  z-index: -1;
}

.shimmer-shimmer::after {
  box-shadow:
    inset 0 0 0 1px hsl(var(--auth-shimmer-glow-hue) 70% 95%),
    inset 0 0 2px 1px hsl(var(--auth-shimmer-glow-hue) 100% 80%),
    inset 0 0 5px 2px hsl(var(--auth-shimmer-glow-hue) 100% 70%);
  z-index: 2;
}

.shimmer-text {
  color: #ffffff;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-image: linear-gradient(
    120deg,
    #ffffff,
    rgba(255, 255, 255, 1) 40%,
    rgba(230, 230, 255, 1) 50%,
    #ffffff 52%
  );
  background-repeat: no-repeat;
  background-size: 300% 300%;
  background-position: 0% center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.auth-oauth-btn:hover .shimmer-text,
.auth-btn-primary:hover .shimmer-text,
.auth-tab-toggle-btn:hover .shimmer-text {
  animation: auth-shimmer-text 0.66s ease-in 1 both;
}

/* ============================================================
   MODAL CONTAINER & BACKDROP
   ============================================================ */

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1;
}

.auth-modal-content {
  position: relative;
  z-index: 2;
  width: 90%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 40px 32px;

  /* Glassmorphism */
  background: rgba(20, 30, 60, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0;

  /* Shadows */
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);

  /* Animation */
  animation: auth-slideUp 0.4s var(--auth-fallback-spring-easing) forwards;
  isolation: isolate;
}

/* Scrollbar hiding */
.auth-modal-content {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.auth-modal-content::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes auth-slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes auth-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes auth-shimmer-shimmer {
  0% { --auth-shimmer: 0deg; }
  100% { --auth-shimmer: 360deg; }
}

@keyframes auth-shimmer-shine {
  0% { opacity: 0; }
  15% { opacity: 1; }
  55% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes auth-shimmer-text {
  0% { background-position: 100% center; }
  100% { background-position: -100% center; }
}

/* ============================================================
   CLOSE BUTTON
   ============================================================ */

.auth-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1002;
  background: none;
  border: none;
  font-size: 32px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: color 0.3s ease, transform 0.3s ease;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

.auth-modal-close:hover {
  color: rgba(255, 255, 255, 1);
  transform: rotate(90deg) scale(1.1);
}

.auth-modal-close:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.5);
  border-radius: 0;
}

/* ============================================================
   HEADINGS & SUBTITLES
   ============================================================ */

.auth-modal-content h2 {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 8px 0;
  font-family: 'Syne', sans-serif;
}

.auth-subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  margin: 0 0 24px 0;
}

/* ============================================================
   TABS
   ============================================================ */

.auth-tab {
  display: none;
}

.auth-tab.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.auth-tabs-toggle {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  border-top: 1px solid rgba(76, 175, 255, 0.2);
  padding-top: 24px;
}

.auth-tab-toggle-btn {
  flex: 1;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
  border-radius: 0;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  font-size: 14px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  user-select: none;
  -webkit-user-select: none;
}

.auth-tab-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(76, 175, 255, 0.4);
  color: rgba(255, 255, 255, 0.9);
}

.auth-tab-toggle-btn.active {
  background: rgba(76, 175, 255, 0.25);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-color: rgba(76, 175, 255, 0.6);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(76, 175, 255, 0.15);
}

.auth-tab-toggle-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.5);
}

/* ============================================================
   OAUTH BUTTONS
   ============================================================ */

.auth-oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-oauth-btn {
  --inset: 30px;

  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.15);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--auth-fallback-spring-duration) var(--auth-fallback-spring-easing);
  font-size: 14px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.15),
    0 2px 4px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  user-select: none;
  -webkit-user-select: none;
}

.auth-oauth-btn:hover {
  transition-duration: calc(var(--auth-fallback-spring-duration) * 0.5);
  scale: 1.05;
  background: rgba(255, 255, 255, 0.25);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.2),
    0 4px 8px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.auth-oauth-btn:focus {
  outline: none;
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.2),
    0 0 0 3px rgba(74, 144, 226, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.auth-oauth-btn.google:hover {
  background: rgba(66, 133, 244, 0.25);
  border-color: rgba(66, 133, 244, 0.5);
}

.auth-oauth-btn.apple:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
}

/* ============================================================
   DIVIDER
   ============================================================ */

.auth-divider {
  text-align: center;
  margin: 20px 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  position: relative;
}

.auth-divider::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 35%;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(76, 175, 255, 0.3));
}

.auth-divider::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  width: 35%;
  height: 1px;
  background: linear-gradient(to left, transparent, rgba(76, 175, 255, 0.3));
}

/* ============================================================
   FORMS
   ============================================================ */

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-form-group label {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.auth-form-group input {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.3s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.auth-form-group input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.15);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-color: rgba(76, 175, 255, 0.6);
  box-shadow:
    0 0 0 3px rgba(76, 175, 255, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.auth-form-group input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.auth-form-group small {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: -2px;
}

/* ============================================================
   PRIMARY BUTTON
   ============================================================ */

.auth-btn-primary {
  --inset: 40px;

  position: relative;
  isolation: isolate;
  width: 100%;
  padding: 12px 16px;
  background: rgba(76, 175, 255, 0.25);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(76, 175, 255, 0.5);
  border-radius: 0;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--auth-fallback-spring-duration) var(--auth-fallback-spring-easing);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 8px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow:
    0 4px 12px rgba(76, 175, 255, 0.15),
    0 2px 4px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  user-select: none;
  -webkit-user-select: none;
}

.auth-btn-primary:hover {
  transition-duration: calc(var(--auth-fallback-spring-duration) * 0.5);
  scale: 1.05;
  background: rgba(76, 175, 255, 0.35);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
  border-color: rgba(76, 175, 255, 0.7);
  box-shadow:
    0 8px 20px rgba(76, 175, 255, 0.3),
    0 4px 8px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.auth-btn-primary:focus {
  outline: none;
  box-shadow:
    0 8px 20px rgba(76, 175, 255, 0.3),
    0 0 0 3px rgba(74, 144, 226, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.auth-btn-primary:active {
  scale: 0.98;
}

/* ============================================================
   FORM LINKS
   ============================================================ */

.auth-form-link {
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  margin: 8px 0 0 0;
}

.auth-form-link a {
  color: #4cAFFF;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s;
}

.auth-form-link a:hover {
  color: #fff;
  text-decoration: underline;
}

/* ============================================================
   STATUS MESSAGES
   ============================================================ */

.auth-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px 20px;
}

.auth-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(76, 175, 255, 0.2);
  border-top-color: #4cAFFF;
  border-radius: 0;
  animation: spin 0.6s linear infinite;
}

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

.auth-loading p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

/* ============================================================
   STATUS MESSAGES
   ============================================================ */

.auth-error {
  padding: 12px 14px;
  background: rgba(244, 67, 54, 0.2);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(244, 67, 54, 0.4);
  border-radius: 0;
  color: #ff8a80;
  font-size: 13px;
  margin-bottom: 16px;
  animation: auth-slideDown 0.3s ease forwards;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.auth-success {
  padding: 12px 14px;
  background: rgba(76, 175, 255, 0.2);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(76, 175, 255, 0.4);
  border-radius: 0;
  color: #80d8ff;
  font-size: 13px;
  margin-bottom: 16px;
  animation: auth-slideDown 0.3s ease forwards;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

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

/* ============================================================
   BROWSER FALLBACKS
   ============================================================ */

@supports not (backdrop-filter: blur(10px)) {
  .auth-modal-content {
    background: rgba(20, 30, 60, 0.35);
    box-shadow:
      0 25px 50px -12px rgba(0, 0, 0, 0.6),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }

  .auth-oauth-btn,
  .auth-btn-primary {
    background: rgba(255, 255, 255, 0.2);
    box-shadow:
      0 8px 16px rgba(0, 0, 0, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }

  .auth-oauth-btn:hover,
  .auth-btn-primary:hover {
    background: rgba(255, 255, 255, 0.3);
  }

  .auth-form-group input {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }

  .auth-form-group input:focus {
    background: rgba(255, 255, 255, 0.25);
    box-shadow:
      0 0 0 3px rgba(76, 175, 255, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);
  }
}

/* iOS Safari blur performance fix */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 768px) {
    .auth-modal-content {
      -webkit-backdrop-filter: blur(5px);
      backdrop-filter: blur(5px);
    }

    .auth-oauth-btn,
    .auth-btn-primary {
      -webkit-backdrop-filter: blur(5px);
      backdrop-filter: blur(5px);
    }

    .auth-form-group input {
      -webkit-backdrop-filter: blur(3px);
      backdrop-filter: blur(3px);
    }
  }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .auth-modal {
    padding: 1rem;
  }

  .auth-modal-content {
    width: 95%;
    max-height: 95vh;
    padding: 32px 24px;
    border-radius: 0;
  }

  .auth-modal-content h2 {
    font-size: 24px;
  }

  .auth-oauth-buttons {
    margin-bottom: 16px;
  }

  .auth-tab-toggle-btn {
    padding: 10px 12px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .auth-modal {
    padding: 0.5rem;
  }

  .auth-modal-content {
    width: 100%;
    max-height: 100vh;
    padding: 24px 16px;
    border-radius: 0;
    overflow-y: auto;
  }

  .auth-modal-content h2 {
    font-size: 20px;
  }

  .auth-modal-close {
    top: 12px;
    right: 12px;
    font-size: 28px;
    width: 36px;
    height: 36px;
  }

  .auth-form-group {
    gap: 4px;
  }

  .auth-form-group label {
    font-size: 12px;
  }

  .auth-form-group input,
  .auth-oauth-btn {
    padding: 10px 12px;
    font-size: 14px;
  }

  .auth-oauth-buttons {
    gap: 10px;
    margin-bottom: 12px;
  }

  .auth-form-link {
    font-size: 12px;
  }

  .auth-divider {
    margin: 16px 0;
    font-size: 12px;
  }

  .auth-tabs-toggle {
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
  }

  /* Touch-friendly button sizing */
  .auth-oauth-btn,
  .auth-btn-primary,
  .auth-tab-toggle-btn {
    min-height: 44px;
  }
}
