/* ==========================================================================
   DGBay Auth UI — M3 Flow Theme
   Material Design 3 Login & Registration Forms
   ========================================================================== */

/* ── Page-level layout: Center the auth card ────────────────────────────── */
.woocommerce-account:not(.logged-in) .site-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px);
  padding: 24px 16px;
}

.woocommerce-account:not(.logged-in) .m3-container {
  max-width: 100%;
  padding: 0;
}

/* Hide page title on auth page */
.woocommerce-account:not(.logged-in) .entry-title,
.woocommerce-account:not(.logged-in) .page-title,
.woocommerce-account:not(.logged-in) .woocommerce-breadcrumb {
  display: none;
}

/* ── Skip Link (a11y) ───────────────────────────────────────────────────── */
.dgbay-auth-skip {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  padding: 8px 16px;
  border-radius: var(--md-sys-shape-corner-small);
  font-weight: 600;
  z-index: 9999;
  text-decoration: none;
  font-size: 14px;
  transition: top var(--md-sys-motion-fast);
}
.dgbay-auth-skip:focus { top: 16px; }

.dgbay-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Auth Wrapper ───────────────────────────────────────────────────────── */
.dgbay-auth-wrap {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
}

.dgbay-auth-card {
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: var(--md-sys-elevation-3);
  overflow: hidden;
  border: 1px solid var(--md-sys-color-outline-variant);
}

/* ── Form Panel ─────────────────────────────────────────────────────────── */
.dgbay-auth-form-panel {
  padding: 40px 36px;
}

@media (max-width: 480px) {
  .dgbay-auth-form-panel {
    padding: 28px 20px;
  }
}

/* ── Logo ───────────────────────────────────────────────────────────────── */
.dgbay-auth-logo-wrap {
  text-align: center;
  margin-bottom: 28px;
}

.dgbay-auth-logo-link {
  display: inline-block;
  text-decoration: none;
}

.dgbay-auth-logo-img {
  max-height: 44px;
  width: auto;
  margin: 0 auto;
}

/* Logo dark/light switching */
.dgbay-auth-logo-dark { display: none; }
.dgbay-auth-logo-light { display: block; }

html[data-theme="dark"] .dgbay-auth-logo-dark { display: block; }
html[data-theme="dark"] .dgbay-auth-logo-light { display: none; }

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .dgbay-auth-logo-dark { display: block; }
  html:not([data-theme="light"]) .dgbay-auth-logo-light { display: none; }
}

/* ── Form Header ────────────────────────────────────────────────────────── */
.dgbay-auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.dgbay-auth-header h1 {
  font-family: var(--md-sys-typescale-display-font);
  font-size: 26px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  line-height: 1.2;
}

.dgbay-auth-header p {
  font-size: 15px;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.5;
  margin: 0;
}

/* ── WooCommerce Notices ─────────────────────────────────────────────────── */
.dgbay-auth-form-panel .woocommerce-notices-wrapper .woocommerce-error,
.dgbay-auth-form-panel .woocommerce-notices-wrapper .woocommerce-message,
.dgbay-auth-form-panel .woocommerce-notices-wrapper .woocommerce-info {
  border-radius: var(--md-sys-shape-corner-medium);
  margin-bottom: 16px;
  font-size: 14px;
  padding: 12px 16px;
  list-style: none;
}

.dgbay-auth-form-panel .woocommerce-notices-wrapper .woocommerce-error {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  border: 1px solid rgba(186,26,26,0.2);
}

.dgbay-auth-form-panel .woocommerce-notices-wrapper .woocommerce-error li {
  list-style: none;
}

/* ── Tab Switcher ───────────────────────────────────────────────────────── */
.dgbay-auth-tabs {
  display: flex;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-full);
  padding: 4px;
  margin-bottom: 24px;
}

.dgbay-auth-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  border-radius: var(--md-sys-shape-corner-full);
  font-family: var(--md-sys-typescale-body-font);
  font-size: 14px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: color var(--md-sys-motion-fast), background-color var(--md-sys-motion-normal);
  line-height: 1;
  white-space: nowrap;
}

.dgbay-auth-tab-btn.is-active,
.dgbay-auth-tab-btn[aria-selected="true"] {
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-1);
  font-weight: 600;
}

.dgbay-auth-tab-btn:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.dgbay-auth-tab-btn svg {
  flex-shrink: 0;
}

/* ── Google OAuth Button ────────────────────────────────────────────────── */
.dgbay-auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
}

.dgbay-auth-divider::before,
.dgbay-auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--md-sys-color-outline-variant);
}

.dgbay-auth-divider span {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.dgbay-auth-google-wrap {
  text-align: center;
}

/* Style the Google Site Kit button wrapper */
.dgbay-auth-google-wrap .g_id_signin,
.dgbay-auth-google-wrap iframe {
  margin: 0 auto;
}

/* ── Form Panels ────────────────────────────────────────────────────────── */
.dgbay-auth-panel {
  display: none;
}

.dgbay-auth-panel.is-active {
  display: block;
  animation: dgbayAuthFadeIn var(--md-sys-motion-normal) both;
}

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

/* ── Form Fields ────────────────────────────────────────────────────────── */
.dgbay-auth-field {
  margin-bottom: 16px;
}

.dgbay-auth-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 6px;
  transition: color var(--md-sys-motion-fast);
  letter-spacing: 0.01em;
}

.dgbay-auth-field:focus-within label {
  color: var(--md-sys-color-primary);
}

.dgbay-auth-required {
  color: var(--md-sys-color-error);
  margin-left: 2px;
}

