/* ── Reset Password Styles ──────────────────────────────────
   Supports Admin, Manager, and Subscriber (Portal) looks
   Mobile 390px first, RTL, No CDN, No horizontal scroll
─────────────────────────────────────────────────────────── */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-page: #0b0f19;
    --card-bg: rgba(15, 23, 42, 0.82);
    --card-border: rgba(148, 163, 184, 0.2);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-faint: #64748b;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.35);
    --accent-hover: #4f46e5;
    --btn-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --accent-bar: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899);
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-border: rgba(148, 163, 184, 0.25);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow-card: 0 24px 60px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.3);
}

html, body {
    min-height: 100%;
    width: 100%;
}

body {
    font-family: 'Cairo', 'Inter', -apple-system, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    direction: rtl;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 14px;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

/* ── Role: Manager ───────────────────────────────────────── */
body.role-manager {
    --bg-page: #0f172a;
    --accent: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.35);
    --btn-grad: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    --accent-bar: linear-gradient(90deg, #8b5cf6, #a855f7, #6366f1);
}

/* ── Role: Subscriber (Portal) ──────────────────────────── */
body.role-subscriber {
    --bg-page: #090d16;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.35);
    --btn-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --accent-bar: linear-gradient(90deg, #06b6d4, #6366f1, #a855f7);
}

/* Light Theme (Portal) */
html[data-theme="light"] body.role-subscriber {
    --bg-page: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-border: rgba(148, 163, 184, 0.3);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-faint: #64748b;
    --input-bg: rgba(248, 250, 252, 0.9);
    --input-border: rgba(148, 163, 184, 0.35);
    --shadow-card: 0 20px 50px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ── Background Animations ───────────────────────────────── */
.reset-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-mesh {
    position: absolute;
    inset: -50%;
    background: radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.18) 0%, transparent 40%),
                radial-gradient(circle at 75% 70%, rgba(139, 92, 246, 0.16) 0%, transparent 45%),
                radial-gradient(circle at 50% 90%, rgba(236, 72, 153, 0.1) 0%, transparent 40%);
    animation: meshShift 18s ease-in-out infinite alternate;
}

body.role-manager .bg-mesh {
    background: radial-gradient(circle at 25% 30%, rgba(139, 92, 246, 0.22) 0%, transparent 50%),
                radial-gradient(circle at 80% 70%, rgba(99, 102, 241, 0.18) 0%, transparent 50%),
                radial-gradient(circle at 50% 90%, rgba(34, 197, 94, 0.1) 0%, transparent 40%);
}

@keyframes meshShift {
    0% { transform: scale(1) rotate(0deg); }
    100% { transform: scale(1.08) rotate(4deg); }
}

.bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

.bg-particles .particle {
    position: absolute;
    border-radius: 50%;
    filter: blur(1px);
    opacity: 0.35;
    animation: floatParticle 12s infinite ease-in-out;
}

.p1 { width: 6px; height: 6px; background: #6366f1; top: 20%; right: 15%; animation-duration: 9s; }
.p2 { width: 8px; height: 8px; background: #8b5cf6; top: 60%; right: 80%; animation-duration: 14s; }
.p3 { width: 5px; height: 5px; background: #38bdf8; top: 80%; right: 30%; animation-duration: 11s; }
.p4 { width: 7px; height: 7px; background: #ec4899; top: 35%; right: 65%; animation-duration: 16s; }
.p5 { width: 6px; height: 6px; background: #22c55e; top: 15%; right: 45%; animation-duration: 13s; }

@keyframes floatParticle {
    0%, 100% { transform: translateY(0) translateX(0); }
    50% { transform: translateY(-24px) translateX(12px); }
}

/* ── Main Card ───────────────────────────────────────────── */
.reset-card {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 420px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    padding: 36px 28px 26px;
    overflow: hidden;
    animation: cardAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.card-accent {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 4px;
    background: var(--accent-bar);
}

/* ── Brand / Header ──────────────────────────────────────── */
.brand-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    gap: 8px;
}

.brand-logo-wrap {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.badge-row {
    display: flex;
    justify-content: center;
}

.badge-role {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(139, 92, 246, 0.14);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 999px;
    padding: 3px 12px;
    font-size: 11.5px;
    font-weight: 600;
}

body.role-subscriber .badge-role {
    background: rgba(99, 102, 241, 0.14);
    color: #a5b4fc;
    border-color: rgba(99, 102, 241, 0.3);
}

/* ── Step Container & Typography ─────────────────────────── */
.screen-step {
    animation: fadeIn 0.3s ease-out;
}

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

.screen-title {
    font-size: 1.35rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.3;
}

.screen-subtitle {
    font-size: 0.92rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 22px;
    line-height: 1.5;
}

/* ── Form & Field Box ────────────────────────────────────── */
.reset-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field-box {
    position: relative;
    display: flex;
    align-items: center;
}

.field-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    z-index: 2;
}

.field-icon svg {
    width: 20px;
    height: 20px;
}

.field-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 14px;
    padding: 15px 44px 15px 16px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.98rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field-input:focus {
    border-color: var(--accent);
    background: rgba(15, 23, 42, 0.85);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.field-input:focus ~ .field-icon {
    color: var(--accent);
}

/* Floating Label */
.field-label {
    position: absolute;
    right: 44px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.92rem;
    color: var(--text-secondary);
    pointer-events: none;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    padding: 0 4px;
    z-index: 1;
}

.field-input:focus ~ .field-label,
.field-input:not(:placeholder-shown) ~ .field-label {
    top: -8px;
    right: 14px;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--card-bg);
    padding: 1px 8px;
    border-radius: 6px;
}

/* Eye Toggle */
.btn-eye {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: color 0.2s ease;
    z-index: 2;
}

.btn-eye:hover {
    color: var(--text-primary);
}

.btn-eye svg {
    width: 19px;
    height: 19px;
}

/* ── 6 Digit Verification Boxes ──────────────────────────── */
.digits-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.digits-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}

.digits-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    direction: ltr;
    margin: 4px 0 6px;
}

.digit-box {
    width: 48px;
    height: 56px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.55rem;
    font-weight: 700;
    text-align: center;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    caret-color: var(--accent);
}

.digit-box:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    transform: translateY(-2px);
    background: rgba(15, 23, 42, 0.9);
}

.digit-box.filled {
    border-color: rgba(99, 102, 241, 0.6);
}

/* ── Resend Code Row ─────────────────────────────────────── */
.resend-row {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 4px;
    font-size: 0.84rem;
    min-height: 28px;
}

.timer-label {
    color: var(--text-faint);
}

.timer-label span {
    font-weight: 700;
    color: var(--text-secondary);
}

.btn-resend {
    background: transparent;
    border: none;
    color: var(--accent);
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.2s ease, background 0.2s ease;
}

.btn-resend:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.12);
}

/* ── Password Strength Bar ───────────────────────────────── */
.strength-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: -6px;
}

