/* Login Dropdown Styles - Based on Search Dropdown Pattern */

.divinho-login-container {
  position: relative;
}

.divinho-login-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--divinho-space-2, 0.5rem);
  padding: var(--divinho-space-3, 0.75rem) var(--divinho-space-4, 1rem);
  background: transparent;
  border: none;
  color: currentColor;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1)),
              background-color var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  border-radius: var(--divinho-radius, 0.5rem);
  text-decoration: none;
}

.divinho-login-trigger:hover {
  color: var(--divinho-wine-primary, #722f37);
  background-color: rgba(114, 47, 55, 0.05);
}

.divinho-login-trigger:focus {
  outline: 2px solid var(--divinho-wine-primary, #722f37);
  outline-offset: 2px;
}

.divinho-login-trigger svg {
  flex-shrink: 0;
}

.divinho-login-dropdown {
  position: absolute;
  top: calc(100% + var(--divinho-space-2, 0.5rem));
  right: 0;
  z-index: var(--divinho-z-dropdown, 1000);
  background: var(--divinho-white, #ffffff);
  border: 1px solid var(--divinho-gray-200, #e5e7eb);
  border-radius: var(--divinho-radius-lg, 1rem);
  box-shadow: var(--divinho-shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04));
  min-width: 320px;
  max-width: 400px;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.5rem) scale(0.95);
  transition: opacity var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1)),
              visibility var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1)),
              transform var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1));
}

