/* Auth Modal Styles */

/* Modal Overlay */
.auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000000; /* Higher than report-overlay (1000000) */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-modal.active,
.auth-modal.open {
  display: flex;
}

.auth-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

/* Modal Container */
.auth-modal-container {
  position: relative;
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: modalSlideIn 0.3s ease;
  display: flex;
  flex-direction: row;
}

/* Wide modal with side panel */
.auth-modal-container.auth-modal-wide {
  max-width: 960px;
}

/* Main content area */
.auth-modal-main {
  flex: 1;
  padding: 32px;
  min-width: 0;
  overflow-y: auto;
  max-height: 90vh;
}

/* Side Panel */
.auth-modal-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 320px;
  background: linear-gradient(135deg, var(--primary) 0%, #2a4aa0 100%);
  border-radius: 0 16px 16px 0;
  padding: 40px 32px;
  flex-shrink: 0;
}

/* Side panel logo */
.auth-side-logo {
  margin-bottom: 32px;
}

.auth-side-logo img {
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

.auth-side-content {
  color: #fff;
}

.auth-side-content h3 {
  margin: 0 0 24px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.auth-side-features {
  list-style: none;
  margin: 0 0 32px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-side-features li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  line-height: 1.4;
}

.auth-side-features li svg {
  flex-shrink: 0;
  color: #7dd3fc;
  margin-top: 1px;
}

.auth-side-testimonial {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  margin-top: auto;
}

.auth-side-testimonial p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.5;
  font-style: italic;
  opacity: 0.95;
}

.auth-side-author {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.auth-side-author strong {
  font-size: 14px;
  font-weight: 600;
}

.auth-side-author span {
  font-size: 12px;
  opacity: 0.8;
}

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

/* Close Button */
.auth-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #666;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.auth-modal-close:hover {
  background: #f5f5f5;
  color: #333;
}

/* Close button on wide modal (over side panel) */
.auth-modal-wide .auth-modal-close {
  color: rgba(255, 255, 255, 0.8);
}

.auth-modal-wide .auth-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Logo */
.auth-modal-logo {
  text-align: center;
  margin-bottom: 20px;
}

.auth-modal-logo img {
  height: auto;
  width: 140px;
  max-width: 100%;
}

/* Progress Indicator */
.auth-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  margin-top: 4px;
}

.auth-progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.auth-progress-step span {
  font-size: 11px;
  color: #999;
  font-weight: 500;
}

.auth-progress-step.active span,
.auth-progress-step.completed span {
  color: var(--primary);
}

.auth-progress-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e8e8e8;
  color: #999;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.auth-progress-step.active .auth-progress-dot {
  background: var(--primary);
  color: #fff;
}

.auth-progress-step.completed .auth-progress-dot {
  background: #22c55e;
  color: #fff;
}

.auth-progress-line {
  width: 30px;
  height: 2px;
  background: #e8e8e8;
  margin-bottom: 18px;
}

.auth-progress-line.completed {
  background: #22c55e;
}

/* Tabs */
.auth-tabs {
  display: flex;
  background: #f5f5f5;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.auth-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.auth-tab:hover:not(.active) {
  color: #333;
}

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

.auth-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
  text-align: center;
}

.auth-subtitle {
  margin: -8px 0 8px;
  font-size: 14px;
  color: #666;
  text-align: center;
}

/* Form Fields */
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

.auth-field label .optional {
  font-weight: 400;
  color: #999;
}

.auth-field input,
.auth-field select {
  padding: 12px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  font-size: 14px;
  color: #333;
  transition: all 0.2s ease;
  background: #fff;
}

.auth-field input:focus,
.auth-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(68, 117, 230, 0.1);
}

.auth-field input::placeholder {
  color: #aaa;
}

.auth-field-hint {
  font-size: 12px;
  color: #888;
}

/* Two Column Row */
.auth-field-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Checkbox & Link Row */
.auth-field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.auth-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: #555;
}

.auth-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.auth-checkbox span {
  line-height: 1.4;
}

.demo-checkbox {
  margin-top: 8px;
  padding: 12px;
  background: #f8f9ff;
  border-radius: 10px;
  border: 1px solid #e8ecff;
}

