/* STLFilesHub — Sign in / Create account popup. Matches the site's dark violet design. */

.stlh-auth {
    --a-bg: #0f172a;
    --a-surface: #111a2e;
    --a-field: #0b1222;
    --a-border: #26324a;
    --a-border-strong: #3a4766;
    --a-text: #f1f5f9;
    --a-muted: #94a3b8;
    --a-accent: #7c3aed;
    --a-accent-hover: #6d28d9;
    --a-accent-soft: rgba(124, 58, 237, .18);
    --a-danger: #f87171;
    --a-success: #4ade80;
    --a-radius: 12px;

    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    font-family: inherit;
    color: var(--a-text);
}
.stlh-auth[hidden] { display: none; }

.stlh-auth__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 7, 18, .72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity .18s ease;
}

.stlh-auth__dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #3a4766 transparent;
    box-sizing: border-box;
    padding: 32px 32px 24px;
    background: linear-gradient(180deg, #121c33 0%, var(--a-bg) 100%);
    border: 1px solid var(--a-border);
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 0 0 1px rgba(124, 58, 237, .08), 0 0 40px rgba(124, 58, 237, .12);
    transform: translateY(12px) scale(.98);
    opacity: 0;
    transition: transform .2s ease, opacity .18s ease;
}
.stlh-auth__dialog::-webkit-scrollbar { width: 8px; }
.stlh-auth__dialog::-webkit-scrollbar-thumb { background: #3a4766; border-radius: 8px; }
.stlh-auth__dialog::-webkit-scrollbar-track { background: transparent; }
.stlh-auth.is-visible .stlh-auth__backdrop { opacity: 1; }
.stlh-auth.is-visible .stlh-auth__dialog { transform: none; opacity: 1; }
html.stlh-auth-open { overflow: hidden; }

.stlh-auth *,
.stlh-auth *::before,
.stlh-auth *::after { box-sizing: border-box; }

.stlh-auth__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--a-muted);
    font-size: 18px;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.stlh-auth__close:hover { background: rgba(255, 255, 255, .06); color: var(--a-text); }

.stlh-auth__brand { display: flex; justify-content: center; margin-bottom: 12px; }
.stlh-auth__brand img { height: 40px; width: auto; display: block; }

.stlh-auth__title {
    margin: 0 0 6px;
    text-align: center;
    font-size: 22px;
    line-height: 1.3;
    font-weight: 700;
    color: var(--a-text);
}
.stlh-auth__subtitle {
    margin: 0 0 20px;
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    color: var(--a-muted);
}

/* Tabs */
.stlh-auth__tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin: 0 0 20px;
    background: var(--a-field);
    border: 1px solid var(--a-border);
    border-radius: var(--a-radius);
}
.stlh-auth__tab {
    height: 38px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--a-muted);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.stlh-auth__tab:hover { color: var(--a-text); }
