/* ============================================
   BIBLIA AUTH - Login, Wizard & User Menu
   ============================================ */

/* === AUTH OVERLAY (Login Screen) === */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 16px;
}
.auth-overlay.visible { opacity: 1; }

.auth-modal {
    background: var(--bg-secondary, #fff);
    border-radius: 20px;
    padding: 40px 32px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}
.auth-overlay.visible .auth-modal { transform: translateY(0); }

.auth-logo { font-size: 56px; margin-bottom: 12px; }

.auth-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #333);
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary, #666);
    margin-bottom: 28px;
    line-height: 1.5;
}

.auth-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 24px;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    background: var(--bg-secondary, #fff);
    color: var(--text-primary, #333);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.auth-google-btn:hover {
    border-color: #4285f4;
    background: rgba(66,133,244,0.05);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66,133,244,0.2);
}
.auth-google-btn:active { transform: translateY(0); }

.auth-google-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.auth-google-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

/* Divider */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-tertiary, #999);
    font-size: 13px;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color, #e0e0e0);
}

/* Email form */
.auth-email-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.auth-email-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    background: var(--bg-primary, #f5f5f5);
    color: var(--text-primary, #333);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.auth-email-input:focus {
    border-color: var(--accent-primary, #667eea);
}
.auth-email-input::placeholder {
    color: var(--text-tertiary, #999);
}
.auth-email-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    background: var(--accent-primary, #667eea);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.auth-email-btn:hover {
    background: var(--accent-hover, #5a6fd6);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}
.auth-email-btn:active { transform: translateY(0); }
.auth-email-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}
.auth-email-toggle {
    background: none;
    border: none;
    color: var(--text-secondary, #666);
    font-size: 13px;
    cursor: pointer;
    padding: 4px;
}
.auth-email-toggle strong {
    color: var(--accent-primary, #667eea);
}
.auth-email-toggle:hover strong {
    text-decoration: underline;
}

.auth-note {
    font-size: 12px;
    color: var(--text-tertiary, #999);
    margin-top: 16px;
    line-height: 1.4;
}

.auth-error {
    color: #e74c3c;
    font-size: 13px;
    margin-top: 12px;
    display: none;
}
.auth-error.visible { display: block; }

/* === Spinner === */
.auth-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(66,133,244,0.3);
    border-top-color: #4285f4;
    border-radius: 50%;
    animation: authSpin 0.6s linear infinite;
}
@keyframes authSpin { to { transform: rotate(360deg); } }

/* === USER BUTTON (Header) === */
#authContainer {
    position: relative;
}
.user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border: none;
    border-radius: 20px;
    background: transparent;
    color: var(--text-primary, #333);
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
    font-size: 13px;
}
.user-btn:hover { background: var(--bg-hover, #f0f0f0); }

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-primary, #667eea);
}

.user-name {
    font-weight: 600;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === USER DROPDOWN === */
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-secondary, #fff);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    border: 1px solid var(--border-color, #e0e0e0);
    min-width: 260px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}
.user-dropdown.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.user-dropdown-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.user-dropdown-info {
    overflow: hidden;
}

.user-dropdown-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-email {
    font-size: 12px;
    color: var(--text-tertiary, #999);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border-light, #f0f0f0);
    margin: 4px 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text-primary, #333);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}
.user-dropdown-item:hover { background: var(--bg-hover, #f0f0f0); }

.user-dropdown-item.danger { color: #e74c3c; }
.user-dropdown-item.danger:hover { background: rgba(231,76,60,0.08); }

/* === WIZARD OVERLAY === */
.wizard-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 16px;
}
.wizard-overlay.visible { opacity: 1; pointer-events: all; }

.wizard-modal {
    background: var(--bg-secondary, #fff);
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0,0,0,0.3);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}
.wizard-overlay.visible .wizard-modal { transform: translateY(0); }

/* Stepper */
.wizard-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 24px 0;
}

.wizard-step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-color, #e0e0e0);
    transition: all 0.3s ease;
}
.wizard-step-dot.active {
    width: 28px;
    border-radius: 5px;
    background: var(--accent-primary, #667eea);
}
.wizard-step-dot.done { background: var(--success-color, #27ae60); }

/* Step Content */
.wizard-step-content {
    padding: 24px 28px 28px;
    display: none;
}
.wizard-step-content.active { display: block; }

.wizard-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary, #333);
    margin-bottom: 12px;
}

.wizard-text {
    font-size: 14px;
    color: var(--text-secondary, #666);
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Feature list (step 1) */
.wizard-features {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
}
.wizard-features li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-primary, #333);
    line-height: 1.4;
}
.wizard-features li span.check {
    color: var(--success-color, #27ae60);
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Highlight box */
.wizard-highlight-box {
    background: var(--accent-light, rgba(102,126,234,0.08));
    border: 1px solid var(--accent-border, rgba(102,126,234,0.3));
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    color: var(--text-primary, #333);
    line-height: 1.5;
}
.wizard-highlight-box .box-icon { font-size: 24px; flex-shrink: 0; }

/* Instruction list */
.wizard-instructions {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
    counter-reset: step;
}
.wizard-instructions li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    font-size: 14px;
    color: var(--text-primary, #333);
    line-height: 1.4;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}
.wizard-instructions li:last-child { border-bottom: none; }
.wizard-instructions li .step-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

/* Checkbox */
.wizard-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary, #333);
}
.wizard-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-primary, #667eea);
    cursor: pointer;
}

/* Key input */
.wizard-key-input-wrapper {
    position: relative;
    margin: 16px 0;
}
.wizard-key-input {
    width: 100%;
    padding: 14px 48px 14px 16px;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    background: var(--bg-primary, #f5f5f5);
    color: var(--text-primary, #333);
    font-size: 14px;
    font-family: monospace;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.wizard-key-input:focus { border-color: var(--accent-primary, #667eea); }
.wizard-key-input::placeholder { color: var(--text-tertiary, #999); }

.wizard-key-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    color: var(--text-tertiary, #999);
}

/* Buttons */
.wizard-btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    background: var(--accent-primary, #667eea);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.wizard-btn-primary:hover {
    background: var(--accent-hover, #5a6fd6);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}
.wizard-btn-primary:active { transform: translateY(0); }
.wizard-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.wizard-btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 24px;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    background: transparent;
    color: var(--text-primary, #333);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 12px;
}
.wizard-btn-secondary:hover {
    border-color: var(--accent-primary, #667eea);
    color: var(--accent-primary, #667eea);
}

.wizard-btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    background: var(--bg-primary, #f5f5f5);
    color: var(--text-secondary, #666);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    margin-left: 6px;
}
.wizard-btn-copy:hover {
    background: var(--accent-light, rgba(102,126,234,0.08));
    border-color: var(--accent-primary, #667eea);
    color: var(--accent-primary, #667eea);
}

/* Wizard error */
.wizard-error {
    background: rgba(231,76,60,0.08);
    border: 1px solid rgba(231,76,60,0.3);
    border-radius: 10px;
    padding: 12px 16px;
    color: #c0392b;
    font-size: 13px;
    margin-top: 12px;
    display: none;
}
.wizard-error.visible { display: block; }

/* Wizard warning */
.wizard-warning {
    background: rgba(243,156,18,0.08);
    border: 1px solid rgba(243,156,18,0.3);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    margin-top: 12px;
    display: none;
}
.wizard-warning.visible { display: flex; flex-direction: column; gap: 8px; }

/* Step 4 - Success */
.wizard-success-check {
    font-size: 64px;
    text-align: center;
    margin-bottom: 12px;
    animation: wizardPop 0.5s cubic-bezier(0.175,0.885,0.32,1.275);
}
@keyframes wizardPop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.wizard-status-box {
    background: var(--bg-primary, #f5f5f5);
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
}
.wizard-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 14px;
    color: var(--text-primary, #333);
}

.wizard-usage-note {
    font-size: 13px;
    color: var(--text-secondary, #666);
    line-height: 1.5;
    margin: 16px 0;
    padding: 12px;
    background: var(--accent-light, rgba(102,126,234,0.08));
    border-radius: 10px;
}

/* === API KEY PANEL (from header dropdown) === */
.key-panel-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    padding: 16px;
}
.key-panel-overlay.visible { opacity: 1; pointer-events: all; }

.key-panel {
    background: var(--bg-secondary, #fff);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.key-panel-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary, #333);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.key-panel-current {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-primary, #f5f5f5);
    border-radius: 10px;
    font-family: monospace;
    font-size: 14px;
    color: var(--text-primary, #333);
    margin-bottom: 12px;
}

.key-panel-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.key-panel-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 10px;
    background: transparent;
    color: var(--text-primary, #333);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.key-panel-btn:hover {
    background: var(--bg-hover, #f0f0f0);
    border-color: var(--accent-primary, #667eea);
}

.key-panel-note {
    font-size: 12px;
    color: var(--text-tertiary, #999);
    margin-top: 12px;
    line-height: 1.4;
}

.key-panel-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-tertiary, #999);
    cursor: pointer;
    padding: 4px;
}

/* === RESPONSIVE === */
@media (max-width: 600px) {
    .auth-modal {
        padding: 28px 20px;
        border-radius: 16px;
    }

    .wizard-modal {
        max-height: 100vh;
        border-radius: 0;
        height: 100%;
    }
    .wizard-overlay { padding: 0; }

    .wizard-step-content { padding: 20px; }

    .user-name { display: none; }

    .user-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        min-width: unset;
    }
}

/* === DARK MODE ADJUSTMENTS === */
[data-theme="dark"] .auth-google-btn {
    border-color: rgba(255,255,255,0.15);
    color: var(--text-primary);
}
[data-theme="dark"] .auth-google-btn:hover {
    border-color: #4285f4;
    background: rgba(66,133,244,0.1);
}
