/* ============================================================
   LOGIN SYSTEM — login.css
   BlackSubnet CDN | Telegram OTP Login Modal + Profile Widget
   ============================================================ */

/* ── Login Overlay ─────────────────────────────────────────── */
#loginOverlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(9, 9, 11, 0.92);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}
#loginOverlay.active {
    opacity: 1;
    pointer-events: all;
}

/* ── Login Card ─────────────────────────────────────────────── */
.login-card {
    background: linear-gradient(145deg, #111114, #18181c);
    border: 1px solid rgba(108, 99, 255, 0.25);
    border-radius: 20px;
    padding: 44px 40px 36px;
    width: 440px;
    max-width: 94vw;
    box-shadow:
        0 0 0 1px rgba(108,99,255,0.08),
        0 24px 80px rgba(0, 0, 0, 0.7),
        0 0 80px rgba(108, 99, 255, 0.08) inset;
    position: relative;
    overflow: hidden;
    animation: cardIn 0.45s cubic-bezier(.34,1.56,.64,1) both;
}

.login-card::before {
    content: '';
    position: absolute;
    top: -1px; left: 10%; right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #6c63ff, #22d3ee, transparent);
    opacity: 0.7;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(32px) scale(0.96); }
    to   { opacity: 1; transform: none; }
}

/* ── Brand mark ─────────────────────────────────────────────── */
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}
.login-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(108,99,255,0.2), rgba(34,211,238,0.1));
    border: 1px solid rgba(108,99,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    animation: iconPulse 3s ease-in-out infinite;
}
@keyframes iconPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(108,99,255,0.4); }
    50%       { box-shadow: 0 0 0 8px rgba(108,99,255,0); }
}
.login-brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #e4e4e7;
}
.login-brand-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6rem;
    color: #52525b;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 2px;
}

/* ── Steps container ────────────────────────────────────────── */
.login-steps {
    position: relative;
    overflow: hidden;
}
.login-step {
    transition: transform 0.4s cubic-bezier(.77,0,.18,1), opacity 0.3s ease;
}
.login-step.hidden {
    display: none;
}