.dgbay-auth-field input[type="text"],
.dgbay-auth-field input[type="email"],
.dgbay-auth-field input[type="password"] {
  display: block;
  width: 100%;
  padding: 13px 16px;
  background: var(--md-sys-color-surface-container-lowest);
  border: 1.5px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-medium);
  font-family: var(--md-sys-typescale-body-font);
  font-size: 15px;
  color: var(--md-sys-color-on-surface);
  transition: border-color var(--md-sys-motion-fast), box-shadow var(--md-sys-motion-fast), background-color var(--md-sys-motion-fast);
  outline: none;
  line-height: 1.4;
}

.dgbay-auth-field input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.6;
}

.dgbay-auth-field input:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px rgba(7,135,234,0.15);
  background: var(--md-sys-color-surface-container-lowest);
}

html[data-theme="dark"] .dgbay-auth-field input:focus {
  box-shadow: 0 0 0 3px rgba(125,195,255,0.18);
}

.dgbay-auth-field input:hover:not(:focus) {
  border-color: var(--md-sys-color-on-surface-variant);
}

.dgbay-auth-field input[aria-invalid="true"] {
  border-color: var(--md-sys-color-error);
}

.dgbay-auth-field input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(186,26,26,0.15);
}

/* ── Password Wrapper ───────────────────────────────────────────────────── */
.dgbay-auth-password-wrap {
  position: relative;
}

.dgbay-auth-password-wrap input {
  padding-right: 48px;
}

.dgbay-auth-toggle-pwd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--md-sys-color-on-surface-variant);
  border-radius: var(--md-sys-shape-corner-small);
  transition: color var(--md-sys-motion-fast), background-color var(--md-sys-motion-fast);
}

.dgbay-auth-toggle-pwd:hover {
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface-container-high);
}

.dgbay-auth-toggle-pwd:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* ── Field Error ────────────────────────────────────────────────────────── */
.dgbay-auth-field-error {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--md-sys-color-error);
  font-weight: 500;
  min-height: 0;
}

.dgbay-auth-field-error:empty {
  display: none;
}

/* ── Field Hint ─────────────────────────────────────────────────────────── */
.dgbay-auth-field-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.4;
}

/* ── Password Strength Meter ────────────────────────────────────────────── */
.dgbay-auth-strength {
  margin-top: 10px;
}

.dgbay-auth-strength-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.dgbay-auth-strength-seg {
  flex: 1;
  height: 3px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-outline-variant);
  transition: background-color var(--md-sys-motion-normal);
}

.dgbay-auth-strength-seg.active-weak   { background: var(--md-sys-color-error); }
.dgbay-auth-strength-seg.active-fair   { background: var(--md-sys-color-warning); }
.dgbay-auth-strength-seg.active-good   { background: #fbbc04; }
.dgbay-auth-strength-seg.active-strong { background: var(--md-sys-color-success); }

.dgbay-auth-strength-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
}

/* ── Remember Me / Inline Row ───────────────────────────────────────────── */
.dgbay-auth-row-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.dgbay-auth-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

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

.dgbay-auth-checkbox span {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  user-select: none;
}

.dgbay-auth-link-forgot {
  font-size: 14px;
  font-weight: 500;
  color: var(--md-sys-color-primary);
  text-decoration: none;
  transition: color var(--md-sys-motion-fast);
}

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

.dgbay-auth-link-forgot:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Primary Submit Button ──────────────────────────────────────────────── */
.dgbay-auth-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 24px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  font-family: var(--md-sys-typescale-body-font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--md-sys-motion-fast), box-shadow var(--md-sys-motion-fast), transform var(--md-sys-motion-fast);
  position: relative;
  overflow: hidden;
  letter-spacing: 0.02em;
}

.dgbay-auth-btn-primary:hover {
  box-shadow: 0 1px 2px rgba(7,135,234,.3), 0 2px 6px 2px rgba(7,135,234,.15);
}

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

.dgbay-auth-btn-primary:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 3px;
}

/* Loading state */
.dgbay-auth-btn-primary.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

.auth-btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: dgbayAuthSpin 0.7s linear infinite;
}

.is-loading .auth-btn-spinner { display: block; }
.is-loading .auth-btn-text { display: none; }

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

/* ── Terms Notice ───────────────────────────────────────────────────────── */
.dgbay-auth-terms {
  margin-top: 16px;
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
  line-height: 1.5;
}

.dgbay-auth-terms a {
  color: var(--md-sys-color-primary);
  text-decoration: none;
  font-weight: 500;
}

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

/* ── WooCommerce Overrides ──────────────────────────────────────────────── */
/* Remove default WC form styles inside our auth forms */
.dgbay-auth-wrap .woocommerce-form-login,
.dgbay-auth-wrap .woocommerce-form-register {
  border: none;
  padding: 0;
  margin: 0;
  background: none;
  box-shadow: none;
}

.dgbay-auth-wrap .woocommerce-form-row {
  padding: 0;
  margin: 0;
}

/* Override WC's default button styling */
.dgbay-auth-wrap .woocommerce-Button.button {
  background: var(--md-sys-color-primary) !important;
  color: var(--md-sys-color-on-primary) !important;
  border: none !important;
  border-radius: var(--md-sys-shape-corner-full) !important;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Remove the default u2 column layout WooCommerce uses */
.dgbay-auth-wrap #customer_login .u-columns,
.dgbay-auth-wrap #customer_login .col-1,
.dgbay-auth-wrap #customer_login .col-2 {
  width: 100%;
  float: none;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .dgbay-auth-wrap {
    max-width: 100%;
  }

  .dgbay-auth-card {
    border-radius: var(--md-sys-shape-corner-large);
  }

  .dgbay-auth-header h1 {
    font-size: 22px;
  }
}

@media (max-width: 360px) {
  .dgbay-auth-form-panel {
    padding: 24px 16px;
  }
}