.auth-link {
  font-size: 13px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-link:hover {
  text-decoration: underline;
}

/* Buttons */
.auth-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: linear-gradient(135deg, var(--primary) 0%, #3461d1 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(68, 117, 230, 0.3);
}

/* Loading spinner for buttons */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.auth-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(68, 117, 230, 0.4);
}

.auth-btn-primary:active {
  transform: translateY(0);
}

.auth-btn-secondary {
  padding: 14px 24px;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fff;
  color: #555;
}

.auth-btn-secondary:hover {
  border-color: #ccc;
  background: #f9f9f9;
}

.auth-buttons-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  margin-top: 8px;
}

.auth-buttons-row-equal {
  grid-template-columns: 1fr 1fr;
}

/* Google Button */
.auth-btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 24px;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fff;
  color: #333;
}

.auth-btn-google:hover {
  background: #f9f9f9;
  border-color: #ccc;
}

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

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e8e8e8;
}

.auth-divider span {
  font-size: 12px;
  color: #999;
  white-space: nowrap;
}

/* Radio Group */
.auth-radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.auth-radio {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid #e8e8e8;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-radio:hover {
  border-color: #ccc;
  background: #fafafa;
}

.auth-radio input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.auth-radio-label {
  font-size: 14px;
  color: #333;
}

.auth-radio:has(input:checked) {
  border-color: var(--primary);
  background: #f8f9ff;
}

/* Plan Cards - Horizontal Grid */
.auth-plans {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Horizontal 1x4 grid for wider modal */
.auth-plans-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-height: none;
  overflow-y: visible;
  padding-right: 0;
}

.auth-plan-card {
  position: relative;
  display: block;
  cursor: pointer;
}

.auth-plan-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.auth-plan-content {
  position: relative;
  padding: 16px;
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  transition: all 0.2s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.auth-plan-card:hover .auth-plan-content {
  border-color: #ccc;
}

.auth-plan-card input:checked + .auth-plan-content {
  border-color: var(--primary);
  background: #f0f4ff;
  box-shadow: 0 0 0 3px rgba(68, 117, 230, 0.15);
}

.auth-plan-card input:checked + .auth-plan-content::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 22px;
  height: 22px;
  background: var(--primary);
  border-radius: 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px;
}

.auth-plan-card.popular .auth-plan-content {
  border-color: #c7d2fe;
  background: linear-gradient(135deg, #fafbff 0%, #f5f7ff 100%);
}

.auth-plan-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
  z-index: 2;
}

.auth-plan-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.auth-plans-grid .auth-plan-header {
  flex-direction: column;
  align-items: flex-start;
}

.auth-plan-name {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a1a;
}

.auth-plan-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.auth-plan-price span {
  font-size: 13px;
  font-weight: 500;
  color: #888;
}

.auth-plan-desc {
  margin: 0 0 10px;
  font-size: 13px;
  color: #666;
  line-height: 1.4;
  flex-grow: 1;
}

.auth-plan-features {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-plan-features li {
  font-size: 12px;
  color: #555;
  padding-left: 20px;
  position: relative;
}

.auth-plan-features li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  width: 12px;
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2322c55e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* Terms */
.auth-terms {
  margin: 16px 0 0;
  font-size: 12px;
  color: #888;
  text-align: center;
  line-height: 1.5;
}

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

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

/* Password Requirements Tooltip */
.auth-field-password {
  position: relative;
}

.auth-password-requirements {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 8px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  z-index: 100;
}

.auth-password-requirements.visible {
  display: block;
  animation: fadeInUp 0.2s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-password-requirements::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 20px;
  width: 10px;
  height: 10px;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  border-top: 1px solid #e0e0e0;
  transform: rotate(45deg);
}

.auth-password-requirements-title {
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 10px;
}

.auth-password-requirements ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-password-requirements li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #666;
  transition: color 0.2s ease;
}

.auth-password-requirements li .icon-check {
  display: none;
  color: #22c55e;
}

.auth-password-requirements li .icon-x {
  display: block;
  color: #dc2626;
}

.auth-password-requirements li.valid {
  color: #22c55e;
}

.auth-password-requirements li.valid .icon-check {
  display: block;
}

.auth-password-requirements li.valid .icon-x {
  display: none;
}