.strength-track {
    width: 100%;
    height: 4px;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 999px;
    overflow: hidden;
}

.strength-bar {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    transition: width 0.3s ease, background-color 0.3s ease;
    background: var(--text-faint);
}

.strength-bar.weak { width: 33%; background: var(--danger); }
.strength-bar.medium { width: 66%; background: var(--warning); }
.strength-bar.strong { width: 100%; background: var(--success); }

.strength-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.strength-hint svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.strength-hint.valid {
    color: var(--success);
}

/* ── Info Card (Always shown on Screen B) ────────────────── */
.info-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 18px;
}

.info-card-icon {
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 2px;
}

.info-card-icon svg {
    width: 20px;
    height: 20px;
}

.info-card-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-main {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.info-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ── Error Message Alert ─────────────────────────────────── */
.error-msg {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    padding: 11px 14px;
    border-radius: 12px;
    font-size: 0.88rem;
    text-align: center;
    line-height: 1.4;
    animation: shakeError 0.4s ease;
}

@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* ── Action Buttons ──────────────────────────────────────── */
.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 50px;
    padding: 14px 20px;
    border: none;
    border-radius: 14px;
    background: var(--btn-grad);
    color: #fff;
    font-family: inherit;
    font-size: 1.02rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px var(--accent-glow);
    transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-action:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px var(--accent-glow);
}

.btn-action:active:not(:disabled) {
    transform: translateY(0);
}

.btn-action:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

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

.btn-as-link {
    display: inline-flex;
    margin-top: 8px;
}

/* Loader Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spinLoader 0.7s linear infinite;
    display: inline-block;
}

@keyframes spinLoader {
    to { transform: rotate(360deg); }
}

/* ── Footer Actions ──────────────────────────────────────── */
.footer-action {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    gap: 8px;
}

.link-secondary, .btn-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.88rem;
    text-decoration: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: color 0.2s ease, background 0.2s ease;
}

.link-secondary:hover, .btn-link:hover {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}

.link-secondary svg, .btn-link svg {
    width: 16px;
    height: 16px;
}

/* ── Screen C: Success ───────────────────────────────────── */
.success-wrap {
    position: relative;
    width: 76px;
    height: 76px;
    margin: 10px auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.16);
    border: 2px solid rgba(34, 197, 94, 0.5);
    color: #22c55e;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    animation: scaleUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.success-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.2);
    animation: pulseRing 1.8s infinite ease-out;
}

@keyframes pulseRing {
    0% { transform: scale(0.85); opacity: 0.8; }
    100% { transform: scale(1.4); opacity: 0; }
}

@keyframes scaleUp {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.redirect-counter {
    text-align: center;
    font-size: 0.92rem;
    color: var(--text-secondary);
    margin: 12px 0 20px;
}

.redirect-counter b {
    color: var(--accent);
    font-size: 1.1rem;
}

.btn-action-wrap {
    display: flex;
    justify-content: center;
}

/* ── Mobile 390px Optimizations ──────────────────────────── */
@media (max-width: 400px) {
    body {
        padding: 14px 10px;
    }

    .reset-card {
        padding: 28px 18px 20px;
        border-radius: 18px;
    }

    .screen-title {
        font-size: 1.22rem;
    }

    .screen-subtitle {
        font-size: 0.86rem;
        margin-bottom: 18px;
    }

    .digit-box {
        width: 42px;
        height: 50px;
        font-size: 1.35rem;
    }

    .digits-row {
        gap: 5px;
    }

    .field-input {
        padding: 13px 40px 13px 14px;
        font-size: 0.94rem;
    }

    .field-label {
        font-size: 0.86rem;
    }

    .btn-action {
        min-height: 48px;
        padding: 12px 16px;
        font-size: 0.98rem;
    }
}
