/* ===== AUTH MODAL — Redesigned ===== */

/* --- Overlay & Shell --- */
.auth-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-modal.active {
    display: flex;
}

.auth-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: authFadeIn 0.25s ease;
}

/* --- Card --- */
.auth-card {
    position: relative;
    z-index: 10001;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 2rem);
    background: var(--white);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid color-mix(in srgb, var(--white) 15%, transparent);
    box-shadow:
        0 25px 60px -12px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.03);
    animation: authSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Close Button --- */
.auth-close {
    position: absolute;
    top: 0.875rem;
    right: 0.875rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--white) 20%, transparent);
    backdrop-filter: blur(4px);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    z-index: 10;
    color: var(--white);
}

.auth-close:hover {
    background: color-mix(in srgb, var(--white) 35%, transparent);
    transform: scale(1.1);
}

.auth-close svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}

/* --- Header Banner --- */
.auth-header {
    position: relative;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
    padding: 2rem 2rem 1.5rem;
    text-align: center;
    overflow: hidden;
    flex-shrink: 0;
}

.auth-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -15%;
    width: 220px;
    height: 220px;
    background: color-mix(in srgb, var(--white) 10%, transparent);
    border-radius: 50%;
    pointer-events: none;
}

.auth-header::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -10%;
    width: 160px;
    height: 160px;
    background: color-mix(in srgb, var(--white) 7%, transparent);
    border-radius: 50%;
    pointer-events: none;
}

.auth-header-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 0.875rem;
    background: color-mix(in srgb, var(--white) 18%, transparent);
    backdrop-filter: blur(8px);
    border: 1px solid color-mix(in srgb, var(--white) 25%, transparent);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.auth-header-icon svg {
    width: 24px;
    height: 24px;
    color: var(--white);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.auth-header h2 {
    color: var(--white);
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    letter-spacing: -0.01em;
}

.auth-header p {
    color: color-mix(in srgb, var(--white) 80%, transparent);
    font-size: 0.8125rem;
    margin: 0;
}

/* --- Pill Tabs --- */
.auth-tabs {
    display: flex;
    gap: 4px;
    background: rgba(var(--primary-color-rgb), 0.08);
    border-radius: 12px;
    padding: 4px;
    margin: -1.125rem 2rem 0;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.auth-tab-btn {
    flex: 1;
    padding: 0.625rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.auth-tab-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.auth-tab-btn.active {
    background: var(--white);
    color: var(--text-dark);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.auth-tab-btn:not(.active):hover {
    color: var(--text-dark);
    background: rgba(var(--primary-color-rgb), 0.05);
}

/* --- Body / Form Area --- */
.auth-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem 0.75rem;
}

/* --- Tab Panels --- */
.auth-panel {
    display: none;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    flex: 1;
}

.auth-panel.active {
    display: flex;
    animation: authPanelIn 0.3s ease;
}

.auth-panel form {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    flex: 1;
}

/* --- Form Elements --- */
.auth-form-group {
    margin-bottom: 0.875rem;
}

.auth-form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.35rem;
}

.auth-form-group label .req {
    color: var(--error-color);
    margin-left: 2px;
}

/* --- Input Icon Wrapper --- */
.auth-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-icon {
    position: absolute;
    left: 0.75rem;
    width: 16px;
    height: 16px;
    color: var(--text-light);
    pointer-events: none;
    flex-shrink: 0;
    transition: color 0.2s;
    z-index: 1;
}

.auth-input-wrap:focus-within .auth-input-icon {
    color: var(--primary-color);
}

.auth-input.has-icon {
    padding-left: 2.375rem;
}

.auth-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-dark);
    background: rgba(var(--primary-color-rgb), 0.02);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    -webkit-appearance: none;
}

.auth-input::placeholder {
    color: var(--text-light);
}

.auth-input:hover:not(:focus) {
    border-color: var(--border-color);
    background: var(--white);
}

.auth-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.1);
    background: var(--white);
}

select.auth-input {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2364748b' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    padding-right: 2.25rem;
}

.auth-input.error {
    border-color: var(--error-color);
}

.auth-input.error:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--error-color) 12%, transparent);
}

.auth-error {
    display: block;
    color: var(--error-color);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    min-height: 0;
}

.auth-error:not(:empty) {
    min-height: 1rem;
}

.auth-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* --- Checkbox --- */
.auth-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.auth-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 1px;
}

.auth-checkbox span {
    font-size: 0.8125rem;
    color: var(--text-light);
    line-height: 1.4;
}

.auth-checkbox a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

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

/* --- Actions Row (remember me + forgot) --- */
.auth-actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.auth-forgot {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    white-space: nowrap;
}

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

/* --- Footer / Submit --- */
.auth-footer {
    padding: 1rem 2rem 1.5rem;
    flex-shrink: 0;
    border-top: 1px solid var(--white);
    background: var(--white);
}

.auth-submit {
    width: 100%;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 12px;
    background: var(--primary-color);
    color: var(--white);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
    box-shadow: 0 4px 14px rgba(var(--primary-color-rgb), 0.3);
    letter-spacing: 0.01em;
}

.auth-submit:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(var(--primary-color-rgb), 0.4);
}

.auth-submit:active:not(:disabled) {
    transform: translateY(0);
}

.auth-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-submit svg {
    width: 16px;
    height: 16px;
}

.auth-switch-text {
    text-align: center;
    margin-top: 0.875rem;
    font-size: 0.8125rem;
    color: var(--text-light);
}

