/**
 * lib-auth - Login page + Security settings panel
 * @author Emmanuel Daunizeau / ACME
 * @copyright 2026 All rights reserved
 * @version 1.0.0
 *
 * CSS custom properties (all with double fallback to parent theme):
 *
 *   --auth-bg, --auth-border, --auth-text, --auth-text-muted,
 *   --auth-accent, --auth-input-bg, --auth-input-border,
 *   --auth-error-bg, --auth-error-fg, --auth-error-border,
 *   --auth-success-bg, --auth-success-fg, --auth-success-border,
 *   --auth-shadow, --auth-radius, --auth-font
 */

/* ================================================================
   LOGIN PAGE
   ================================================================ */

.auth-login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    font-family: var(--auth-font, inherit);
}

.auth-login-card {
    width: 100%;
    max-width: 420px;
    background: var(--auth-bg, var(--card-bg, #16213e));
    border: 1px solid var(--auth-border, var(--border, #0f3460));
    border-radius: var(--auth-radius, 12px);
    padding: 32px 28px 28px;
    box-shadow: var(--auth-shadow, 0 16px 48px rgba(0,0,0,0.35));
    animation: auth-fade-in 0.4s ease;
}

.auth-login-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 28px;
    text-align: center;
}

.auth-login-icon {
    color: var(--auth-accent, var(--accent, #e94560));
    margin-bottom: 12px;
}

.auth-login-icon svg {
    width: 40px;
    height: 40px;
}

.auth-login-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--auth-accent, var(--accent, #e94560));
    margin: 0 0 4px 0;
    letter-spacing: 0.5px;
}

.auth-login-subtitle {
    font-size: 14px;
    color: var(--auth-text-muted, var(--text-muted, #888));
    margin: 0;
}

/* ---- Login fields ---- */

.auth-field {
    margin-bottom: 18px;
}

.auth-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--auth-text-muted, var(--text-muted, #888));
}

.auth-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background: var(--auth-input-bg, var(--input-bg, #0f3460));
    border: 1px solid var(--auth-input-border, var(--input-border, #1a3a6e));
    border-radius: 6px;
    color: var(--auth-text, var(--text, #e0e0e0));
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.auth-input:focus {
    outline: none;
    border-color: var(--auth-accent, var(--accent, #e94560));
}

.auth-input::placeholder {
    color: var(--auth-text-muted, var(--text-muted, #888));
    opacity: 0.6;
}

.auth-input-totp {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 20px;
    letter-spacing: 6px;
    text-align: center;
    padding: 0 20px;
}

/* ---- Password field with toggle ---- */

.auth-input-wrap {
    position: relative;
}

.auth-input-wrap .auth-input {
    padding-right: 44px;
}

.auth-password-toggle {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 42px;
    background: none;
    border: none;
    border-radius: 0 5px 5px 0;
    color: var(--auth-text-muted, var(--text-muted, #888));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
    font-size: 18px;
    padding: 0;
}

.auth-password-toggle:hover {
    color: var(--auth-accent, var(--accent, #e94560));
}

/* ---- Submit button ---- */

.auth-submit {
    width: 100%;
    height: 44px;
    border: none;
    border-radius: 6px;
    background: var(--auth-accent, var(--accent, #e94560));
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
    margin-top: 4px;
}

.auth-submit:hover {
    filter: brightness(1.1);
}

.auth-submit:active {
    transform: scale(0.985);
}

/* ---- Error banner ---- */

.auth-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 13px;
    line-height: 1.45;
    background: var(--auth-error-bg, var(--toast-error-bg, #4a0d0d));
    color: var(--auth-error-fg, var(--toast-error-fg, #e94560));
    border: 1px solid var(--auth-error-border, var(--toast-error-border, #6e1a1a));
    animation: auth-shake 0.35s ease;
}

.auth-error-icon {
    flex-shrink: 0;
    font-size: 16px;
    margin-top: 1px;
}

/* ---- Hint ---- */

.auth-hint {
    text-align: center;
    color: var(--auth-text-muted, var(--text-muted, #888));
    font-size: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--auth-border, var(--border, #0f3460));
}

/* ================================================================
   SECURITY SETTINGS PANEL
   ================================================================ */

.auth-settings {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ---- TOTP Enroll card ---- */

.auth-totp-enroll {
    padding: 20px;
    border-radius: var(--auth-radius, 12px);
    border: 1px solid var(--auth-success-border, var(--toast-success-border, #1a6e4a));
    background: var(--auth-success-bg, var(--toast-success-bg, #0d4a3a));
    color: var(--auth-success-fg, var(--toast-success-fg, #4ecca3));
}

.auth-totp-enroll-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 14px;
}

.auth-totp-enroll-body {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.auth-totp-qr {
    border-radius: 8px;
    border: 1px solid var(--auth-border, var(--border, #0f3460));
    background: #fff;
    padding: 6px;
}

.auth-totp-details {
    flex: 1;
    min-width: 200px;
    font-size: 13px;
}

.auth-totp-details code {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
    font-size: 12px;
    word-break: break-all;
}

/* ---- Settings section card ---- */

.auth-section {
    background: var(--auth-bg, var(--card-bg, #16213e));
    border: 1px solid var(--auth-border, var(--border, #0f3460));
    border-radius: var(--auth-radius, 12px);
    padding: 20px 24px;
}

.auth-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--auth-border, var(--border, #0f3460));
}

.auth-section-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(233, 69, 96, 0.12);
    color: var(--auth-accent, var(--accent, #e94560));
}

.auth-section-icon svg {
    width: 18px;
    height: 18px;
}

.auth-section-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--auth-text, var(--heading, #fff));
}

.auth-section-desc {
    margin: 0;
    font-size: 12px;
    color: var(--auth-text-muted, var(--text-muted, #888));
}

/* ---- Session timeout (compact inline) ---- */

.auth-session-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.auth-session-row .auth-input {
    width: 80px;
    height: 36px;
    text-align: center;
    font-size: 14px;
}

.auth-session-hint {
    color: var(--auth-text-muted, var(--text-muted, #888));
    font-size: 12px;
    margin-top: 10px;
}

/* ---- Credentials form grid ---- */

.auth-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.auth-form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--auth-text-muted, var(--text-muted, #888));
}

.auth-form-input {
    height: 40px;
    padding: 0 12px;
    background: var(--auth-input-bg, var(--input-bg, #0f3460));
    border: 1px solid var(--auth-input-border, var(--input-border, #1a3a6e));
    border-radius: 6px;
    color: var(--auth-text, var(--text, #e0e0e0));
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.auth-form-input:focus {
    outline: none;
    border-color: var(--auth-accent, var(--accent, #e94560));
}

.auth-form-hint {
    font-size: 11px;
    color: var(--auth-text-muted, var(--text-muted, #888));
}

.auth-form-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-form-row .auth-form-input {
    flex: 1;
}

/* ---- Action buttons ---- */

.auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.auth-btn-accent {
    background: var(--auth-accent, var(--accent, #e94560));
    color: #fff;
}

.auth-btn-accent:hover {
    filter: brightness(1.1);
}

.auth-btn-danger {
    background: #8b0000;
    color: #fff;
    width: 100%;
    height: 42px;
    font-size: 14px;
    margin-top: 8px;
}

.auth-btn-danger:hover {
    background: #a00000;
}

.auth-btn-warning {
    background: #f9a825;
    color: #1a1a2e;
}

.auth-btn-warning:hover {
    background: #e09620;
}

.auth-btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

/* ================================================================
   ANIMATIONS
   ================================================================ */

@keyframes auth-fade-in {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes auth-shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(5px); }
    60%      { transform: translateX(-3px); }
    80%      { transform: translateX(2px); }
}
