/**
 * Branded Auth Styles
 *
 * Dark theme login/register/forgot-password forms and auth modal.
 * Uses CSS custom properties from the theme (--ip-*).
 *
 * @package IndiePortal
 * @since   1.0.393
 */

/* ==========================================================================
   Full-Page Layout
   ========================================================================== */

.ip-auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ip-bg-base, #0d0d0d);
    padding: 2rem 1rem;
}

/* ==========================================================================
   Auth Card
   ========================================================================== */

.ip-auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--ip-bg-surface, #1a1a1a);
    border: 1px solid var(--ip-border-default, rgba(255, 255, 255, 0.1));
    border-radius: 16px;
    padding: 2.5rem;
}

.ip-auth-card--register {
    max-width: 500px;
}

/* Logo */
.ip-auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.ip-auth-logo-icon {
    font-size: 28px;
    line-height: 1;
}

.ip-auth-logo-text {
    font-family: var(--ip-font-display, 'Inter', sans-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ip-text-primary, #ffffff);
    letter-spacing: -0.02em;
}

.ip-auth-logo-accent {
    color: var(--ip-primary, #C82AEF);
}

/* Heading */
.ip-auth-heading {
    font-family: var(--ip-font-display, 'Inter', sans-serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--ip-text-primary, #ffffff);
    text-align: center;
    margin: 0 0 1.5rem;
}

/* Subtext */
.ip-auth-subtext {
    font-size: 0.875rem;
    color: var(--ip-text-tertiary, rgba(255, 255, 255, 0.6));
    text-align: center;
    margin: 0 0 1.5rem;
    line-height: 1.5;
}

/* ==========================================================================
   Form Elements
   ========================================================================== */

.ip-auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ip-auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ip-auth-field > label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ip-text-secondary, rgba(255, 255, 255, 0.85));
}

.ip-auth-required {
    color: var(--ip-error, #ef4444);
}

.ip-auth-optional {
    font-weight: 400;
    color: var(--ip-text-muted, rgba(255, 255, 255, 0.4));
    font-size: 0.75rem;
}

.ip-auth-field input[type="text"],
.ip-auth-field input[type="email"],
.ip-auth-field input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--ip-bg-input, #1a1a1a);
    border: 1px solid var(--ip-border-default, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    color: var(--ip-text-primary, #ffffff);
    font-size: 0.9375rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.ip-auth-field input:focus {
    border-color: var(--ip-primary, #C82AEF);
    box-shadow: 0 0 0 3px var(--ip-primary-light, rgba(200, 42, 239, 0.15));
}

.ip-auth-field input::placeholder {
    color: var(--ip-text-muted, rgba(255, 255, 255, 0.4));
}

/* Password wrapper (for toggle button) */
.ip-auth-password-wrap {
    position: relative;
}

.ip-auth-password-wrap input {
    padding-right: 44px;
}

.ip-auth-toggle-pw {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--ip-text-muted, rgba(255, 255, 255, 0.4));
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.ip-auth-toggle-pw:hover {
    color: var(--ip-text-secondary, rgba(255, 255, 255, 0.85));
}

.ip-auth-toggle-pw.active svg {
    color: var(--ip-primary, #C82AEF);
}

/* Remember me + forgot password row */
.ip-auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.ip-auth-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--ip-text-secondary, rgba(255, 255, 255, 0.85));
}

.ip-auth-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--ip-primary, #C82AEF);
    cursor: pointer;
}

.ip-auth-link {
    font-size: 0.8125rem;
    color: var(--ip-primary, #C82AEF);
    text-decoration: none;
    transition: color 0.2s;
}

.ip-auth-link:hover {
    color: var(--ip-primary-hover, #D94FF5);
    text-decoration: underline;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.ip-auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
    line-height: 1.4;
}

.ip-auth-btn--primary {
    width: 100%;
    background: var(--ip-primary, #C82AEF);
    color: #ffffff;
}

.ip-auth-btn--primary:hover {
    background: var(--ip-primary-hover, #D94FF5);
}

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

/* Loading state */
.ip-auth-btn.ip-auth-loading .ip-auth-btn-text {
    visibility: hidden;
}

.ip-auth-btn-spinner {
    display: none;
}

.ip-auth-btn.ip-auth-loading .ip-auth-btn-spinner {
    display: block;
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: ip-auth-spin 0.6s linear infinite;
}

.ip-auth-btn.ip-auth-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.85;
}

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

/* ==========================================================================
   Messages (error / success / info / warning)
   ========================================================================== */

.ip-auth-message,
.ip-auth-errors:not(:empty),
.ip-auth-success:not(:empty) {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.ip-auth-message--error,
.ip-auth-errors:not(:empty) {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.ip-auth-message--success,
.ip-auth-success:not(:empty) {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.ip-auth-message--info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

.ip-auth-message--warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

/* ==========================================================================
   Switch Links (bottom of card)
   ========================================================================== */

.ip-auth-switch {
    text-align: center;
    font-size: 0.875rem;
    color: var(--ip-text-tertiary, rgba(255, 255, 255, 0.6));
    margin-top: 1.5rem;
}

.ip-auth-switch a {
    color: var(--ip-primary, #C82AEF);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.ip-auth-switch a:hover {
    color: var(--ip-primary-hover, #D94FF5);
    text-decoration: underline;
}

/* ==========================================================================
   Password Strength
   ========================================================================== */

.ip-password-strength {
    height: 4px;
    border-radius: 2px;
    background: var(--ip-border-subtle, rgba(255, 255, 255, 0.06));
    margin-top: 4px;
    overflow: hidden;
}

.ip-password-strength-fill {
    height: 100%;
    border-radius: 2px;
    width: 0;
    transition: width 0.3s ease, background 0.3s ease;
}

.ip-password-strength-fill[data-strength="weak"] {
    width: 25%;
    background: var(--ip-error, #ef4444);
}

.ip-password-strength-fill[data-strength="fair"] {
    width: 50%;
    background: var(--ip-warning, #f59e0b);
}

.ip-password-strength-fill[data-strength="strong"] {
    width: 75%;
    background: var(--ip-success, #22c55e);
}

.ip-password-strength-fill[data-strength="very-strong"] {
    width: 100%;
    background: var(--ip-success, #22c55e);
}

.ip-password-strength-label {
    font-size: 0.75rem;
    color: var(--ip-text-muted, rgba(255, 255, 255, 0.4));
    margin-top: 2px;
    display: block;
    min-height: 1em;
}

/* ==========================================================================
   Preference Chips
   ========================================================================== */

.ip-auth-preferences {
    margin-top: 0.5rem;
}

.ip-auth-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.ip-auth-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border: 1px solid var(--ip-border-default, rgba(255, 255, 255, 0.1));
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--ip-text-secondary, rgba(255, 255, 255, 0.85));
    background: transparent;
    transition: all 0.2s;
    user-select: none;
}

.ip-auth-chip:hover {
    border-color: var(--ip-border-strong, rgba(255, 255, 255, 0.15));
    background: var(--ip-primary-subtle, rgba(200, 42, 239, 0.08));
}

.ip-auth-chip.selected {
    background: var(--ip-primary-light, rgba(200, 42, 239, 0.15));
    border-color: var(--ip-primary, #C82AEF);
    color: var(--ip-primary, #C82AEF);
}

.ip-auth-chip input[type="checkbox"] {
    display: none;
}

/* ==========================================================================
   Method Divider ("or sign in with")
   ========================================================================== */

.ip-auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0;
    color: var(--ip-text-muted, rgba(255, 255, 255, 0.4));
    font-size: 0.8125rem;
}

.ip-auth-divider::before,
.ip-auth-divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--ip-border-subtle, rgba(255, 255, 255, 0.06));
}

/* ==========================================================================
   Magic Link
   ========================================================================== */

.ip-auth-btn--magic {
    width: 100%;
    background: transparent;
    border: 1px solid var(--ip-border-default, rgba(255, 255, 255, 0.1));
    color: var(--ip-text-primary, #ffffff);
    gap: 10px;
}

.ip-auth-btn--magic:hover {
    border-color: var(--ip-primary, #C82AEF);
    background: var(--ip-primary-subtle, rgba(200, 42, 239, 0.08));
}

.ip-auth-magic-section.active {
    display: block;
}

.ip-auth-password-section.hidden {
    display: none;
}

.ip-auth-magic-expand {
    margin-top: 0.75rem;
}

.ip-auth-magic-expand .ip-auth-field {
    margin-bottom: 0.75rem;
}

.ip-auth-magic-back {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

/* ==========================================================================
   Honeypot (hidden)
   ========================================================================== */

.ip-auth-hp {
    position: absolute;
    left: -9999px;
    opacity: 0;
    height: 0;
    overflow: hidden;
}

/* ==========================================================================
   Modal
   ========================================================================== */

.ip-auth-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ip-auth-modal[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
}

.ip-auth-modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--ip-bg-overlay, rgba(0, 0, 0, 0.85));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ip-auth-modal-container {
    position: relative;
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--ip-bg-surface, #1a1a1a);
    border: 1px solid var(--ip-border-default, rgba(255, 255, 255, 0.1));
    border-radius: 16px;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.ip-auth-modal[aria-hidden="false"] .ip-auth-modal-container {
    transform: translateY(0);
}

/* Scrollbar styling */
.ip-auth-modal-container::-webkit-scrollbar {
    width: 6px;
}

.ip-auth-modal-container::-webkit-scrollbar-track {
    background: transparent;
}

.ip-auth-modal-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* Modal header */
.ip-auth-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--ip-border-subtle, rgba(255, 255, 255, 0.06));
    position: sticky;
    top: 0;
    background: var(--ip-bg-surface, #1a1a1a);
    z-index: 1;
    border-radius: 16px 16px 0 0;
}

.ip-auth-modal-tabs {
    display: flex;
    gap: 4px;
}

.ip-auth-tab {
    padding: 8px 16px;
    background: none;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--ip-text-tertiary, rgba(255, 255, 255, 0.6));
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.ip-auth-tab:hover {
    color: var(--ip-text-primary, #ffffff);
    background: rgba(255, 255, 255, 0.05);
}

.ip-auth-tab.active {
    color: var(--ip-primary, #C82AEF);
    background: var(--ip-primary-subtle, rgba(200, 42, 239, 0.08));
}

.ip-auth-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--ip-text-muted, rgba(255, 255, 255, 0.4));
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.ip-auth-modal-close:hover {
    color: var(--ip-text-primary, #ffffff);
    background: rgba(255, 255, 255, 0.08);
}

/* Modal body */
.ip-auth-modal-body {
    padding: 1.5rem;
}

/* Panel visibility */
.ip-auth-panel {
    display: none;
}

.ip-auth-panel.active {
    display: block;
}

/* Modal forms don't need the full-page wrapper */
.ip-auth-modal .ip-auth-card {
    background: none;
    border: none;
    padding: 0;
    max-width: none;
    border-radius: 0;
}

/* ==========================================================================
   Mobile
   ========================================================================== */

@media (max-width: 640px) {
    /* Full-page */
    .ip-auth-page {
        padding: 1rem;
        align-items: flex-start;
        padding-top: 4rem;
    }

    .ip-auth-card {
        padding: 1.5rem;
    }

    /* Modal → bottom sheet */
    .ip-auth-modal {
        align-items: flex-end;
    }

    .ip-auth-modal-container {
        width: 100%;
        max-width: none;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }

    .ip-auth-modal[aria-hidden="false"] .ip-auth-modal-container {
        transform: translateY(0);
    }

    /* Chips — smaller on mobile */
    .ip-auth-chip {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
}

@media (max-width: 380px) {
    .ip-auth-card {
        padding: 1.25rem;
    }

    .ip-auth-heading {
        font-size: 1.1rem;
    }

    .ip-auth-modal-body {
        padding: 1rem;
    }
}

/* ==========================================================================
   Social Login Buttons
   ========================================================================== */

.ip-auth-social-buttons {
    display: flex;
    gap: 10px;
    margin: 0.25rem 0;
}

.ip-auth-btn--social {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--ip-border-default, rgba(255, 255, 255, 0.1));
    color: var(--ip-text-primary, #ffffff);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: border-color 0.2s, background 0.2s;
}

.ip-auth-btn--social:hover {
    border-color: var(--ip-border-hover, rgba(255, 255, 255, 0.2));
    background: var(--ip-bg-hover, rgba(255, 255, 255, 0.04));
}

.ip-auth-btn--social svg {
    flex-shrink: 0;
}

.ip-auth-btn--google:hover {
    border-color: #4285F4;
    background: rgba(66, 133, 244, 0.08);
}

.ip-auth-btn--steam:hover {
    border-color: #1b2838;
    background: rgba(27, 40, 56, 0.15);
}

.ip-auth-btn--steam svg {
    fill: var(--ip-text-primary, #ffffff);
}

.ip-auth-divider--social {
    margin: 1rem 0;
}

/* Single social button (only one provider) — full width */
.ip-auth-social-buttons .ip-auth-btn--social:only-child {
    flex: none;
    width: 100%;
}
