/* =============================================================================
   Gripar Login Modal — Unified Auth Modal System
   Version: 1.0.0
   Requires: gp-site-chrome.css (inherits --gp-* tokens)
   ============================================================================= */

/* ── Design Tokens (local) ── */
.gp-auth-modal-overlay {
    --m-brand:        #5B6ABF;
    --m-brand-dark:   #3D4FAF;
    --m-brand-mid:    #7B8AD4;
    --m-brand-soft:   #EEF1FB;
    --m-brand-wash:   #F5F7FF;
    --m-saffron:      #F58220;
    --m-saffron-dark: #D96915;
    --m-saffron-soft: #FEF3EB;
    --m-ink:          #0F172A;
    --m-ink-2:        #1F2937;
    --m-soft:         #475569;
    --m-muted:        #94A3B8;
    --m-line:         #E2E8F0;
    --m-bg:           #F8FAFF;
    --m-success:      #10B981;
    --m-error:        #EF4444;
    --m-radius:       20px;
    --m-radius-sm:    12px;
    --m-shadow:       0 24px 64px rgba(15,23,42,.14), 0 8px 24px rgba(15,23,42,.08);
    --m-transition:   .3s cubic-bezier(.16,1,.3,1);
}

/* ── Overlay ── */
.gp-auth-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15,23,42,.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
    padding: 24px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}
.gp-auth-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* ── Modal Card ── */
.gp-auth-modal {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: var(--m-radius);
    box-shadow: var(--m-shadow);
    overflow: hidden;
    transform: translateY(20px) scale(.97);
    transition: transform var(--m-transition);
}
.gp-auth-modal-overlay.open .gp-auth-modal {
    transform: translateY(0) scale(1);
}

/* Accent strip at top */
.gp-auth-modal::before {
    content: '';
    display: block;
    height: 4px;
    background: linear-gradient(90deg, var(--m-saffron), var(--m-brand-mid), var(--m-brand));
}

/* Close button */
.gp-auth-modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 2;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--m-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, color .2s;
    line-height: 1;
}
.gp-auth-modal-close:hover {
    background: var(--m-brand-soft);
    color: var(--m-brand);
}

/* ── Modal Body ── */
.gp-auth-modal-body {
    position: relative;
    padding: 40px 36px 32px;
    min-height: 320px;
}

/* ── Steps (only one visible at a time) ── */
.gp-modal-step {
    display: none;
    animation: gpModalFadeIn .3s ease forwards;
}
.gp-modal-step.active {
    display: block;
}
@keyframes gpModalFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Step Header ── */
.gp-modal-step-header {
    text-align: center;
    margin-bottom: 28px;
}
.gp-modal-step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--m-brand-soft), var(--m-brand-wash));
    margin-bottom: 16px;
}
.gp-modal-step-icon i,
.gp-modal-step-icon svg {
    font-size: 22px;
    color: var(--m-brand);
    width: 22px;
    height: 22px;
}
.gp-modal-step-header h3 {
    font-size: 22px;
    font-weight: 700;
    color: var(--m-ink);
    margin: 0 0 6px;
    line-height: 1.3;
}
.gp-modal-step-header p {
    font-size: 14px;
    color: var(--m-soft);
    margin: 0;
    line-height: 1.5;
}

/* ── Form Elements ── */
.gp-modal-form-group {
    margin-bottom: 18px;
}
.gp-modal-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--m-ink-2);
    margin-bottom: 6px;
}
.gp-modal-input-wrap {
    position: relative;
}
.gp-modal-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--m-ink);
    background: var(--m-bg);
    border: 1.5px solid var(--m-line);
    border-radius: var(--m-radius-sm);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}
.gp-modal-input:focus {
    border-color: var(--m-brand);
    box-shadow: 0 0 0 3px rgba(91,106,191,.12);
}
.gp-modal-input.error {
    border-color: var(--m-error);
    box-shadow: 0 0 0 3px rgba(239,68,68,.1);
    animation: gpShake .4s ease;
}
@keyframes gpShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* Password toggle inside input */
.gp-modal-pw-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--m-muted);
    transition: color .2s;
    display: flex;
    align-items: center;
}
.gp-modal-pw-toggle:hover {
    color: var(--m-soft);
}
.gp-modal-input-wrap .gp-modal-input {
    padding-right: 44px;
}

/* Remember me row */
.gp-modal-remember-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 13px;
}
.gp-modal-remember-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--m-soft);
    font-weight: 500;
    margin-bottom: 0;
}
.gp-modal-remember-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--m-brand);
    margin: 0;
}

/* ── Buttons ── */
.gp-modal-btn {
    width: 100%;
    padding: 13px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, var(--m-brand), var(--m-brand-dark));
    border: none;
    border-radius: var(--m-radius-sm);
    cursor: pointer;
    transition: transform .15s, box-shadow .2s, opacity .2s;
    box-shadow: 0 4px 16px rgba(91,106,191,.25);
    position: relative;
    overflow: hidden;
}
.gp-modal-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(91,106,191,.35);
}
.gp-modal-btn:active:not(:disabled) {
    transform: translateY(0);
}
.gp-modal-btn:disabled {
    opacity: .6;
    cursor: not-allowed;
}
/* Loading spinner on button */
.gp-modal-btn.loading {
    color: transparent !important;
    pointer-events: none;
}
.gp-modal-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 2.5px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: gpSpin .6s linear infinite;
}
@keyframes gpSpin {
    to { transform: rotate(360deg); }
}