.stlh-auth__tab.is-active { background: var(--a-accent); color: #fff; box-shadow: 0 4px 14px rgba(124, 58, 237, .35); }

/* Notices */
.stlh-auth__notice {
    margin: 0 0 16px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
    border: 1px solid transparent;
}
.stlh-auth__notice[hidden] { display: none; }
.stlh-auth__notice--error { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .35); color: #fecaca; }
.stlh-auth__notice--success { background: rgba(74, 222, 128, .1); border-color: rgba(74, 222, 128, .35); color: #bbf7d0; }
.stlh-auth__notice--info { background: var(--a-accent-soft); border-color: rgba(124, 58, 237, .4); color: #ddd6fe; }

/* Social */
.stlh-auth-social { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.stlh-auth-social-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 46px;
    padding: 0 12px;
    border: 1px solid var(--a-border-strong);
    border-radius: var(--a-radius);
    background: #fff;
    color: #1f2937;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform .12s, box-shadow .15s, background .15s;
}
.stlh-auth-social-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 0, 0, .3); color: #111827; }
.stlh-auth-social-btn--facebook { background: #1877f2; border-color: #1877f2; color: #fff; }
.stlh-auth-social-btn--facebook:hover { background: #166fe0; color: #fff; }
.stlh-auth-social-btn svg { flex: 0 0 auto; }
.stlh-auth-social-btn--facebook svg path:first-child { fill: #fff; }
.stlh-auth-social-btn--facebook svg path:last-child { fill: #1877f2; }

.stlh-auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--a-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.stlh-auth-divider::before,
.stlh-auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--a-border); }

/* Fields */
.stlh-auth__form { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.stlh-field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.stlh-field label { margin: 0; font-size: 13px; font-weight: 600; color: #cbd5e1; }
.stlh-field__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.stlh-auth .stlh-field input[type="text"],
.stlh-auth .stlh-field input[type="email"],
.stlh-auth .stlh-field input[type="password"] {
    display: block;
    width: 100%;
    height: 46px;
    margin: 0;
    padding: 0 14px;
    background: var(--a-field);
    border: 1px solid var(--a-border);
    border-radius: var(--a-radius);
    color: var(--a-text);
    font: inherit;
    font-size: 15px;
    line-height: 46px;
    box-shadow: none;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.stlh-auth .stlh-field input::placeholder { color: #64748b; }
.stlh-auth .stlh-field input:hover { border-color: var(--a-border-strong); }
.stlh-auth .stlh-field input:focus { border-color: var(--a-accent); box-shadow: 0 0 0 3px var(--a-accent-soft); }
.stlh-auth .stlh-field input[aria-invalid="true"] { border-color: var(--a-danger); }

.stlh-field__password { position: relative; }
.stlh-auth .stlh-field__password input { padding-right: 48px; }
.stlh-field__toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    width: 36px;
    height: 36px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--a-muted);
    cursor: pointer;
}
.stlh-field__toggle:hover { color: var(--a-text); background: rgba(255, 255, 255, .05); }

.stlh-field__hint { min-height: 0; font-size: 12px; line-height: 1.4; color: var(--a-muted); }
.stlh-field__hint:empty { display: none; }
.stlh-field__hint.is-error { color: var(--a-danger); }
.stlh-field__hint.is-ok { color: var(--a-success); }

.stlh-strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.stlh-strength span { height: 4px; border-radius: 4px; background: var(--a-border); transition: background .2s; }
.stlh-strength[data-level="1"] span:nth-child(-n+1) { background: #ef4444; }
.stlh-strength[data-level="2"] span:nth-child(-n+2) { background: #f59e0b; }
.stlh-strength[data-level="3"] span:nth-child(-n+3) { background: #22c55e; }
.stlh-strength[data-level="4"] span { background: #16a34a; }

.stlh-check { display: inline-flex; align-items: center; gap: 10px; margin: 0; font-size: 14px; color: #cbd5e1; cursor: pointer; user-select: none; }
.stlh-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--a-accent); cursor: pointer; }

.stlh-auth__link { font-size: 13px; font-weight: 600; color: #a78bfa; text-decoration: none; }
.stlh-auth__link:hover { color: #c4b5fd; text-decoration: underline; }

.stlh-auth__submit {
    position: relative;
    width: 100%;
    height: 48px;
    margin-top: 4px;
    border: 0;
    border-radius: var(--a-radius);
    background: linear-gradient(135deg, #8b5cf6, var(--a-accent));
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(124, 58, 237, .35);
    transition: transform .12s, box-shadow .15s, opacity .15s;
}
.stlh-auth__submit:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(124, 58, 237, .45); }
.stlh-auth__submit:disabled { opacity: .75; cursor: progress; transform: none; }
.stlh-auth__submit.is-loading span { visibility: hidden; }
.stlh-auth__submit.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: stlh-spin .7s linear infinite;
}
@keyframes stlh-spin { to { transform: rotate(360deg); } }

.stlh-auth__legal { margin: 0; font-size: 12px; line-height: 1.5; text-align: center; color: var(--a-muted); }
.stlh-auth__legal a { color: #a78bfa; }

.stlh-auth__switch { margin: 20px 0 0; text-align: center; font-size: 14px; color: var(--a-muted); }
.stlh-auth__switch button { padding: 0; border: 0; background: none; color: #a78bfa; font: inherit; font-weight: 700; cursor: pointer; }
.stlh-auth__switch button:hover { text-decoration: underline; }

.stlh-auth button:focus-visible,
.stlh-auth a:focus-visible,
.stlh-check input:focus-visible { outline: 2px solid #a78bfa; outline-offset: 2px; }

/* Phones: bottom sheet */
@media (max-width: 520px) {
    .stlh-auth { align-items: flex-end; padding: 0; }
    .stlh-auth__dialog {
        max-width: none;
        max-height: 92vh;
        max-height: 92dvh;
        padding: 28px 20px calc(20px + env(safe-area-inset-bottom));
        border-radius: 20px 20px 0 0;
        transform: translateY(24px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .stlh-auth__backdrop, .stlh-auth__dialog, .stlh-auth__submit { transition: none; }
}

button.stlh-auth__link { background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }
html[data-theme="light"] .stlh-auth__link { color: #6d28d9; }
