/* ===== Design Tokens ===== */
:root {
  --brand-600: #2c4cff;
  --brand-500: #3f67ff;
  --brand-400: #6f8bff;
  --ink-900: #0b1220;
  --ink-700: #1f2a44;
  --ink-500: #445170;
  --ink-300: #8a95ad;
  --ink-200: #c4ccda;
  --bg-100: #f7f8fb;
  --white: #ffffff;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;

  --shadow-lg: 0 20px 50px rgba(9, 25, 55, 0.25);
  --shadow-md: 0 10px 30px rgba(9, 25, 55, 0.18);
  --focus: 0 0 0 3px rgba(11, 18, 32, 0.15);
}

/* ===== Base ===== */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  background: var(--bg-100);
  color: var(--ink-900);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.4;
}

/* Register page: Add margin under confirm password field */
#register-form .field:has(#reg_password_confirm) {
  margin-bottom: 8px;
}

/* Register page: Add margin under password hint */
#reg-pw-hint {
  margin-bottom: 8px;
}

a {
  color: var(--ink-900);
  text-decoration: underline;
  font-weight: 600;
}
a:hover {
  opacity: 0.8;
}

/* ===== Layout ===== */
.hero {
  position: relative;
  min-height: 100dvh;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 24px;
  padding-top: 125px; /* Push card down to avoid blocking background */
  overflow: hidden;
  contain: layout style paint;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url(assets/TredjeIterationBaggrundsbillede.webp)
    center / contain no-repeat;
  background-position: center -17px;
  will-change: transform;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  /* Overlay removed to show original image */
  pointer-events: none;
}

/* ===== Modal Card ===== */
.card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 430px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  animation: rise 380ms cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}

@keyframes rise {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.card header {
  margin-bottom: 16px;
}

.title {
  margin: 0 0 8px 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--ink-900);
}
.subtitle {
  margin: 0;
  font-size: 15px;
  color: black;
}

.perk {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 18px 0;
  padding: 12px 16px;
  font-size: 15px;
  color: var(--ink-700);
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid var(--ink-200);
  text-align: center;
}
.perk .dot {
  width: 10px;
  height: 10px;
  background: var(--ink-700);
  border-radius: 999px;
}

/* ===== Form ===== */
form {
  display: grid;
  gap: 14px;
}

.field {
  position: relative;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-900);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--ink-200);
  background: var(--white);
  color: var(--ink-900);
  font-size: 16px;
  transition: box-shadow 150ms, background 150ms;
  padding-right: 44px; /* space for reveal button */
}

.input::placeholder {
  color: #b5bbc5;
  transition: color 150ms ease;
}

.input:focus::placeholder {
  color: rgb(99, 99, 99);
}

.input:focus {
  outline: none;
}

.input.invalid {
  border-color: #e5484d;
  background: #fff5f5;
  box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.12);
}

/* Password toggle button: keep neutral, no hover color */
.reveal-btn {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-500);
  border-radius: 6px;
  cursor: pointer;
}

.reveal-btn:hover,
.reveal-btn:focus {
  color: var(--ink-500); /* no color change */
  background: transparent;
  box-shadow: none; /* keep focus ring off if you prefer; or keep your :focus-visible */
}

.reveal-btn:focus-visible {
  /* keep accessibility focus if desired */
  box-shadow: var(--focus);
}

.reveal-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ===== Form Errors & Hints (Fixed Specificity) ===== */
.hint,
#login-form .error,
#register-form .error {
  font-size: 12px;
  margin-top: 6px;
}

.hint {
  color: var(--ink-500);
}

/* Error messages with higher specificity for both forms */
#login-form .error,
#register-form .error {
  display: none;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  color: #be123c;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  animation: slideDown 200ms ease-out;
}

/* Show errors when they have content */
#login-form .error:not(:empty),
#register-form .error:not(:empty) {
  display: flex;
}

/* Error icons for both forms */
#login-form .error::before,
#register-form .error::before {
  content: "";
  display: block;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23be123c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Caps lock warning (specific styling) */
#caps {
  display: none;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #c2410c;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  animation: slideDown 200ms ease-out;
}

#caps:not(:empty) {
  display: flex;
}

#caps::before {
  content: "";
  display: block;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23c2410c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3Cpath d='M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.btn-primary.shake {
  animation: shake 300ms ease-in-out;
}

.field .hint {
  margin-top: 6px;
}

#login-form .field .error + .hint,
#register-form .field .error + .hint {
  margin-top: 8px;
}

/* Focus state improvements for invalid inputs */
.input.invalid:focus {
  border-color: #e5484d;
  box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.18);
  background: #ffffff;
}

/* Smooth transitions */
.input {
  transition: border-color 150ms ease, background 150ms ease,
    box-shadow 150ms ease;
}

/* Remember switch and links row */
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  color: var(--ink-900);
  font-size: 14px;
  font-weight: 600;
}