/* Responsive */
@media screen and (max-width: 1024px) {
  .auth-modal-container.auth-modal-wide {
    max-width: 640px;
  }

  .auth-modal-side {
    display: none !important;
  }

  .auth-plans-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media screen and (max-width: 680px) {
  .auth-modal-container.auth-modal-wide {
    max-width: 100%;
  }

  .auth-plans-grid {
    grid-template-columns: 1fr;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
  }

  .auth-plans-grid .auth-plan-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }
}

@media screen and (max-width: 480px) {
  .auth-modal {
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .auth-modal-container {
    padding: 0;
    max-width: 100%;
    border-radius: 12px;
    max-height: calc(100vh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .auth-modal-main {
    padding: 24px 20px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .auth-modal-close {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
  }

  .auth-title {
    font-size: 20px;
  }

  .auth-subtitle {
    font-size: 13px;
  }

  .auth-field-row-2col {
    grid-template-columns: 1fr;
  }

  .auth-progress-step span {
    display: none;
  }

  .auth-progress-line {
    margin-bottom: 0;
  }

  .auth-buttons-row {
    grid-template-columns: 1fr 1fr;
  }

  .auth-plans {
    max-height: 280px;
  }

  .auth-plan-content {
    padding: 14px;
  }

  .auth-tab {
    padding: 10px 14px;
    font-size: 13px;
  }

  .auth-field input,
  .auth-field select {
    padding: 14px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  .auth-btn-primary,
  .auth-btn-secondary {
    padding: 14px 20px;
    font-size: 15px;
  }

  .auth-btn-google {
    padding: 12px 16px;
    font-size: 14px;
  }

  .auth-checkbox {
    font-size: 12px;
  }

  .auth-terms {
    font-size: 11px;
  }
}

/* Very small phones */
@media screen and (max-width: 360px) {
  .auth-modal {
    padding: 8px;
  }

  .auth-modal-main {
    padding: 20px 16px;
  }

  .auth-title {
    font-size: 18px;
  }

  .auth-tabs {
    margin-bottom: 20px;
  }

  .auth-tab {
    padding: 8px 10px;
    font-size: 12px;
  }

  .auth-plan-name {
    font-size: 14px;
  }

  .auth-plan-price {
    font-size: 18px;
  }

  .auth-plan-desc {
    font-size: 12px;
  }

  .auth-plan-features li {
    font-size: 11px;
  }

  .auth-billing-toggle-container {
    gap: 8px;
  }

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

  .auth-save-badge {
    font-size: 10px;
    padding: 3px 6px;
  }
}

/* Billing Toggle Styles */
.auth-billing-toggle-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.auth-billing-label {
  font-size: 14px;
  color: #666;
  cursor: pointer;
  transition: color 0.2s ease;
}

.auth-billing-label.active {
  color: #1a1a1a;
  font-weight: 600;
}

.auth-billing-switch {
  position: relative;
  width: 48px;
  height: 26px;
  background: #e2e8f0;
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.auth-billing-switch.active {
  background: #22c55e;
}

.auth-billing-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.auth-billing-switch.active::after {
  transform: translateX(22px);
}

.auth-save-badge {
  background: #22c55e;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 12px;
}


/* Forgot Password Form */
#forgot-password-form .auth-title,
#reset-password-form .auth-title {
  margin-bottom: 4px;
}

#forgot-password-form .auth-subtitle,
#reset-password-form .auth-subtitle {
  margin: 0 0 16px;
}

#forgot-password-form .auth-btn-primary,
#reset-password-form .auth-btn-primary {
  width: 100%;
  margin-top: 8px;
}

.auth-back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: #6b7280;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  margin-bottom: 16px;
  transition: color 0.2s ease;
}

.auth-back-btn:hover {
  color: #1a1a1a;
}

.auth-back-btn i {
  font-size: 12px;
}

.auth-success-message {
  text-align: center;
  padding: 24px 0;
}

.auth-success-message i {
  font-size: 48px;
  color: #22c55e;
  margin-bottom: 16px;
}

.auth-success-message p {
  color: #4b5563;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}

#forgot-password-form .auth-btn-secondary,
#reset-password-form .auth-btn-secondary {
  width: 100%;
}

.auth-btn-secondary {
  background: #f3f4f6;
  color: #1a1a1a;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}

.auth-btn-secondary:hover {
  background: #e5e7eb;
}