/* ── Message boxes ── */
.gp-modal-msg {
    display: none;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 16px;
    text-align: center;
}
.gp-modal-msg.show {
    display: block;
    animation: gpModalFadeIn .25s ease;
}
.gp-modal-msg.error {
    background: #FEF2F2;
    color: #DC2626;
    border: 1px solid #FECACA;
}
.gp-modal-msg.success {
    background: #F0FDF4;
    color: #16A34A;
    border: 1px solid #BBF7D0;
}
.gp-modal-msg.info {
    background: var(--m-brand-soft);
    color: var(--m-brand-dark);
    border: 1px solid #C8D0F0;
}

/* ── MFA OTP Input Group ── */
.gp-modal-otp-group {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 24px 0;
}
.gp-modal-otp-input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;
    color: var(--m-ink);
    background: var(--m-bg);
    border: 2px solid var(--m-line);
    border-radius: var(--m-radius-sm);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    caret-color: var(--m-brand);
}
.gp-modal-otp-input:focus {
    border-color: var(--m-brand);
    box-shadow: 0 0 0 3px rgba(91,106,191,.12);
}
.gp-modal-otp-input.filled {
    border-color: var(--m-brand-mid);
    background: var(--m-brand-wash);
}
.gp-modal-otp-input.error {
    border-color: var(--m-error);
    animation: gpShake .4s ease;
}

/* MFA dev code display */
.gp-modal-dev-code {
    display: none;
    text-align: center;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 8px;
    font-size: 12px;
    color: #92400E;
}
.gp-modal-dev-code strong {
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 2px;
}

/* ── Step Footer / Links ── */
.gp-modal-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 13px;
    color: var(--m-muted);
}
.gp-modal-footer a,
.gp-modal-link {
    color: var(--m-brand);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: color .2s;
}
.gp-modal-footer a:hover,
.gp-modal-link:hover {
    color: var(--m-brand-dark);
    text-decoration: underline;
}

.gp-modal-back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--m-muted);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: color .2s;
    margin-top: 16px;
}
.gp-modal-back-link:hover {
    color: var(--m-brand);
}

/* ── Divider ── */
.gp-modal-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    font-size: 12px;
    color: var(--m-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}
.gp-modal-divider::before,
.gp-modal-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--m-line);
}

/* ── Success checkmark ── */
.gp-modal-success-check {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(4px);
    z-index: 10;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.gp-modal-success-check.show {
    display: flex;
    animation: gpModalFadeIn .3s ease;
}
.gp-modal-success-check-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--m-success);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: gpCheckPop .4s cubic-bezier(.16,1,.3,1);
}
.gp-modal-success-check-icon svg {
    width: 28px;
    height: 28px;
    stroke: #fff;
    stroke-width: 3;
    fill: none;
}
.gp-modal-success-check p {
    font-size: 15px;
    font-weight: 600;
    color: var(--m-ink);
}
@keyframes gpCheckPop {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ── Password strength bar ── */
.gp-modal-pw-strength {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}
.gp-modal-pw-strength-bar {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--m-line);
    transition: background .3s;
}
.gp-modal-pw-strength-bar.weak   { background: var(--m-error); }
.gp-modal-pw-strength-bar.fair   { background: #F59E0B; }
.gp-modal-pw-strength-bar.good   { background: #10B981; }
.gp-modal-pw-strength-bar.strong { background: #059669; }

.gp-modal-pw-hint {
    font-size: 11px;
    color: var(--m-muted);
    margin-top: 4px;
}

/* ── Username result card (forgot-username step) ── */
.gp-modal-username-result {
    display: none;
    text-align: center;
    padding: 20px;
    background: var(--m-brand-wash);
    border-radius: var(--m-radius-sm);
    border: 1px solid #C8D0F0;
    margin-top: 16px;
}
.gp-modal-username-result.show {
    display: block;
    animation: gpModalFadeIn .3s ease;
}
.gp-modal-username-result .result-label {
    font-size: 13px;
    color: var(--m-soft);
    margin-bottom: 8px;
}
.gp-modal-username-result .result-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--m-brand-dark);
}

/* ── Footer branding ── */
.gp-modal-brand-footer {
    text-align: center;
    padding: 14px 36px 18px;
    border-top: 1px solid var(--m-line);
    font-size: 11px;
    color: var(--m-muted);
}
.gp-modal-brand-footer a {
    color: var(--m-brand);
    text-decoration: none;
    font-weight: 600;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .gp-auth-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .gp-auth-modal {
        max-width: 100%;
        border-radius: var(--m-radius) var(--m-radius) 0 0;
        max-height: 95vh;
        overflow-y: auto;
    }
    .gp-auth-modal-body {
        padding: 32px 24px 24px;
    }
    .gp-modal-otp-input {
        width: 42px;
        height: 50px;
        font-size: 20px;
    }
    .gp-modal-step-header h3 {
        font-size: 20px;
    }
}
