/* ============================================================
   Финчик — Формы аутентификации (login + register)
   Используется и в модалках на лендинге, и на /login, /register
   ============================================================ */

/* === MODAL OVERLAY === */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 30, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: authFadeIn 0.18s ease;
}
.auth-overlay.active { display: flex; }
@keyframes authFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === CARD === */
.auth-card {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 32px;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 30px 80px rgba(0,0,0,0.30), 0 8px 20px rgba(0,0,0,0.12);
    animation: authSlideIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.auth-card-wide { max-width: 500px; }
@keyframes authSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* === PAGE WRAP (для /login и /register) === */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f5f7 0%, #e8ecf3 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-page .auth-card { animation: none; }

/* === HEADER === */
.auth-head {
    text-align: center;
    margin-bottom: 24px;
}
.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    margin-bottom: 16px;
}
.auth-brand-logo {
    width: 40px; height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--accent) 0%, #5856d6 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    box-shadow: 0 4px 14px rgba(0,122,255,0.25);
}
.auth-brand-name {
    font-weight: 600;
    font-size: 19px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.auth-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}
.auth-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.05);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-secondary);
}
.auth-close:hover {
    background: rgba(0,0,0,0.1);
    color: var(--text-primary);
}
.auth-card { position: relative; }
.auth-card-noclose .auth-close { display: none; }

/* === FORM === */
.auth-form .form-group {
    margin-bottom: 14px;
}
.auth-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.auth-input {
    display: block;
    width: 100%;
    padding: 11px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: #fafafa;
    border: 1px solid var(--border-input);
    border-radius: 10px;
    box-sizing: border-box;
    transition: var(--transition);
}
.auth-input:focus {
    outline: none;
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.auth-input.has-error {
    border-color: var(--danger);
    background: var(--danger-light);
}

/* === PASSWORD WRAP (с кнопкой глаза и генератора) === */
.auth-pwd-wrap {
    position: relative;
}
.auth-pwd-wrap .auth-input {
    padding-right: 78px;  /* место для двух кнопок */
}
.auth-pwd-wrap.single-btn .auth-input {
    padding-right: 44px;  /* только глаз, без генератора */
}
.auth-pwd-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px; height: 32px;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
}
.auth-pwd-btn:hover {
    background: rgba(0,0,0,0.06);
    color: var(--text-primary);
}
.auth-pwd-eye  { right: 6px; }
.auth-pwd-gen  { right: 38px; }
.auth-pwd-wrap.single-btn .auth-pwd-eye { right: 6px; }

/* === PWD label row (label + generate button) === */
.auth-pwd-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 6px;
}
.auth-pwd-label-row .auth-label { margin-bottom: 0; }
.auth-pwd-gen-link {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 11.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
    transition: var(--transition);
}
.auth-pwd-gen-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* === CAPS LOCK WARNING === */
.auth-caps-warn {
    display: none;
    margin-top: 6px;
    padding: 6px 10px;
    background: var(--warning-light);
    color: var(--warning);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}
.auth-caps-warn.show { display: block; }

/* === PASSWORD STRENGTH === */
.auth-strength {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.auth-strength-bars {
    display: flex;
    gap: 4px;
    flex: 1;
}
.auth-strength-bar {
    height: 4px;
    flex: 1;
    background: #e5e5ea;
    border-radius: 2px;
    transition: background 0.2s;
}
.auth-strength-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 56px;
    text-align: right;
}

/* Уровни */
.auth-strength[data-lvl="0"] .auth-strength-bar:nth-child(-n+0) { background: var(--danger); }
.auth-strength[data-lvl="1"] .auth-strength-bar:nth-child(-n+1) { background: var(--danger); }
.auth-strength[data-lvl="2"] .auth-strength-bar:nth-child(-n+2) { background: var(--warning); }
.auth-strength[data-lvl="3"] .auth-strength-bar:nth-child(-n+3) { background: #ffcc00; }
.auth-strength[data-lvl="4"] .auth-strength-bar:nth-child(-n+4) { background: var(--success); }
.auth-strength[data-lvl="1"] .auth-strength-label { color: var(--danger); }
.auth-strength[data-lvl="2"] .auth-strength-label { color: var(--warning); }
.auth-strength[data-lvl="3"] .auth-strength-label { color: #d4a300; }
.auth-strength[data-lvl="4"] .auth-strength-label { color: var(--success); }

/* === HINT (под полями) === */
.auth-hint {
    margin-top: 5px;
    font-size: 11.5px;
    color: var(--text-secondary);
}
.auth-hint.error {
    color: var(--danger);
    font-weight: 500;
}

/* === AGREE === */
.auth-agree {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 14px 0;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.auth-agree input {
    margin-top: 2px;
    accent-color: var(--accent);
    cursor: pointer;
}
.auth-agree a {
    color: var(--accent);
    text-decoration: none;
}
.auth-agree a:hover { text-decoration: underline; }

/* === BUTTON === */
.auth-btn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 6px;
    box-shadow: 0 2px 8px rgba(0,122,255,0.25);
    position: relative;
    min-height: 44px;
}
.auth-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(0,122,255,0.35);
}
.auth-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
.auth-btn .auth-spinner {
    display: none;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: authSpin 0.7s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}
.auth-btn.loading .auth-spinner { display: inline-block; }
.auth-btn.loading .auth-btn-label { opacity: 0.85; }
@keyframes authSpin {
    to { transform: rotate(360deg); }
}

/* === ERROR === */
.auth-error {
    display: none;
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--danger-light);
    color: var(--danger);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.45;
}
.auth-error.show { display: block; }

/* === FOOTER (Уже есть аккаунт / Нет аккаунта) === */
.auth-foot {
    text-align: center;
    margin-top: 18px;
    font-size: 13px;
    color: var(--text-secondary);
}
.auth-foot a {
    color: var(--accent);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}
.auth-foot a:hover { text-decoration: underline; }

/* === Сетка для two-column полей === */
.auth-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 480px) {
    .auth-grid-2 { grid-template-columns: 1fr; gap: 0; }
    .auth-card { padding: 24px; }
}
