/**
 * Unified Authentication Styles for Maths Vault Games
 */

:root {
    --auth-primary: #C90C0F;
    --auth-primary-hover: #a00a0c;
    --auth-secondary: #FAB719;
    --auth-bg: #f8fafc;
    --auth-surface: #FFFFFF;
    --auth-border: #e2e8f0;
    --auth-text: #1D1D1B;
    --auth-text-light: #64748b;
    --auth-error: #ef4444;
    --auth-success: #10b981;
    --auth-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --auth-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Login Screen */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.login-poster-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    filter: blur(3px);
    opacity: 0.3;
}

.login-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
}

.login-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 450px;
    padding: 2rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
    color: white;
}

.login-logo h1 {
    font-size: 3rem;
    margin: 0;
    font-weight: 700;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.login-tagline {
    font-size: 1.125rem;
    margin: 0.5rem 0 0;
    opacity: 0.9;
}

.login-box {
    background: var(--auth-surface);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--auth-shadow-lg);
}

.login-box h2 {
    color: var(--auth-primary);
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

/* Forms */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    color: var(--auth-text);
    font-size: 0.875rem;
}

.form-group input {
    padding: 0.75rem;
    border: 2px solid var(--auth-border);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.form-group input:focus {
    outline: none;
    border-color: var(--auth-primary);
}

.error-message {
    color: var(--auth-error);
    font-size: 0.875rem;
    margin: 0;
    min-height: 1.25rem;
}

.success-message {
    color: var(--auth-success);
    font-size: 0.875rem;
    margin: 0;
    min-height: 1.25rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: var(--auth-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--auth-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--auth-shadow);
}

.btn-secondary {
    background: var(--auth-secondary);
    color: var(--auth-text);
}

.btn-secondary:hover {
    background: #f59e0b;
    transform: translateY(-2px);
    box-shadow: var(--auth-shadow);
}

.btn-block {
    width: 100%;
}

.btn-link {
    background: none;
    border: none;
    color: var(--auth-primary);
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.5rem;
    text-decoration: underline;
    font-family: inherit;
}

.btn-link:hover {
    color: var(--auth-primary-hover);
}

/* Auth Toggle */
.auth-toggle {
    text-align: center;
    margin-top: 1rem;
}

/* Guest Option */
.guest-option {
    margin-top: 1.5rem;
}

.guest-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1rem 0;
    color: var(--auth-text-light);
}

.guest-divider::before,
.guest-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--auth-border);
}

.guest-divider span {
    padding: 0 1rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.guest-note {
    text-align: center;
    font-size: 0.75rem;
    color: var(--auth-text-light);
    margin: 0.5rem 0 0;
}

/* User Display (for logged-in state) */
.user-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--auth-surface);
    border-radius: 0.5rem;
    border: 2px solid var(--auth-border);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--auth-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.125rem;
}

.user-info {
    flex: 1;
}

.user-display-name {
    font-weight: 600;
    color: var(--auth-text);
    margin: 0;
    font-size: 0.875rem;
}

.user-stats {
    font-size: 0.75rem;
    color: var(--auth-text-light);
    margin: 0;
}

/* Profile Modal */
.profile-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.profile-modal.hidden {
    display: none;
}

.profile-modal-content {
    background: var(--auth-surface);
    border-radius: 1rem;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    max-height: 85vh;
    box-shadow: var(--auth-shadow-lg);
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    scroll-behavior: smooth;
}

/* Close button in corner of profile modal */
.profile-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--auth-text-light);
    cursor: pointer;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    z-index: 10;
}

.profile-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--auth-primary);
    transform: rotate(90deg);
}

/* Webkit scrollbar styling for profile modal */
.profile-modal-content::-webkit-scrollbar {
    width: 8px;
}

.profile-modal-content::-webkit-scrollbar-track {
    background: var(--auth-bg);
    border-radius: 4px;
}

.profile-modal-content::-webkit-scrollbar-thumb {
    background: var(--auth-border);
    border-radius: 4px;
}

.profile-modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--auth-text-light);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--auth-border);
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--auth-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 2rem;
}

.profile-info h2 {
    margin: 0;
    color: var(--auth-primary);
    font-size: 1.5rem;
}

.profile-username {
    color: var(--auth-text-light);
    font-size: 0.875rem;
    margin: 0.25rem 0 0;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--auth-bg);
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--auth-primary);
    margin: 0;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--auth-text-light);
    margin: 0.25rem 0 0;
}

.profile-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge-container {
    margin-top: 1rem;
    padding-top: 1rem;
    padding-bottom: 1.5rem;
    border-top: 2px solid var(--auth-border);
    overflow: visible;
}

.badge-container.collapsible-section {
    padding-bottom: 1rem; /* Reduce padding when collapsible */
}

.badge-container h3 {
    font-size: 1rem;
    margin: 0 0 1rem;
    color: var(--auth-text);
}

