/**
 * Prime Store - Authentication Component
 * Login, register, and OTP verification forms
 *
 * @package PrimeStore
 * @version 2.0.0
 */

/* ===================================================================
   CSS CUSTOM PROPERTIES
   These variables are dynamically set via PHP settings
   =================================================================== */
:root {
    --auth-bg-color: #ffffff;
    --auth-border-radius-box: 16px;
    --auth-input-bg: #f9fafb;
    --auth-input-border: #e5e7eb;
    --auth-input-text: #1f2937;
    --auth-input-focus-border: #4f46e5;
    --auth-input-focus-bg: #ffffff;
    --auth-border-radius-input: 8px;
    --auth-button-bg: #4f46e5;
    --auth-button-text: #ffffff;
    --auth-button-hover-bg: #4338ca;
    --auth-border-radius-button: 8px;
    --auth-secondary-color: #6366f1;
    --auth-link-color: #4f46e5;
    --auth-link-hover-color: #4338ca;
    --auth-primary-color: #4f46e5;
    --auth-error-color: #ef4444;
    --auth-success-color: #10b981;
    --auth-border-radius-radio: 8px;
    --auth-radio-hover-border: #c7d2fe;
    --auth-radio-hover-bg: #f5f3ff;
    --auth-radio-color: #4f46e5;
    --auth-placeholder-color: #9ca3af;
    --auth-autofill-text-color: #1f2937;
    --auth-autofill-bg-color: #e8f0fe;
}

/* ===================================================================
   CONTAINER & BOX
   =================================================================== */
.prime-store-auth-container {
    max-width: 420px;
    margin: 0 auto;
    padding: 0 15px;
    font-family: inherit;
}