.auth-switch-text a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

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

/* --- Divider (optional, for social auth) --- */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.875rem 0;
    color: var(--text-light);
    font-size: 0.75rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* --- Password Show/Hide Toggle --- */
.auth-input.has-toggle {
    padding-right: 2.375rem;
}

.auth-pwd-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
    display: flex;
    align-items: center;
    line-height: 1;
    transition: color 0.2s;
    z-index: 2;
}

.auth-pwd-toggle:hover {
    color: var(--primary-color);
}

.auth-pwd-toggle svg {
    width: 16px;
    height: 16px;
}

/* --- Password Strength Meter --- */
.pwd-strength-wrap {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-top: 0.5rem;
}

.pwd-strength-bar {
    flex: 1;
    display: flex;
    gap: 3px;
}

.pwd-strength-segment {
    flex: 1;
    height: 4px;
    border-radius: 4px;
    background: var(--border-color);
    transition: background 0.35s ease;
}

.pwd-strength-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-light);
    white-space: nowrap;
    min-width: 40px;
    text-align: right;
    transition: color 0.35s ease;
}

.pwd-strength-wrap.weak .pwd-strength-segment:nth-child(1) { background: #ef4444; }
.pwd-strength-wrap.weak .pwd-strength-label { color: #ef4444; }

.pwd-strength-wrap.fair .pwd-strength-segment:nth-child(1),
.pwd-strength-wrap.fair .pwd-strength-segment:nth-child(2) { background: #f97316; }
.pwd-strength-wrap.fair .pwd-strength-label { color: #f97316; }

.pwd-strength-wrap.good .pwd-strength-segment:nth-child(1),
.pwd-strength-wrap.good .pwd-strength-segment:nth-child(2),
.pwd-strength-wrap.good .pwd-strength-segment:nth-child(3) { background: #eab308; }
.pwd-strength-wrap.good .pwd-strength-label { color: #eab308; }

.pwd-strength-wrap.strong .pwd-strength-segment { background: #22c55e; }
.pwd-strength-wrap.strong .pwd-strength-label { color: #22c55e; }

/* --- Password Requirements Box (below confirm field) --- */
.pwd-requirements-box {
    background: rgba(var(--primary-color-rgb), 0.04);
    border: 1px solid rgba(var(--primary-color-rgb), 0.12);
    border-radius: 10px;
    padding: 0.75rem 0.875rem;
    margin-bottom: 0.875rem;
}

.pwd-req-heading {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pwd-req-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem 0.5rem;
}

.pwd-req-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.775rem;
    font-weight: 500;
    color: var(--text-light);
    transition: color 0.2s ease;
}

.req-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--border-color);
    transition: color 0.2s ease;
}

.pwd-req-item.met {
    color: #16a34a;
}

.pwd-req-item.met .req-icon {
    color: #16a34a;
}

/* --- Forgot Password Panel --- */

/* Step wrapper divs sit between .auth-panel and its form/content, so they must
   propagate the flex-column fill-height chain that the other panels rely on. */
#forgotStep1,
#forgotStep2 {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.auth-forgot-desc {
    color: var(--text-light);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

/* Success state after sending reset link */
.forgot-success-body {
    text-align: center;
    padding-top: 2rem;
    padding-bottom: 0.5rem;
}

.forgot-success-icon {
    width: 64px;
    height: 64px;
    background: rgba(var(--primary-color-rgb), 0.1);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.125rem;
    color: var(--primary-color);
}

.forgot-success-icon svg {
    width: 28px;
    height: 28px;
}

.forgot-success-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 0.5rem;
}

.forgot-success-message {
    color: var(--text-light);
    font-size: 0.875rem;
    line-height: 1.65;
    margin: 0;
}

/* --- Animations --- */
@keyframes authFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes authSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

/* --- Responsive --- */
@media (max-width: 575.98px) {
    .auth-modal {
        padding: 0.5rem;
        align-items: flex-start;
        padding-top: 2rem;
    }

    .auth-card {
        max-width: 100%;
        border-radius: 16px;
        max-height: calc(100vh - 3rem);
    }

    .auth-header {
        padding: 1.25rem 1.25rem 1.125rem;
        flex-shrink: 0;
    }

    .auth-header-icon {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        margin-bottom: 0.625rem;
    }

    .auth-header-icon svg {
        width: 18px;
        height: 18px;
    }

    .auth-header h2 {
        font-size: 1.0625rem;
    }

    .auth-header p {
        font-size: 0.75rem;
    }

    .auth-tabs {
        margin: -0.875rem 1.25rem 0;
        flex-shrink: 0;
    }

    .auth-tab-btn {
        padding: 0.5rem 0.625rem;
        font-size: 0.8rem;
    }

    .auth-body {
        padding: 1rem 1.25rem 0.5rem;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .auth-footer {
        padding: 0.75rem 1.25rem 1rem;
        flex-shrink: 0;
    }

    .auth-form-group {
        margin-bottom: 0.625rem;
    }

    .auth-form-group label {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }

    .auth-input {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }

    .auth-input.has-icon {
        padding-left: 2.125rem;
    }

    .auth-input-icon {
        left: 0.625rem;
        width: 14px;
        height: 14px;
    }

    .auth-form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .auth-submit {
        padding: 0.625rem 1rem;
        font-size: 0.85rem;
    }

    .auth-switch-text {
        margin-top: 0.625rem;
        font-size: 0.8rem;
    }

    .auth-checkbox span {
        font-size: 0.75rem;
    }
}
