/**
 * Universal Auth Styles
 * Shared styles for the floating auth pill and auth modal
 * Used by: auth-core.js
 */

/* ============================================================================
   Floating Auth Pill Container
   ============================================================================ */

.floating-auth-container {
    position: fixed !important;
    top: 16px !important;
    right: 20px !important;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10100;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease, pointer-events 0s;
}

.floating-auth-container.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================================
   Floating Auth Pill
   ============================================================================ */

.floating-auth-pill {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    background: #fff;
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.floating-auth-pill.visible {
    opacity: 1;
    transform: translateY(0);
}

.floating-auth-pill:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Logged-in state */
.floating-auth-pill.logged-in {
    padding: 4px;
    flex-direction: row;
    border-radius: 25px;
}

/* ============================================================================
   Auth Pill Buttons (Logged Out)
   ============================================================================ */

.auth-pill-btn {
    background: none;
    border: none;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.auth-pill-signup {
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    order: 1;
}

.auth-pill-signup:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.auth-pill-login {
    color: #666;
    border-radius: 12px;
    order: 2;
}

.auth-pill-login:hover {
    color: #333;
    background: #f5f5f5;
}

.auth-pill-divider {
    display: none;
}

/* ============================================================================
   Benefits Tooltip (Logged Out) - Positioned to the right
   ============================================================================ */

.auth-pill-benefits {
    position: absolute;
    top: 0;
    right: calc(100% + 12px);
    left: auto;
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateX(8px);
    transition: all 0.25s ease;
    min-width: 200px;
    z-index: 1017;
    pointer-events: none;
}

/* Only show benefits tooltip on mouse-capable devices */
@media (hover: hover) and (pointer: fine) {
    .floating-auth-pill:hover .auth-pill-benefits {
        opacity: 1;
        visibility: visible;
        transform: translateX(0);
    }
}

.auth-pill-benefits::before {
    content: '';
    position: absolute;
    top: 16px;
    right: -8px;
    left: auto;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid #fff;
}

.auth-pill-benefits h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.auth-pill-benefits ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.auth-pill-benefits li {
    padding: 6px 0;
    font-size: 13px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-pill-benefits li::before {
    content: '✓';
    color: #28a745;
    font-weight: bold;
}

/* ============================================================================
   Avatar and Popover (Logged In)
   ============================================================================ */

.auth-pill-avatar-wrapper {
    position: relative;
}

.auth-pill-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.auth-pill-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ============================================================================
   Avatar Hover Tooltip (Logged In) - Mouse only
   Shows meaningful info on hover (click opens popover)
   ============================================================================ */

.auth-pill-avatar-tooltip {
    position: absolute;
    top: 0;
    right: calc(100% + 12px);
    background: #fff;
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateX(8px);
    transition: all 0.25s ease;
    min-width: 160px;
    z-index: 1016;
    pointer-events: none;
}

.auth-pill-avatar-tooltip::before {
    content: '';
    position: absolute;
    top: 12px;
    right: -8px;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid #fff;
}

.auth-pill-avatar-tooltip p {
    margin: 0;
    font-size: 13px;
    color: #555;
    line-height: 1.4;
}

.auth-pill-avatar-tooltip strong {
    color: #333;
    font-weight: 600;
}

/* Only show tooltip on mouse-capable devices */
@media (hover: hover) and (pointer: fine) {
    .auth-pill-avatar-wrapper:hover .auth-pill-avatar-tooltip {
        opacity: 1;
        visibility: visible;
        transform: translateX(0);
    }
    
    /* Hide tooltip when popover is open */
    .auth-pill-avatar-wrapper:has(.auth-pill-popover.visible) .auth-pill-avatar-tooltip {
        opacity: 0;
        visibility: hidden;
    }
}

.auth-pill-popover {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
    min-width: 240px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.25s ease;
    z-index: 1017;
}

.auth-pill-popover.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.auth-pill-popover::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 12px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #fff;
}

.auth-popover-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.auth-popover-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    flex-shrink: 0;
}

.auth-popover-info {
    flex: 1;
    min-width: 0;
}

.auth-popover-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-popover-username {
    font-size: 13px;
    color: #667eea;
    margin-top: 2px;
}

.auth-popover-email {
    font-size: 12px;
    color: #888;
    margin-bottom: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-popover-divider {
    height: 1px;
    background: #eee;
    margin: 12px 0;
}

.auth-popover-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.auth-popover-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.auth-popover-btn svg {
    flex-shrink: 0;
}

.auth-popover-set-username {
    color: #667eea;
    background: #f0f4ff;
    margin-bottom: 8px;
}

.auth-popover-set-username:hover {
    background: #e0e8ff;
    color: #5a6fd6;
}

.auth-popover-logout {
    color: #dc3545;
}

.auth-popover-logout:hover {
    background: #fff5f5;
    color: #c82333;
}

/* ============================================================================
   Username Validation
   ============================================================================ */

.username-status-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    display: none;
    pointer-events: none;
    z-index: 2;
}

.username-warning-tooltip {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #ffc107;
    color: #333;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    margin-bottom: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 10;
    animation: tooltipFadeIn 0.2s ease;
}

@keyframes tooltipFadeIn {
    from { 
        opacity: 0; 
        transform: translateY(4px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* ============================================================================
   Auth Modal Overrides
   ============================================================================ */

#auth-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#auth-modal {
    background: #fff;
    border-radius: 16px;
    max-width: 420px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

/* ============================================================================
   Responsive Adjustments
   ============================================================================ */

@media (max-width: 480px) {
    .floating-auth-container {
        top: 10px !important;
        right: 10px !important;
        gap: 6px;
    }
    
    .floating-auth-pill {
        padding: 4px 6px;
    }
    
    .auth-pill-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .auth-pill-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .auth-pill-popover {
        min-width: 220px;
        right: -10px;
    }
    
    .auth-pill-benefits {
        min-width: 180px;
        padding: 12px 16px;
    }
    
    .grammar-topics-nav-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
    
    .auth-extra-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
}

/* Hide text on very small screens, show only icons */
@media (max-width: 360px) {
    .grammar-topics-nav-btn span,
    .auth-extra-btn span {
        display: none;
    }
    
    .grammar-topics-nav-btn,
    .auth-extra-btn {
        padding: 8px !important;
        border-radius: 50% !important;
    }
}

/* ============================================================================
   Mobile Z-Index Fixes
   Lower auth pill z-index when modals or search results are shown
   ============================================================================ */

/* When test card modal is open, push auth pill behind */
body.test-card-modal-open .floating-auth-container {
    z-index: 9000 !important;
}

/* On mobile, when search results are shown, push auth pill behind the search bar */
@media (max-width: 991px) {
    .dictionary-search.has-results ~ .floating-auth-container,
    body:has(.dictionary-search.has-results) .floating-auth-container {
        z-index: 999 !important;
    }
}

/* ============================================================================
   Dark Mode Support
   ============================================================================ */

.theme-dark .floating-auth-pill,
body.dark-mode .floating-auth-pill {
    background: #1e1e1e !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

.theme-dark .auth-pill-btn,
body.dark-mode .auth-pill-btn {
    color: #ccc !important;
}

.theme-dark .auth-pill-btn:hover,
body.dark-mode .auth-pill-btn:hover {
    color: #fff !important;
    background: #333 !important;
}

.theme-dark .auth-pill-benefits,
body.dark-mode .auth-pill-benefits {
    background: #1e1e1e !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4) !important;
}

.theme-dark .auth-pill-benefits::before,
body.dark-mode .auth-pill-benefits::before {
    border-left-color: #1e1e1e !important;
}

.theme-dark .auth-pill-benefits h4,
body.dark-mode .auth-pill-benefits h4 {
    color: #fff !important;
}

.theme-dark .auth-pill-benefits li,
body.dark-mode .auth-pill-benefits li {
    color: #ccc !important;
}

/* Dark mode for avatar tooltip */
.theme-dark .auth-pill-avatar-tooltip,
body.dark-mode .auth-pill-avatar-tooltip {
    background: #1e1e1e !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4) !important;
}

.theme-dark .auth-pill-avatar-tooltip::before,
body.dark-mode .auth-pill-avatar-tooltip::before {
    border-left-color: #1e1e1e !important;
}

.theme-dark .auth-pill-avatar-tooltip p,
body.dark-mode .auth-pill-avatar-tooltip p {
    color: #ccc !important;
}

.theme-dark .auth-pill-avatar-tooltip strong,
body.dark-mode .auth-pill-avatar-tooltip strong {
    color: #fff !important;
}

.theme-dark .auth-pill-popover,
body.dark-mode .auth-pill-popover {
    background: #1e1e1e !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4) !important;
}

.theme-dark .auth-pill-popover::before,
body.dark-mode .auth-pill-popover::before {
    border-bottom-color: #1e1e1e !important;
}

.theme-dark .auth-popover-name,
body.dark-mode .auth-popover-name {
    color: #fff !important;
}

.theme-dark .auth-popover-email,
body.dark-mode .auth-popover-email {
    color: #aaa !important;
}

.theme-dark .auth-popover-logout,
body.dark-mode .auth-popover-logout {
    background: #2a2a2a !important;
    color: #ccc !important;
}

.theme-dark .auth-popover-logout:hover,
body.dark-mode .auth-popover-logout:hover {
    background: #ff6b6b !important;
    color: #fff !important;
}