.prime-store-auth-box {
    background: var(--color-bg, #fff);
    border-radius: var(--auth-border-radius-box, var(--radius-xl, 16px));
    box-shadow: var(--shadow-lg, 0 4px 24px rgba(0, 0, 0, 0.08));
    padding: var(--spacing-3xl, 32px);
    position: relative;
    overflow: hidden;
}

/* ===================================================================
   HEADER
   =================================================================== */
.prime-store-auth-header {
    text-align: center;
    margin-bottom: var(--spacing-3xl, 32px);
}

.prime-store-auth-header h2 {
    font-size: var(--font-size-3xl, 24px);
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 var(--spacing-sm, 8px) 0;
}

.prime-store-auth-header p {
    font-size: var(--font-size-base, 14px) !important;
    color: var(--color-text-secondary, #6b7280);
    margin: 0;
}

.prime-store-auth-header .prime-store-auth-subtitle {
    font-size: var(--font-size-base, 14px);
    color: var(--color-text-secondary, #6b7280);
    margin: 0;
    display: block;
}

/* Steps */
.prime-store-auth-step {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.prime-store-auth-step-header {
    margin-bottom: 20px;
}

.prime-store-auth-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    transition: color 0.2s;
}

.prime-store-auth-back:hover {
    background-color: unset;
    color: #4f46e5;
}

.prime-store-auth-back svg {
    width: 18px;
    height: 18px;
}

/* ===================================================================
   FORM GROUPS
   =================================================================== */
.prime-store-auth-form-group {
    margin-bottom: 5px;
}

.prime-store-auth-form-group label {
    display: block;
    font-size: var(--font-size-base, 14px);
    font-weight: 600;
    color: var(--color-text, #374151);
    margin-bottom: var(--spacing-sm, 8px);
}

.prime-store-auth-form-group label .required {
    color: var(--auth-error-color, var(--color-error, #ef4444));
}

.prime-store-auth-form-group label small {
    font-weight: 400;
    color: var(--auth-placeholder-color, var(--color-text-light, #9ca3af));
}

/* ===================================================================
   INPUT WRAPPER
   =================================================================== */
.prime-store-auth-input-wrapper {
    position: relative;
}

.prime-store-auth-input-wrapper input {
    width: 100%;
    padding: 10px 16px 10px 48px;
    border: 2px solid var(--auth-input-border, var(--color-border, #e5e7eb));
    border-radius: var(--auth-border-radius-input, var(--radius-lg, 12px));
    font-size: var(--font-size-lg, 16px);
    color: var(--auth-input-text, var(--color-text, #1f2937));
    background: var(--auth-input-bg, var(--color-bg-secondary, #f9fafb));
    transition: all var(--transition-base, 200ms ease);
    box-sizing: border-box;
}

.prime-store-auth-input-wrapper input:focus {
    outline: none;
    border-color: var(--auth-input-focus-border, var(--color-primary, #4f46e5));
    background: var(--auth-input-focus-bg, var(--color-bg, #fff));
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.prime-store-auth-input-wrapper input.has-error {
    border-color: var(--auth-error-color, var(--color-error, #ef4444));
}

/* ===================================================================
   INPUT ICONS
   =================================================================== */
.prime-store-auth-input-icon {
    position: absolute;
    left: 12px;
    top: 55%;
    transform: translateY(-50%);
    color: #7e8591;
    pointer-events: none;
}

.prime-store-auth-input-icon svg {
    width: 24px;
    height: 24px;
}

/* Regular inputs */
.prime-store-auth-form-group > input {
    width: 100%;
    padding: 10px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 16px;
    color: #1f2937;
    background: #f9fafb;
    transition: all 0.2s;
    box-sizing: border-box;
}

.prime-store-auth-form-group > input:focus {
    outline: none;
    border-color: #4f46e5;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* Password toggle button reset */
.prime-store-auth-toggle-password {
    all: unset;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #9ca3af !important;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
}

.prime-store-auth-toggle-password:hover {
    color: #4f46e5;
    background: transparent !important;
    border: none !important;
}

.prime-store-auth-toggle-password svg {
    width: 20px;
    height: 20px;
}

/* Password wrapper */
.prime-store-auth-password-wrapper,
.prime-store-password-wrapper {
    position: relative;
}

.prime-store-auth-password-wrapper input,
.prime-store-password-wrapper input {
    padding-left: 48px;
    color: #1f2937 !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #1f2937 !important;
}

.prime-store-auth-password-wrapper input::placeholder,
.prime-store-password-wrapper input::placeholder {
    color: #9ca3af !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #9ca3af !important;
}

/* Error message */
.prime-store-auth-error {
    display: block;
    font-size: 12px;
    color: #ef4444;
    margin-top: 6px;
    min-height: 18px;
}

/* General error message */
.prime-store-auth-general-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

/* OTP Inputs */
.prime-store-auth-otp-inputs {
    display: flex;
    gap: 8px;
    justify-content: center;
    direction: ltr;
}

.prime-store-auth-otp-inputs .otp-digit {
    padding: 0px !important;
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: #f9fafb;
    transition: all 0.2s;
    color: #1f2937;
}

.prime-store-auth-otp-inputs .otp-digit:focus {
    outline: none;
    border-color: #4f46e5;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.prime-store-auth-otp-inputs.has-error .otp-digit {
    border-color: #ef4444;
}

/* Info text */
.prime-store-auth-info {
    text-align: center;
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 24px;
}

.prime-store-auth-info strong {
    color: #1f2937;
    direction: ltr;
    display: inline-block;
}

/* Timer */
.prime-store-auth-timer {
    text-align: center;
    font-size: 14px;
    color: #6b7280;
    margin: 16px 0;
}

.prime-store-auth-timer .timer-countdown {
    font-weight: 700;
    color: #4f46e5;
    min-width: 24px;
    display: inline-block;
}

/* Buttons */
.prime-store-auth-btn {
    width: 100%;
    padding: 14px 24px !important;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.prime-store-auth-btn-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: #fff;
}

.prime-store-auth-btn-primary:hover {
    background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
}

.prime-store-auth-btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.prime-store-auth-btn-link {
    background: transparent;
    color: #4f46e5;
    padding: 8px;
}

.prime-store-auth-btn-link:hover {
    background: rgba(79, 70, 229, 0.05);
    color: #1a1a2e;
}

/* Auth Links (simple text links) */
.prime-store-auth-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

/* Auth Switch Method */
.prime-store-auth-switch-method {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 16px;
    width: 100%;
}

.prime-store-auth-link {
    color: #4f46e5 !important;
    text-decoration: none !important;
    font-size: 14px;
    transition: color 0.2s;
    cursor: pointer;
    background: none !important;
    border: none !important;
    display: inline-block;
}

.prime-store-auth-link:hover {
    color: #4338ca !important;
    text-decoration: none !important;
}

/* Loading spinner */
.prime-store-auth-btn .spinner {
    width: 24px;
    height: 24px;
    animation: rotate 1s linear infinite;
}

.prime-store-auth-btn .spinner circle {
    stroke: currentColor;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* Success */
.prime-store-auth-step-success {
    text-align: center;
    padding: 40px 0;
}

.prime-store-auth-success-icon {
    color: #10b981;
    margin-bottom: 24px;
}

.prime-store-auth-success-icon svg {
    width: 64px;
    height: 64px;
}

.prime-store-auth-step-success h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 8px 0;
}

.prime-store-auth-step-success p {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* Debug box */
.prime-store-auth-debug {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 12px;
    margin-top: 16px;
    text-align: center;
}

.prime-store-auth-debug p {
    margin: 0;
    font-size: 14px;
    color: #92400e;
}

.prime-store-auth-debug .debug-code {
    font-size: 20px;
    color: #d97706;
    letter-spacing: 4px;
    direction: ltr;
    display: inline-block;
}

/* Gender Options */
.prime-store-auth-gender-options {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.prime-store-auth-radio-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 12px 20px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    transition: all 0.2s ease;
    flex: 1;
    justify-content: center;
}

.prime-store-auth-radio-label:hover {
    border-color: #c7d2fe;
    background: #f5f3ff;
}

.prime-store-auth-radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: #4f46e5;
    cursor: pointer;
}

.prime-store-auth-radio-label input[type="radio"]:checked + span {
    color: #4f46e5;
    font-weight: 600;
}

/* This will be overridden by inline styles from settings */
.prime-store-auth-radio-label:has(input[type="radio"]:checked) {
    border-color: #4f46e5;
    background-color: rgba(79, 70, 229, 0.05);
}

.prime-store-auth-radio-label span {
    font-size: 14px;
    color: #374151;
}

/* === Dynamic Customization Styles === */
/* These use CSS variables that are set from plugin settings */

/* Auth Box */
.prime-store-auth-box {
    background-color: var(--auth-bg-color) !important;
    border-radius: var(--auth-border-radius-box) !important;
}

/* Form Inputs */
.prime-store-auth-input-wrapper input,
.prime-store-auth-form-group > input,
.prime-store-auth-form-group select,
.prime-store-auth-form-group textarea {
    background-color: var(--auth-input-bg) !important;
    border-color: var(--auth-input-border) !important;
    color: var(--auth-input-text) !important;
    border-radius: var(--auth-border-radius-input) !important;
}

.prime-store-auth-input-wrapper input:focus,
.prime-store-auth-form-group > input:focus,
.prime-store-auth-form-group select:focus,
.prime-store-auth-form-group textarea:focus {
    border-color: var(--auth-input-focus-border) !important;
    background-color: var(--auth-input-focus-bg) !important;
}

/* OTP Inputs */
.prime-store-auth-otp-inputs .otp-digit {
    background-color: var(--auth-input-bg) !important;
    border-color: var(--auth-input-border) !important;
    color: var(--auth-input-text) !important;
    border-radius: var(--auth-border-radius-input) !important;
}

.prime-store-auth-otp-inputs .otp-digit:focus {
    border-color: var(--auth-input-focus-border) !important;
    background-color: var(--auth-input-focus-bg) !important;
}

/* Primary Button */
.prime-store-auth-btn-primary {
    background: var(--auth-button-bg) !important;
    background-image: none !important;
    color: var(--auth-button-text) !important;
    border-radius: var(--auth-border-radius-button) !important;
}

.prime-store-auth-btn-primary:hover {
    background: var(--auth-button-hover-bg) !important;
    background-image: none !important;
}

/* Secondary Button */
.prime-store-auth-btn-secondary {
    background: var(--auth-secondary-color) !important;
    background-image: none !important;
    color: var(--auth-button-text) !important;
    border-radius: var(--auth-border-radius-button) !important;
}

.prime-store-auth-btn-secondary:hover {
    opacity: 0.9;
}

/* Link Buttons */
.prime-store-auth-btn-link {
    color: var(--auth-link-color) !important;
}

.prime-store-auth-btn-link:hover {
    color: var(--auth-link-hover-color) !important;
}

/* Links */
.prime-store-auth-link,
.prime-store-auth-container a,
.prime-store-auth-footer a {
    color: var(--auth-link-color) !important;
}

.prime-store-auth-link:hover,
.prime-store-auth-container a:hover,
.prime-store-auth-footer a:hover {
    color: var(--auth-link-hover-color) !important;
}

/* Back Button */
.prime-store-auth-back {
    color: var(--auth-link-color) !important;
}

.prime-store-auth-back:hover {
    color: var(--auth-link-hover-color) !important;
}

/* Timer Countdown */
.prime-store-auth-timer .timer-countdown {
    color: var(--auth-primary-color) !important;
}

/* Error Messages */
.prime-store-auth-error,
.prime-store-error-message,
.prime-store-auth-input-wrapper input.has-error,
.prime-store-auth-otp-inputs.has-error .otp-digit {
    border-color: var(--auth-error-color) !important;
    color: var(--auth-error-color) !important;
}

.prime-store-auth-alert-error {
    border-color: var(--auth-error-color) !important;
    color: var(--auth-error-color) !important;
}

/* Success Messages */
.prime-store-auth-success,
.prime-store-success-message {
    border-color: var(--auth-success-color) !important;
    color: var(--auth-success-color) !important;
}

.prime-store-auth-alert-success {
    border-color: var(--auth-success-color) !important;
    color: var(--auth-success-color) !important;
}

/* Tabs */
.prime-store-auth-tabs button:hover {
    color: var(--auth-primary-color) !important;
}

.prime-store-auth-tabs button.active {
    color: var(--auth-primary-color) !important;
    border-bottom-color: var(--auth-primary-color) !important;
}

/* Progress Indicator */
.prime-store-auth-progress .step.active,
.prime-store-auth-progress .step.completed {
    background-color: var(--auth-primary-color) !important;
}

/* Loading Spinner */
.prime-store-auth-btn .btn-loader .spinner circle {
    stroke: var(--auth-button-text) !important;
}

/* Radio Buttons */
.prime-store-auth-radio-label {
    border-radius: var(--auth-border-radius-radio) !important;
}

.prime-store-auth-radio-label:hover {
    border-color: var(--auth-radio-hover-border) !important;
    background: var(--auth-radio-hover-bg) !important;
}

.prime-store-auth-radio-label input[type="radio"]:checked + span {
    color: var(--auth-radio-color) !important;
}

.prime-store-auth-radio-label input[type="radio"]:checked {
    accent-color: var(--auth-radio-color) !important;
}

.prime-store-auth-radio-label:has(input[type="radio"]:checked) {
    border-color: var(--auth-radio-color) !important;
}

/* Placeholder */
.prime-store-auth-input-wrapper input::placeholder,
.prime-store-auth-form-group > input::placeholder,
.prime-store-auth-form-group select::placeholder,
.prime-store-auth-form-group textarea::placeholder {
    color: var(--auth-placeholder-color) !important;
}

/* Autofill */
.prime-store-auth-input-wrapper input:-webkit-autofill,
.prime-store-auth-input-wrapper input:-webkit-autofill:hover,
.prime-store-auth-input-wrapper input:-webkit-autofill:focus,
.prime-store-auth-form-group > input:-webkit-autofill,
.prime-store-auth-form-group > input:-webkit-autofill:hover,
.prime-store-auth-form-group > input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--auth-autofill-text-color) !important;
    border-color: var(--auth-input-border) !important;
}

.prime-store-auth-input-wrapper input:-internal-autofill-selected,
.prime-store-auth-form-group > input:-internal-autofill-selected {
    background-color: var(--auth-autofill-bg-color) !important;
    color: var(--auth-autofill-text-color) !important;
}

/* Captcha */
.prime-store-auth-captcha {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

/* Responsive */
@media (max-width: 480px) {
    .prime-store-auth-container {
        margin: 20px auto;
    }

    .prime-store-auth-box {
        padding: 24px 20px;
        border-radius: 12px;
    }

    .prime-store-auth-header h2 {
        font-size: 20px;
    }

    .prime-store-auth-otp-inputs .otp-digit {
        width: 42px;
        height: 50px;
        font-size: 20px;
    }

    .prime-store-auth-gender-options {
        flex-direction: column;
        gap: 10px;
    }

    .prime-store-auth-radio-label {
        padding: 10px 16px;
    }
}

/* Hide WooCommerce default login when our form is active */
.prime-store-wc-login-wrapper {
    display: none !important;
}