.switch input {
  appearance: none;
  width: 42px;
  height: 24px;
  background: #d7dcea;
  border-radius: 999px;
  position: relative;
  outline: none;
  transition: background 160ms ease;
}

.switch input:checked {
  background: var(--ink-700);
}

.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(9, 25, 55, 0.2);
  transition: transform 160ms ease;
}
.switch input:checked::after {
  transform: translateX(18px);
}

/* Buttons */
.btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform 80ms ease, box-shadow 150ms ease;
}

.btn-primary {
  width: 100%;
  background: #062348;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 16px;
  box-shadow: none;
  transition: background 120ms ease, opacity 120ms ease;
}

.btn-primary:hover {
  background: #062348;
  opacity: 0.95;
  transform: none;
  box-shadow: none;
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.membership-offer {
  margin-top: 14px;
  text-align: center;
}

.membership-link {
  color: var(--ink-900);
  text-decoration: underline;
  font-weight: 600;
  font-size: 16px;
}
.membership-link:hover {
  opacity: 0.8;
}

/* Mobile tweaks */
@media (max-width: 520px) {
  .hero {
    padding-top: 10px; /* Reduce top padding on mobile to bring card higher */
  }

  .hero::before {
    display: none; /* Remove background image on mobile */
  }

  .card {
    padding: 20px 16px; /* Tighter on mobile */
    margin: 12px; /* Add breathing room */
    max-width: calc(100vw - 24px); /* Prevent overflow */
  }

  .input {
    font-size: 16px; /* Prevent iOS zoom */
    padding: 12px 14px;
  }

  .btn-primary {
    padding: 16px; /* Larger touch target */
    font-size: 17px;
    min-height: 50px; /* Ensure minimum touch target */
  }

  .field-label {
    font-size: 13px; /* Slightly smaller labels */
  }

  .error {
    font-size: 12px;
    padding: 8px 10px;
  }
}

/* iPad portrait mode (820x1180 aspect ratio) */
@media (max-width: 830px) and (min-height: 1100px) and (orientation: portrait) {
  .hero::before {
    background-size: cover;
    background-position: center -17px;
  }
  
  .hero {
    padding-top: 80px;
  }
}

/* FINAL: Hard override for inline style injection */
#login-form .field .input-wrapper {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  overflow: visible !important;
}

#login-form input#password {
  display: block !important;
}

/* Hide perk badge for logged-out users */
body.logged-out .perk {
  display: none !important;
}

/* Forgot password link size */
#forgot-link {
  font-size: 13px;
  line-height: 1.3;
}

.mybasics-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    max-width: 900px; /* Adjust as needed */
    align-items: center;
}
.form-separator {
    display: flex;
    align-items: center;
    color: var(--ink-500);
    font-weight: 600;
}
.login-card, .register-card {
    width: 100%;
    max-width: 430px; /* Keep original card width */
}

@media (min-width: 800px) {
    .mybasics-container {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
    }
    .form-separator {
        writing-mode: vertical-rl;
        text-orientation: mixed;
        height: 100px;
        margin-top: 150px; /* Adjust vertical alignment */
    }
}

/* Form view management */
.auth-forms {
  position: relative;
}
.auth-view.is-hidden {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  height: 0;
  overflow: hidden;
}
.auth-view.is-visible {
  opacity: 1;
  visibility: visible;
}
/* Hide WooCommerce's default inline error messages */
.woocommerce-form-login .woocommerce-error,
.woocommerce-form-login .woocommerce-message,
.woocommerce-form-login .woocommerce-info,
.woocommerce-form-register .woocommerce-error,
.woocommerce-form-register .woocommerce-message,
.woocommerce-form-register .woocommerce-info {
  display: none !important;
}

/* Hide WooCommerce default form row errors */
.woocommerce-form-login .woocommerce-form-row .woocommerce-error,
.woocommerce-form-register .woocommerce-form-row .woocommerce-error {
  display: none !important;
}

/* Hide any default validation messages that appear inline */
.woocommerce-form__input-checkbox + .required,
.woocommerce-form-login .required,
.woocommerce-form-register .required {
  display: inline !important; /* Keep the asterisk visible */
}

/* But hide any inline error text WooCommerce adds */
.woocommerce-form-login .inline,
.woocommerce-form-register .inline {
  display: none !important;
}
#login-form label.error,
#register-form label.error {
  display: none !important;
}
/* Specifically target and hide the unwanted auto-generated div */
.input-wrapper > .error-message {
  display: none !important;
}
.woocommerce-message {
  display: none !important;
}

/* Loading state for buttons */
.btn-primary.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn-primary.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Form Spacing Adjustments ===== */

/* Login page: Add margin above the login button (space from "Husk mig" toggle) */
#login-form .btn-primary {
  margin-top: 20px;
}

/* Login page: More space between field labels and inputs */
#login-form label[for="username"],
#login-form label[for="password"] {
  margin-bottom: 4px;
}

/* Login page: More space between email and password fields */
#login-form .field:has(#password) {
  margin-top: 24px;
}