.divinho-login-dropdown:not([hidden]) {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.divinho-login-content {
  padding: 0;
}

.divinho-login-header {
  position: relative;
  text-align: center;
  padding: var(--divinho-space-8, 2rem) var(--divinho-space-6, 1.5rem) var(--divinho-space-6, 1.5rem);
  background: linear-gradient(135deg, var(--divinho-wine-primary, #722f37) 0%, #8b3d47 100%);
  color: var(--divinho-white, #ffffff);
}

.divinho-wine-icon {
  margin: 0 auto var(--divinho-space-3, 0.75rem);
  width: 32px;
  height: 32px;
  color: var(--divinho-wine-accent, #a0616a);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.divinho-login-title {
  font-family: var(--divinho-font-serif, Georgia, serif);
  font-size: var(--divinho-space-6, 1.5rem);
  font-weight: 700;
  margin: 0 0 var(--divinho-space-2, 0.5rem);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.divinho-login-subtitle {
  font-size: 0.875rem;
  margin: 0;
  opacity: 0.9;
}

.divinho-login-close {
  position: absolute;
  top: var(--divinho-space-3, 0.75rem);
  right: var(--divinho-space-3, 0.75rem);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: var(--divinho-radius, 0.5rem);
  color: var(--divinho-white, #ffffff);
  cursor: pointer;
  transition: background-color var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1)),
              transform var(--divinho-transition-fast, 150ms cubic-bezier(0.4, 0, 0.2, 1));
}

.divinho-login-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.divinho-login-close:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.divinho-login-form {
  padding: var(--divinho-space-6, 1.5rem);
}

.divinho-form-group {
  margin-bottom: var(--divinho-space-5, 1.25rem);
}

.divinho-form-label {
  display: block;
  font-weight: 600;
  color: var(--divinho-gray-900, #111827);
  margin-bottom: var(--divinho-space-2, 0.5rem);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.divinho-form-label .required {
  color: var(--divinho-wine-primary, #722f37);
  margin-left: 4px;
}

.divinho-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.divinho-input-icon {
  position: absolute;
  left: var(--divinho-space-4, 1rem);
  color: var(--divinho-gray-400, #9ca3af);
  z-index: 2;
  pointer-events: none;
}

.divinho-form-input {
  width: 100%;
  padding: var(--divinho-space-3, 0.75rem) var(--divinho-space-4, 1rem) var(--divinho-space-3, 0.75rem) calc(var(--divinho-space-10, 2.5rem) + 8px);
  border: 2px solid var(--divinho-gray-200, #e5e7eb);
  border-radius: var(--divinho-radius, 0.5rem);
  font-size: 1rem;
  background: var(--divinho-white, #ffffff);
  transition: border-color var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1)),
              box-shadow var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  appearance: none;
}

.divinho-form-input:focus {
  outline: none;
  border-color: var(--divinho-wine-primary, #722f37);
  box-shadow: 0 0 0 3px rgba(114, 47, 55, 0.1);
  background: var(--divinho-white, #ffffff);
}

.divinho-form-input::placeholder {
  color: var(--divinho-gray-400, #9ca3af);
  opacity: 0.7;
}

.divinho-form-row {
  margin-bottom: var(--divinho-space-4, 1rem);
}

.divinho-checkbox-wrapper {
  display: flex;
  align-items: flex-start;
  gap: var(--divinho-space-2, 0.5rem);
  cursor: pointer;
  font-size: 0.875rem;
}

.divinho-checkbox {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--divinho-gray-300, #d1d5db);
  border-radius: var(--divinho-radius-sm, 0.375rem);
  background: var(--divinho-white, #ffffff);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  margin: 0;
  margin-top: 0.125rem;
  transition: background-color var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1)),
              border-color var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1));
}

.divinho-checkbox:checked {
  background: var(--divinho-wine-primary, #722f37);
  border-color: var(--divinho-wine-primary, #722f37);
}

.divinho-checkbox-checkmark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  opacity: 0;
  transition: opacity var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1));
}

.divinho-checkbox:checked + .divinho-checkbox-checkmark {
  opacity: 1;
}

.divinho-checkbox-checkmark::before {
  content: '✓';
  color: var(--divinho-white, #ffffff);
  font-weight: 700;
  font-size: 12px;
}

.divinho-checkbox-label {
  color: var(--divinho-gray-700, #374151);
}

/* Make terms agreement text smaller */
input[name="terms_agreement"] ~ .divinho-checkbox-label {
  font-size: var(--divinho-font-xs, 0.75rem);
  line-height: 1.5;
}

/* Make newsletter consent text smaller */
input[name="newsletter_consent"] ~ .divinho-checkbox-label {
  font-size: var(--divinho-font-xs, 0.75rem);
  line-height: 1.5;
}

/* Improve link spacing and appearance within checkbox labels */
.divinho-checkbox-label .divinho-link {
  display: inline;
  margin: 0 0.125rem;
  padding: 0.125rem 0;
  line-height: inherit;
}

.divinho-checkbox-label .divinho-link:first-of-type {
  margin-left: 0.25rem;
}

.divinho-checkbox-label .divinho-link:last-of-type {
  margin-right: 0.25rem;
}

/* External link icons in checkbox labels */
.divinho-checkbox-label .external-link-icon {
  display: inline-block;
  vertical-align: baseline;
  margin-left: 0.125rem;
  opacity: 0.7;
}

.divinho-form-actions {
  margin-top: var(--divinho-space-6, 1.5rem);
}

.divinho-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--divinho-space-2, 0.5rem);
  width: 100%;
  padding: var(--divinho-space-3, 0.75rem) var(--divinho-space-6, 1.5rem);
  border: none;
  border-radius: var(--divinho-radius, 0.5rem);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1)),
              transform var(--divinho-transition-fast, 150ms cubic-bezier(0.4, 0, 0.2, 1)),
              box-shadow var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  position: relative;
  overflow: hidden;
}

.divinho-button-primary {
  background: linear-gradient(135deg, var(--divinho-wine-primary, #722f37) 0%, #8b3d47 100%);
  color: var(--divinho-white, #ffffff);
  box-shadow: 0 4px 12px rgba(114, 47, 55, 0.3);
}

.divinho-button-primary:hover {
  background: linear-gradient(135deg, #8b3d47 0%, var(--divinho-wine-primary, #722f37) 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(114, 47, 55, 0.4);
}

.divinho-button-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(114, 47, 55, 0.3);
}

.divinho-button-primary:focus {
  outline: 2px solid var(--divinho-wine-primary, #722f37);
  outline-offset: 2px;
}

.divinho-login-links {
  margin-top: var(--divinho-space-4, 1rem);
  padding-top: var(--divinho-space-4, 1rem);
  border-top: 1px solid var(--divinho-gray-100, #f3f4f6);
  text-align: center;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--divinho-space-2, 0.5rem);
  flex-wrap: wrap;
}

.divinho-link {
  color: var(--divinho-wine-primary, #722f37);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--divinho-transition, 200ms cubic-bezier(0.4, 0, 0.2, 1));
}

.divinho-link:hover {
  color: var(--divinho-wine-accent, #a0616a);
  text-decoration: underline;
}

.divinho-link-separator {
  color: var(--divinho-gray-300, #d1d5db);
}

/* Responsive styles */
@media (max-width: 768px) {
  .divinho-login-dropdown {
    left: 0;
    right: 0;
    max-width: none;
    margin: 0 var(--divinho-space-2, 0.5rem);
  }

  .divinho-login-header {
    padding: var(--divinho-space-6, 1.5rem) var(--divinho-space-4, 1rem) var(--divinho-space-4, 1rem);
  }

  .divinho-login-title {
    font-size: var(--divinho-space-5, 1.25rem);
  }

  .divinho-login-form {
    padding: var(--divinho-space-4, 1rem);
  }
  
  .divinho-login-links {
    flex-wrap: wrap;
  }
}

/* Mobile-First Full-Screen Modal Design (<480px) */
@media (max-width: 480px) {
  .divinho-login-container {
    position: static;
  }
  
  /* Full-screen modal with proper overlay */
  .divinho-login-dropdown {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    border-radius: 0;
    max-height: 100vh;
    min-width: unset;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--divinho-white, #ffffff);
    z-index: 999999; /* Very high to ensure above all page content */
  }

  .divinho-login-dropdown:not([hidden]) {
    transform: translateY(0);
  }

  /* Sticky header that stays at top */
  .divinho-login-header {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
    padding: var(--divinho-space-4, 1rem);
    background: linear-gradient(135deg, var(--divinho-wine-primary, #722f37) 0%, #8b3d47 100%);
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  .divinho-wine-icon {
    margin: 0 auto var(--divinho-space-2, 0.5rem);
    width: 28px;
    height: 28px;
  }

  .divinho-login-title {
    font-size: 1.25rem;
    margin-bottom: var(--divinho-space-1, 0.25rem);
  }

  .divinho-login-subtitle {
    font-size: 0.8125rem;
  }

  .divinho-login-close {
    position: absolute;
    top: var(--divinho-space-2, 0.5rem);
    right: var(--divinho-space-2, 0.5rem);
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Scrollable content area */
  .divinho-login-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
  }

  /* Form container with padding */
  .divinho-login-form {
    flex: 1;
    padding: var(--divinho-space-5, 1.25rem) var(--divinho-space-4, 1rem);
    display: flex;
    flex-direction: column;
  }

  /* Ensure form groups have proper spacing */
  .divinho-form-group {
    margin-bottom: var(--divinho-space-4, 1rem);
  }

  /* Better touch targets for inputs */
  .divinho-form-input {
    min-height: 48px;
    font-size: 16px; /* Prevents iOS zoom */
    padding: var(--divinho-space-3, 0.75rem) var(--divinho-space-4, 1rem) var(--divinho-space-3, 0.75rem) calc(var(--divinho-space-10, 2.5rem) + 8px);
  }

  /* Better touch targets for buttons */
  .divinho-button {
    min-height: 48px;
    padding: var(--divinho-space-4, 1rem) var(--divinho-space-6, 1.5rem);
    font-size: 1rem;
  }

  /* Better touch targets for checkboxes */
  .divinho-checkbox-wrapper {
    padding: var(--divinho-space-2, 0.5rem) 0;
    gap: var(--divinho-space-3, 0.75rem);
  }

  .divinho-checkbox {
    width: 24px;
    height: 24px;
    min-width: 24px;
  }

  /* Vertical link layout */
  .divinho-login-links {
    flex-direction: column;
    gap: var(--divinho-space-3, 0.75rem);
    align-items: stretch;
    padding-top: var(--divinho-space-4, 1rem);
    margin-top: auto;
  }
  
  .divinho-link {
    text-align: center;
    padding: var(--divinho-space-2, 0.5rem);
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .divinho-link-separator {
    display: none;
  }

  /* Better spacing for form actions */
  .divinho-form-actions {
    margin-top: var(--divinho-space-5, 1.25rem);
    margin-bottom: var(--divinho-space-4, 1rem);
  }

  /* Optimize checkbox labels for mobile */
  .divinho-checkbox-label {
    font-size: 0.875rem;
    line-height: 1.5;
  }

  /* Better field help text */
  .divinho-field-help {
    font-size: 0.8125rem;
    line-height: 1.4;
    margin-top: var(--divinho-space-2, 0.5rem);
  }

  /* Ensure password strength indicator is visible */
  .divinho-password-strength {
    margin-top: var(--divinho-space-2, 0.5rem);
    font-size: 0.8125rem;
  }

  /* Account success view */
  .divinho-account-success {
    padding: var(--divinho-space-6, 1.5rem) var(--divinho-space-4, 1rem);
  }

  .divinho-success-icon {
    width: 64px;
    height: 64px;
    margin-bottom: var(--divinho-space-4, 1rem);
  }

  .divinho-success-title {
    font-size: 1.25rem;
  }

  .divinho-success-message {
    font-size: 0.9375rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .divinho-login-dropdown,
  .divinho-login-trigger,
  .divinho-login-close,
  .divinho-button,
  .divinho-form-input,
  .divinho-checkbox {
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: high) {
  .divinho-login-dropdown {
    border-width: 2px;
  }

  .divinho-form-input {
    border-width: 3px;
  }

  .divinho-button-primary {
    border: 2px solid var(--divinho-gray-900, #111827);
  }
}

/* Print styles */
@media print {
  .divinho-login-dropdown {
    display: none !important;
  }
}

/* Loading state */
.divinho-login-form.loading {
  pointer-events: none;
  opacity: 0.7;
}

.divinho-login-form.loading .divinho-button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: divinho-spin 1s linear infinite;
}

@keyframes divinho-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Focus visible styles */
.divinho-login-trigger:focus-visible,
.divinho-login-close:focus-visible,
.divinho-form-input:focus-visible,
.divinho-checkbox:focus-visible,
.divinho-button:focus-visible,
.divinho-link:focus-visible {
  outline: 2px solid var(--divinho-wine-primary, #722f37);
  outline-offset: 2px;
}

/* View panel switching */
.divinho-view-panel {
  display: none;
}

.divinho-view-panel.active {
  display: block;
}

/* View switcher links styled as buttons */
.divinho-login-links button.divinho-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.divinho-login-links button.divinho-link:hover {
  text-decoration: underline;
}

/* Field help text */
.divinho-field-help {
  font-size: 0.875rem;
  color: var(--divinho-gray-500, #6b7280);
  line-height: 1.4;
}

/* Password validation error state */
.divinho-form-input.error {
  border-color: var(--divinho-error, #ef4444);
}

.divinho-form-input.error:focus {
  border-color: var(--divinho-error, #ef4444);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Password strength indicator */
.divinho-password-strength {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.4;
}

.divinho-password-strength .divinho-strength-text {
  display: block;
}

/* Turnstile CAPTCHA Container */
.divinho-turnstile-container {
  margin: var(--divinho-space-4, 1rem) 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 65px;
  transition: all 0.3s ease;
}

/* Error state for Turnstile */
.divinho-turnstile-container.error {
  padding: var(--divinho-space-3, 0.75rem);
  border: 2px solid #dc3545;
  border-radius: var(--divinho-radius, 0.5rem);
  background-color: rgba(220, 53, 69, 0.05);
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.divinho-turnstile-container .cf-turnstile {
  margin: 0 auto;
}

/* Loading state for Turnstile */
.divinho-turnstile-container:empty::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--divinho-gray-200, #e5e7eb);
  border-top-color: var(--divinho-wine-primary, #722f37);
  border-radius: 50%;
  animation: divinho-spin 0.6s linear infinite;
}

@keyframes divinho-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Account Created Success Notification */
.divinho-account-success {
  display: none;
  padding: var(--divinho-space-8, 2rem) var(--divinho-space-6, 1.5rem);
}

.divinho-account-success.active {
  display: block;
}

.divinho-success-content {
  text-align: center;
}

.divinho-success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  margin: 0 auto var(--divinho-space-6, 1.5rem);
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 50%;
  color: var(--divinho-white, #ffffff);
}

.divinho-success-icon svg {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.divinho-success-title {
  font-family: var(--divinho-font-serif, Georgia, serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--divinho-gray-900, #111827);
  margin: 0 0 var(--divinho-space-4, 1rem);
}

.divinho-success-message {
  font-size: 1rem;
  color: var(--divinho-gray-600, #4b5563);
  line-height: 1.6;
  margin: 0 0 var(--divinho-space-6, 1.5rem);
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
}

.divinho-success-info {
  display: flex;
  align-items: flex-start;
  gap: var(--divinho-space-3, 0.75rem);
  padding: var(--divinho-space-4, 1rem);
  background: var(--divinho-gray-50, #f9fafb);
  border-left: 4px solid var(--divinho-wine-primary, #722f37);
  border-radius: var(--divinho-radius, 0.5rem);
  margin-bottom: var(--divinho-space-6, 1.5rem);
  text-align: left;
}

.divinho-success-info svg {
  flex-shrink: 0;
  color: var(--divinho-wine-primary, #722f37);
  margin-top: 2px;
}

.divinho-success-info span {
  font-size: 0.875rem;
  color: var(--divinho-gray-600, #4b5563);
  line-height: 1.5;
}

.divinho-account-success .divinho-form-actions {
  margin-top: var(--divinho-space-6, 1.5rem);
}

.divinho-account-success .divinho-button {
  display: inline-flex;
  align-items: center;
  gap: var(--divinho-space-2, 0.5rem);
}

