/**
 * Authentication Pages Styles
 * Login, Account Settings, Password pages
 */

/* Flexbox layout for auth pages - sticky footer, no double scroll */
html:has(.auth-page) {
  height: 100%;
  overflow: hidden !important; /* Completely disable html scroll */
  scrollbar-gutter: unset;
}

body:has(.auth-page) {
  display: flex;
  height: 100vh;
  margin: 0;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto; /* Only body scrolls if needed */
}

body:has(.auth-page) .header {
  flex-shrink: 0;
}

body:has(.auth-page) .footer {
  display: none;
}

/* Hide mobile search bar from flex layout on auth pages */
body:has(.auth-page) .mobile-search-bar {
  display: none;
}

/* Auth Page Container */
.auth-page {
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px 100px 20px;
  overflow: visible;
  min-height: 0; /* Allow flex item to shrink below content size */
}

.auth-container {
  width: 100%;
  max-width: 470px;
  margin: 0 auto;
  padding-bottom: 32px;
}

/* Page Title */
.auth-title {
  font-family: var(--ff-display);
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  margin-bottom: 20px;
  text-align: center;
  color: var(--color-text);
  max-width: 300px;
  margin: 32px auto;
}

.auth-subtitle {
  font-family: var(--ff-sans-medium);
  font-size: var(--fs-body);
  color: var(--color-text);
  margin: 16px 0 16px 0;
  text-align: center;
}

/* Benefits Section */
.auth-benefits {
  width: 100%;
  background: var(--grey-03);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  margin-bottom: 24px;
  box-sizing: border-box;
}

.auth-benefit-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-benefit-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.auth-benefit-item span {
  font-family: var(--ff-sans-medium);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-body-sm);
  color: var(--black);
}

/* Form Styles */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-input-group {
  display: flex;
  flex-direction: column;
}