/* Register page: More space between field labels and inputs */
#register-form label[for="reg_email"],
#register-form label[for="reg_password"],
#register-form label[for="reg_password_confirm"] {
  margin-bottom: 4px;
}

/* Register page: More space between email and password fields */
#register-form .field:has(#reg_password) {
  margin-top: 24px;
}

/* Register page: Add margin above the register button (space from paragraph above) */
#register-form .btn-primary {
  margin-top: 20px;
}

/* Adjust card positioning for login and registration forms */
.auth-forms:has(#login-form.is-visible) .card {
  margin-top: 15px;
}

.auth-forms:has(#register-form.is-visible) .card {
  margin-top: 60px;
}

.membership-pitch-title {
  margin: 0 0 4px 0;
  font-weight: 700;
  font-size: 15px;
  color: rgb(143, 143, 143);
}

.membership-pitch-description {
  margin: 0;
  max-width: 340px; /* Constrain line length for readability */
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

.membership-offer {
  margin-top: 24px; /* Increased top margin for better separation */
  text-align: center;
}

/* mybasics-custom-login.css */

.is-hidden {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none; /* Prevents interaction with hidden elements */
}

.is-visible {
  display: block !important; /* Or flex, depending on your layout */
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto;
}

/* ===== Password Strength: Clean, Fixed Placement ===== */
/* Hide WooCommerce's default moving parts in our custom form */
#register-form .woocommerce-password-strength,
#register-form .woocommerce-password-hint {
  display: none !important;
}

/* Our fixed container under the password field */
#register-form .strength-ui {
  margin-top: 10px;
}

#register-form .strength-bar {
  position: relative;
  width: 100%;
  height: 8px;
  background: #eaedf3; /* subtle track */
  border-radius: 999px;
  overflow: hidden;
}

#register-form .strength-bar-fill {
  height: 100%;
  width: 0%;
  background: #e5484d; /* default weak */
  border-radius: 999px;
  transition: width 180ms ease, background-color 180ms ease;
}

#register-form .strength-label {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-500);
}

/* Map strength levels to width + color */
#register-form .strength-ui[data-strength="0"] .strength-bar-fill {
  width: 20%;
  background: #ef4444; /* red */
}
#register-form .strength-ui[data-strength="1"] .strength-bar-fill {
  width: 45%;
  background: #f59e0b; /* amber */
}
#register-form .strength-ui[data-strength="2"] .strength-bar-fill {
  width: 75%;
  background: var(--brand-500); /* brand */
}
#register-form .strength-ui[data-strength="3"] .strength-bar-fill {
  width: 100%;
  background: #10b981; /* green */
}

/* Compact on mobile */
@media (max-width: 520px) {
  #register-form .strength-bar { height: 7px; }
  #register-form .strength-label { font-size: 11px; }
}

/* ===== Duplicate Email Modal ===== */
.duplicate-email-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  padding: 20px;
  display: block;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 200ms ease, visibility 200ms ease;
}

.duplicate-email-modal.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.duplicate-email-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 32, 0.7);
  backdrop-filter: blur(4px);
  animation: fadeIn 200ms ease;
}

.duplicate-email-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: min(100%, 480px);
  padding: 32px 28px 28px;
  animation: modalSlideIn 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform, opacity;
}

.duplicate-email-modal-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  background: #fef3c7;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f59e0b;
}

.duplicate-email-modal-icon svg {
  width: 24px;
  height: 24px;
}

.duplicate-email-modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-900);
  margin: 0 0 12px;
  text-align: center;
  line-height: 1.3;
}

.duplicate-email-modal-message {
  font-size: 15px;
  color: var(--ink-500);
  line-height: 1.6;
  margin: 0 0 24px;
  text-align: center;
}

.duplicate-email-modal-email {
  font-weight: 600;
  color: var(--ink-900);
}

.duplicate-email-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.duplicate-email-modal-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: opacity 120ms ease, transform 80ms ease;
  text-decoration: none;
}

.duplicate-email-modal-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.duplicate-email-modal-btn:active {
  transform: translateY(0);
}

.duplicate-email-modal-btn-primary {
  background: #062348;
  color: var(--white);
}

.duplicate-email-modal-btn-secondary {
  background: var(--bg-100);
  color: var(--ink-900);
  border: 1px solid var(--ink-200);
}

.duplicate-email-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--ink-300);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
}

.duplicate-email-modal-close:hover {
  background: var(--bg-100);
  color: var(--ink-700);
}

.duplicate-email-modal-close svg {
  width: 20px;
  height: 20px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(0) scale(1);
  }
}

/* Mobile adjustments */
@media (max-width: 520px) {
  .duplicate-email-modal-content {
    padding: 24px 20px 20px;
    max-width: calc(100vw - 32px);
  }

  .duplicate-email-modal-title {
    font-size: 18px;
  }

  .duplicate-email-modal-message {
    font-size: 14px;
  }

  .duplicate-email-modal-btn {
    padding: 16px;
    font-size: 16px;
  }
}