/* Collapsible sections */
.collapsible-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--auth-border);
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 0;
    transition: color 0.3s ease;
}

.collapsible-header:hover {
    color: var(--auth-primary);
}

.collapsible-icon {
    transition: transform 0.3s ease;
    font-size: 0.875rem;
}

.collapsible-header.open .collapsible-icon {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.collapsible-content.open {
    max-height: 2000px;
    opacity: 1;
    padding-top: 1rem;
}

/* New larger badge grid for profile */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 1rem;
    justify-items: center;
    overflow: visible;
}

.badge-group {
    margin-bottom: 1.75rem;
}

.badge-group:last-child {
    margin-bottom: 0;
}

.badge-group-title {
    margin: 0 0 0.85rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--auth-text-light);
}

.badge-large {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--auth-bg-light);
    border: 2px solid var(--auth-border);
    border-radius: 12px;
    transition: all 0.3s;
    cursor: pointer;
    z-index: 1;
}

.badge-large:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    border-color: #FAB719;
    z-index: 100000;
}

.badge-large::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: pre-line;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 999999;
    min-width: 150px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.badge-large:hover::after {
    opacity: 1;
}

.badge-icon-large {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.badge-icon-fallback-large {
    font-size: 2.5rem;
}

/* Legacy badge list styling */
.badges-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--auth-secondary);
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--auth-text);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: help;
}

.badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.badge-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.badge-icon-fallback {
    font-size: 1.25rem;
}

.badge-name {
    white-space: nowrap;
}

/* Compact badges for header display */
.user-badges-compact {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    margin-right: 0.75rem;
}

.badge-compact {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    transition: all 0.2s;
    cursor: pointer;
}

.badge-compact:hover {
    transform: translateY(-2px) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: #FAB719;
    z-index: 10;
}

.badge-icon-compact {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.badge-icon-fallback-compact {
    font-size: 1.1rem;
}

.badge-more {
    font-size: 0.75rem;
    color: #666;
    font-weight: bold;
    padding: 0.25rem 0.5rem;
    background: #f8f9fa;
    border-radius: 12px;
}

.no-badges {
    color: var(--auth-text-light);
    font-size: 0.875rem;
    font-style: italic;
}

/* Badge Progress */
.badge-progress-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.badge-progress-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.badge-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.badge-progress-name {
    font-weight: 600;
    color: var(--auth-text);
}

.badge-progress-text {
    font-size: 0.75rem;
    color: var(--auth-text-light);
}

.badge-progress-bar-container {
    height: 8px;
    background: var(--auth-border);
    border-radius: 4px;
    overflow: hidden;
}

.badge-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--auth-primary), var(--auth-secondary));
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Badge Toast Notifications */
.badge-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.badge-toast {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 16px;
    min-width: 320px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

.badge-toast.show {
    transform: translateX(0);
    opacity: 1;
    animation: badge-bounce 0.6s ease-out;
}

@keyframes badge-bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0) translateX(0);
    }
    40% {
        transform: translateY(-20px) translateX(0);
    }
    60% {
        transform: translateY(-10px) translateX(0);
    }
}

.badge-toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge-toast-icon {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    animation: badge-spin 0.8s ease-out;
}

@keyframes badge-spin {
    0% {
        transform: rotate(-180deg) scale(0);
    }
    50% {
        transform: rotate(20deg) scale(1.1);
    }
    100% {
        transform: rotate(0deg) scale(1);
    }
}

.badge-toast-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.badge-toast-text {
    flex: 1;
    color: white;
}

.badge-toast-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.badge-toast-name {
    font-size: 18px;
    font-weight: 600;
}

.badge-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
}

.badge-toast-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: white;
    animation: badge-progress 4s linear;
}

@keyframes badge-progress {
    0% {
        transform: scaleX(1);
        transform-origin: left;
    }
    100% {
        transform: scaleX(0);
        transform-origin: left;
    }
}

/* Game Ratings Section */
.game-ratings-container h3 {
    font-size: 1rem;
    margin: 0;
    color: var(--auth-text);
}

.game-ratings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.game-rating-card {
    background: var(--auth-bg);
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--auth-border);
}

.game-rating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.game-rating-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--auth-text);
}

.game-rating-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--auth-primary);
}

.game-rating-stats {
    display: flex;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--auth-text-light);
    align-items: center;
}

.rating-stat {
    font-weight: 500;
}

.rating-stat-divider {
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
    .login-container {
        padding: 1rem;
    }
    
    .login-logo h1 {
        font-size: 2rem;
    }
    
    .login-box {
        padding: 1.5rem;
    }
    
    .profile-modal-content {
        padding: 1.5rem;
        max-height: 90vh;
    }
    
    .profile-stats {
        grid-template-columns: 1fr;
    }
    
    .game-ratings-grid {
        grid-template-columns: 1fr;
    }
    
    .badge-toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .badge-toast {
        min-width: auto;
        width: 100%;
    }
}