.auth-label {
  font-family: var(--font-family-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
}

.auth-input {
  width: 100%;
  padding: 12px 12px;
  font-family: var(--ff-sans-medium);
  font-size: 1rem;
  border: 1px solid var(--grey-15);
  border-radius: 4px;
  background: var(--color-background, #fff);
  color: var(--grey-15);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  box-sizing: border-box;
}

.auth-input:focus {
  outline: none;
  border-color: var(--color-text);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.auth-input::placeholder {
  color: var(--text-secondary);
}

/* Password Input with Eye Toggle */
.auth-password-wrapper {
  position: relative;
}

.auth-password-wrapper .auth-input {
  padding-right: 48px; /* Space for eye icon */
}

.password-toggle-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--grey-15, #666);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.password-toggle-btn:hover {
  color: var(--color-text, #000);
}

.eye-icon {
  width: 20px;
  height: 20px;
}

/* Forgot Password Link (right-aligned below password) */
.auth-forgot-password {
  text-align: right;
  margin: -10px 0 0 0;
}

.auth-forgot-password a {
  font-family: var(--font-family-body);
  font-size: var(--fs-body-sm);
  color: var(--color-text-secondary);
  text-decoration: underline;
}

.auth-forgot-password a:hover {
  text-decoration: none;
}

/* Switch Link (Already have account? / New to Forthgreen?) */
.auth-switch-link {
  text-align: center;
  font-family: var(--ff-sans-medium);
  margin: 16px 0 12px 0;
  font-size: var(--fs-body-sm);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-switch-link a {
  color: var(--color-text);
  text-decoration: underline;
}

.auth-switch-link a:hover {
  text-decoration: none;
}

/* Auth Toggle (Sign In / Sign Up) - deprecated, keeping for backward compat */
.auth-toggle {
  margin-bottom: 1.5rem;
}

.auth-toggle-label {
  font-family: var(--ff-sans);
  font-size: 0.9375rem;
  color: var(--color-text-secondary, #666);
  text-align: center;
  margin-bottom: 0.75rem;
}

.auth-toggle-buttons {
  display: flex;
  gap: 0.5rem;
}

.auth-toggle-btn {
  flex: 1;
  padding: 0.875rem 1rem;
  font-family: var(--ff-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary, #666);
  background: transparent;
  border: 1px solid var(--grey-08, #e0e0e0);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-toggle-btn:hover {
  border-color: var(--color-text, #000);
  color: var(--color-text, #000);
}

.auth-toggle-btn.active {
  background: var(--black, #000);
  color: var(--white, #fff);
  border-color: var(--black, #000);
}

/* Primary Button */
.auth-btn-primary {
  width: 100%;
  padding: 14px 12px;
  font-family: var(--ff-sans-medium);
  font-weight: var(--ff-sans-medium);
  font-size: var(--fs-body-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--white);
  background: var(--black);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.1s;
}

.auth-btn-primary:hover {
  background: var(--grey-15);
  color: var(--white);
}

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

.auth-btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 12px 0;
}

.auth-divider-line {
  flex: 1;
  height: 1px;
  background: var(--color-border, #e0e0e0);
}

.auth-divider-text {
  font-family: var(--ff-sans-medium);
  font-size: var(--fs-body-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* OAuth Button */
.auth-btn-oauth {
  width: 100%;
  padding: 12px 12px;
  font-family: var(--font-family-body);
  font-size: var(--fs-body);
  font-weight: var(--ff-sans-medium);
  color: var(--color-text);
  background: var(--white);
  border: 1px solid var(--grey-08);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition:
    background 0.2s,
    border-color 0.2s;
}

.auth-btn-oauth:hover {
  background: var(--grey-03);
}

.auth-btn-oauth img {
  width: 20px;
  height: 20px;
}

/* Terms Text */
.auth-terms {
  font-family: var(--ff-sans);
  font-size: var(--fs-caption);
  color: var(--grey-13);
  line-height: var(--lh-caption);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  max-width: 300px;
  margin: 0 auto;
}

.auth-terms a {
  color: var(--color-text);
  text-decoration: underline;
}

.auth-terms a:hover {
  text-decoration: none;
}

/* Info Box */
.auth-info-box {
  padding: 1rem 1.25rem;
  background: #f5f5f5;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.auth-info-box p {
  font-family: var(--font-family-body);
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin: 0;
}

.auth-info-box a {
  color: var(--color-text);
  text-decoration: underline;
}

/* Account Settings Specific */
.settings-section {
  padding: 1.5rem 0;
  border: 1px solid var(--grey-06);
  padding: 24px 16px;
  margin-bottom: 16px;
  border-radius: 4px;
}

.settings-label {
  font-family: var(--font-sans-medium);
  font-size: var(--fs-body-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.settings-value {
  font-family: var(--font-family-body);
  font-size: var(--fs-body);
  color: var(--color-text-secondary);
  margin-bottom: 0px;
}

.settings-link {
  font-family: var(--ff-sans-medium);
  color: var(--color-text);
  text-decoration: underline;
  cursor: pointer;
}

.settings-link:hover {
  text-decoration: none;
}

/* Error Message */
.auth-error {
  padding: 1rem;
  background: #fee;
  border: 1px solid #fcc;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.auth-error p {
  font-family: var(--font-family-body);
  font-size: 0.875rem;
  color: #c00;
  margin: 0;
}

.auth-error a {
  color: #c00;
  text-decoration: underline;
}

.auth-error a:hover {
  text-decoration: none;
}

/* Success Message */
.auth-success {
  padding: 1rem;
  background: #efe;
  border: 1px solid #cfc;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.auth-success p {
  font-family: var(--font-family-body);
  font-size: 0.875rem;
  color: #060;
  margin: 0;
}

.auth-success a {
  color: #060;
  text-decoration: underline;
}

.auth-success a:hover {
  text-decoration: none;
}

/* Loading State */
.auth-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.auth-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: auth-spin 0.8s linear infinite;
}

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

/* Danger/Delete Account Styles */
/* .settings-section-danger {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--grey-06);
} */

.settings-link-danger {
  font-family: var(--ff-sans-medium);
  font-size: var(--fs-body);
  color: #dc2626;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.settings-link-danger:hover {
  color: #b91c1c;
}

/* Confirmation Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 8px;
  padding: 32px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-title {
  font-family: var(--ff-sans-medium);
  font-size: var(--fs-h3);
  margin: 0 0 8px 0;
  color: var(--black);
}

.modal-text {
  font-family: var(--ff-sans);
  font-size: var(--fs-body);
  color: var(--grey-15);
  margin: 0 0 24px 0;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-btn {
  font-family: var(--ff-sans-medium);
  font-size: var(--fs-body);
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition:
    background-color 0.2s,
    opacity 0.2s;
}

.modal-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.modal-btn-cancel {
  background: var(--grey-03);
  color: var(--black);
}

#userEmail {
  margin-bottom: 8px !important;
}

.modal-btn-cancel:hover:not(:disabled) {
  background: var(--grey-06);
}

.modal-btn-danger {
  background: #dc2626;
  color: white;
}

.modal-btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

/* ========================================
   SPLIT LAYOUT (Signup with Product Mosaic)
   ======================================== */

/* Override base auth-page styles for split layout */
.auth-page.auth-page-split {
  display: flex;
  flex-direction: row;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Prevent body scroll on split layout pages */
body:has(.auth-page-split) {
  overflow: hidden;
}

.auth-page-form {
  width: 50%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 40px;
  box-sizing: border-box;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.auth-page-form::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.auth-page-form .auth-container {
  width: 100%;
  max-width: 470px;
}

.auth-page-mosaic {
  width: 50%;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: var(--white);
}

/* Mosaic Wrapper - applies rotation */
.mosaic-wrapper {
  position: absolute;
  top: -50%;
  left: -30%;
  width: 160%;
  height: 200%;
  transform: rotate(-15deg);
  overflow: hidden;
}

/* Mosaic Track - contains all tiles, animated */
.mosaic-track {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2px;
  padding: 0;
  will-change: transform;
  -webkit-animation: mosaic-scroll 120s linear infinite;
  animation: mosaic-scroll 120s linear infinite;
}

/* Individual Tile */
.mosaic-tile {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--grey-02);
}

.mosaic-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background-color: white;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
}

.mosaic-tile.loaded img {
  opacity: 1;
}

/* Heart Icon Overlay */
.mosaic-heart {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e53935;
}

.mosaic-heart svg {
  width: 20px;
  height: 20px;
  fill: #e53935;
  stroke: #e53935;
}

/* Infinite Scroll Animation */
@-webkit-keyframes mosaic-scroll {
  0% {
    -webkit-transform: translateY(0);
    transform: translateY(0);
  }
  100% {
    -webkit-transform: translateY(-25%);
    transform: translateY(-25%);
  }
}

@keyframes mosaic-scroll {
  0% {
    -webkit-transform: translateY(0);
    transform: translateY(0);
  }
  100% {
    -webkit-transform: translateY(-25%);
    transform: translateY(-25%);
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .auth-page {
    padding: 24px 16px;
    display: inline-block;
    flex: none;
  }

  .auth-title {
    font-size: 3rem;
    line-height: 3.8rem;
  }

  .auth-container {
    max-width: 100%;
  }

  /* Prevent iOS/Android zoom on input focus - must be at least 16px */
  .auth-input {
    font-size: 16px;
  }

  /* Hide mosaic on mobile, form takes full width */
  .auth-page-split {
    flex-direction: column;
  }

  .auth-page-form {
    width: 100%;
    padding: 24px 16px;
  }

  .auth-page-mosaic {
    display: none;
  }
}

/* ========================================
   FOLLOWED BRANDS SECTION
   ======================================== */

.followed-brands-container {
  margin-top: 16px;
}

.followed-brands-loading {
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-family: var(--ff-sans);
  font-size: var(--fs-body);
}

.followed-brands-list {
  max-height: 310px;
  overflow-y: auto;
  display: none;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.followed-brands-list::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.followed-brands-empty {
  display: none;
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-family: var(--ff-sans);
  font-size: var(--fs-body);
  margin: 0;
}

.followed-brand-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--grey-04);
}

.followed-brand-item:last-child {
  border-bottom: none;
}

.followed-brand-link {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: inherit;
  flex: 1;
  min-width: 0;
}

.followed-brand-link:hover .followed-brand-name {
  text-decoration: underline;
}

.followed-brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--grey-03);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ff-sans-medium);
  font-size: var(--fs-body-lg);
  color: var(--text-secondary);
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--grey-07);
}

.followed-brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.followed-brand-name {
  font-family: var(--ff-sans-medium);
  font-size: var(--fs-body);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.followed-brand-btn {
  font-family: var(--ff-sans-medium);
  font-size: var(--fs-body-sm);
  line-height: 1;
  padding: 8px 12px;
  background-color: transparent;
  color: var(--text);
  border: 1px solid var(--black);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.followed-brand-btn:hover {
  background-color: var(--grey-03);
}

.followed-brand-btn.following {
  background-color: var(--black);
  color: var(--white);
}

.followed-brand-btn.following:hover {
  background-color: var(--grey-15);
}

.followed-brand-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