/* ── Step heading ───────────────────────────────────────────── */
.login-step-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #e4e4e7;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}
.login-step-sub {
    font-size: 0.8rem;
    color: #71717a;
    margin-bottom: 28px;
    line-height: 1.5;
}
.login-step-sub a {
    color: #6c63ff;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}
.login-step-sub a:hover { color: #9d98ff; text-decoration: underline; }

/* ── Input group ────────────────────────────────────────────── */
.login-input-group {
    margin-bottom: 20px;
}
.login-label {
    display: block;
    font-size: 0.73rem;
    font-weight: 600;
    color: #a1a1aa;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}
.login-input {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 13px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    color: #e4e4e7;
    letter-spacing: 0.04em;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-input:focus {
    border-color: #6c63ff;
    box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}
.login-input::placeholder { color: #52525b; }
.login-input.error {
    border-color: #f43f5e;
    animation: shake 0.4s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

/* ── Telegram ID hint pill ──────────────────────────────────── */
.tg-bot-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(34,211,238,0.06);
    border: 1px solid rgba(34,211,238,0.2);
    margin-bottom: 24px;
    font-size: 0.78rem;
    color: #a1a1aa;
    width: 100%;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.tg-bot-link:hover {
    background: rgba(34,211,238,0.1);
    border-color: rgba(34,211,238,0.35);
    color: #e4e4e7;
}
.tg-bot-link svg { flex-shrink: 0; color: #22d3ee; }

/* ── Submit button ──────────────────────────────────────────── */
.login-btn {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #6c63ff, #4f46e5);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: -0.01em;
    transition: opacity 0.15s, transform 0.15s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(108,99,255,0.35);
}
.login-btn:hover:not(:disabled) {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(108,99,255,0.4);
}
.login-btn:active:not(:disabled) { transform: translateY(0); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.login-btn.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
    from { background-position: -200% 0; }
    to   { background-position: 200% 0; }
}

/* ── OTP Input Row ──────────────────────────────────────────── */
.otp-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 24px;
}
.otp-digit {
    width: 52px;
    height: 58px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: #e4e4e7;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    caret-color: #6c63ff;
}
.otp-digit:focus {
    border-color: #6c63ff;
    box-shadow: 0 0 0 3px rgba(108,99,255,0.18);
    transform: translateY(-2px);
}
.otp-digit.filled { border-color: rgba(108,99,255,0.5); }
.otp-digit.error-digit {
    border-color: #f43f5e;
    animation: shake 0.4s ease;
}

/* ── Countdown ring ─────────────────────────────────────────── */
.countdown-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 24px;
}
.countdown-ring {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
}
.countdown-ring .ring-bg {
    fill: none;
    stroke: rgba(255,255,255,0.06);
    stroke-width: 4;
}
.countdown-ring .ring-fg {
    fill: none;
    stroke: #6c63ff;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 138.23; /* 2π × 22 */
    stroke-dashoffset: 0;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke 0.3s ease;
}
.countdown-ring .ring-fg.urgent { stroke: #f59e0b; }
.countdown-ring .ring-fg.expired { stroke: #f43f5e; }
.countdown-text-wrap { text-align: left; }
.countdown-secs {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: #e4e4e7;
    line-height: 1;
}
.countdown-label { font-size: 0.73rem; color: #52525b; margin-top: 2px; }

/* ── Error message ──────────────────────────────────────────── */
.login-error {
    font-size: 0.78rem;
    color: #f43f5e;
    text-align: center;
    min-height: 20px;
    margin-bottom: 8px;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Back link ──────────────────────────────────────────────── */
.login-back {
    text-align: center;
    margin-top: 14px;
    font-size: 0.75rem;
    color: #52525b;
    cursor: pointer;
    transition: color 0.15s;
}
.login-back:hover { color: #a1a1aa; }

/* ── Step indicator ─────────────────────────────────────────── */
.login-step-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 28px;
}
.step-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #27272a;
    transition: background 0.3s, transform 0.3s;
}
.step-dot.active { background: #6c63ff; transform: scale(1.4); }
.step-dot.done   { background: #10b981; }
.step-line {
    flex: 1;
    height: 1px;
    background: #27272a;
    transition: background 0.3s;
}
.step-line.done { background: #10b981; }

/* ── User Avatar (header) ───────────────────────────────────── */
#userAvatarBtn {
    display: none;
    align-items: center;
    gap: 9px;
    padding: 5px 10px 5px 5px;
    border-radius: 30px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    position: relative;
}
#userAvatarBtn.visible { display: flex; }
#userAvatarBtn:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(108,99,255,0.35);
}
.user-avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(108,99,255,0.5);
}
.user-avatar-initials {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c63ff, #22d3ee);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
}
.user-avatar-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e4e4e7;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    position: absolute;
    bottom: 6px;
    left: 26px;
    border: 1.5px solid #09090b;
}

/* ── Profile Popup ──────────────────────────────────────────── */
#profilePopup {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 260px;
    background: #111114;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    z-index: 9000;
    overflow: hidden;
    animation: popupIn 0.2s cubic-bezier(.34,1.56,.64,1) both;
}
#profilePopup.open { display: block; }
@keyframes popupIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}
.profile-popup-header {
    padding: 20px 18px 16px;
    background: linear-gradient(145deg, rgba(108,99,255,0.1), rgba(34,211,238,0.04));
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    gap: 12px;
}
.profile-popup-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(108,99,255,0.5);
    flex-shrink: 0;
}
.profile-popup-avatar-init {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c63ff, #22d3ee);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.profile-popup-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #e4e4e7;
    word-break: break-all;
}
.profile-popup-username {
    font-size: 0.72rem;
    color: #52525b;
    margin-top: 2px;
}
.profile-popup-rows { padding: 12px 18px; }
.profile-popup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 0.75rem;
}
.profile-popup-row:last-of-type { border-bottom: none; }
.profile-popup-key {
    color: #52525b;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.profile-popup-val { color: #a1a1aa; font-size: 0.78rem; }
.profile-popup-footer { padding: 10px 18px 14px; }
.logout-btn {
    width: 100%;
    padding: 9px;
    border-radius: 8px;
    border: 1px solid rgba(244,63,94,0.25);
    background: rgba(244,63,94,0.07);
    color: #f43f5e;
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.logout-btn:hover {
    background: rgba(244,63,94,0.14);
    border-color: rgba(244,63,94,0.4);
}
