/* 
 * File: assets/css/ejs-achievements.css
 * Description: Styles for EmulatorJS achievement system
 * @package EmulatorJS
 * @since 1.0.0
 */

/* Achievement Showcase */
.ejs-achievements-showcase {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

/* Profile Achievements Header */
.ejs-profile-achievements .ejs-achievements-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.ejs-profile-achievements .ejs-achievements-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Icon button for view all achievements */
.ejs-view-all-achievements-icon {
    background: #f0f0f0;
    border: none;
    color: #333;
    font-size: 16px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 5px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ejs-view-all-achievements-icon:hover {
    background: #333;
    color: #fff;
}

.ejs-view-all-achievements-icon:active {
    transform: scale(0.95);
}

/* Hide old achievement actions in profile */
.ejs-profile-achievements .ejs-achievement-actions {
    display: none;
}

.ejs-achievement-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 6px;
    color: white;
}

.ejs-achievement-stats .stat-item {
    text-align: center;
    flex: 1;
}

.ejs-achievement-stats .stat-number {
    display: block;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
}

.ejs-achievement-stats .stat-label {
    font-size: 12px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Achievement Grid - FIXED: Force grid layout with !important */
.ejs-achievements-grid {
    display: grid !important;
    /* FIXED: Force responsive grid for badge layout */
    grid-template-columns: repeat(4, 1fr) !important; /* Desktop: 5 columns */
    gap: 10px !important;
    margin-bottom: 20px;
    /* FIXED: Override any flex or block styling */
    flex-direction: unset !important;
    flex-wrap: unset !important;
}

/* FIXED: Ensure modal grid also uses grid layout */
.ejs-achievements-modal-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
    /* FIXED: Override any flex or block styling */
    flex-direction: unset !important;
    flex-wrap: unset !important;
}

/* FIXED: Force grid item to not be flex container at grid level */
.ejs-achievements-grid > .ejs-achievement-item,
.ejs-achievements-modal-grid > .ejs-achievement-item {
    display: flex !important;
    flex-direction: row !important;
}

.ejs-achievement-item {
    display: flex;
    flex-direction: row; /* FIXED: Horizontal layout - badge left, text right */
    align-items: flex-start; /* FIXED: Align to top */
    padding: 15px;
    border-radius: 8px;
    background: #f8f9fa;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 120px; /* FIXED: Consistent height */
}

.ejs-achievement-item:hover {
    transform: translateY(-2px);
}

/* Tier-based styling */
.ejs-achievement-item.tier-bronze {
    border-color: #CD7F32;
    background: linear-gradient(135deg, #fff 0%, #fdf5e6 100%);
}

.ejs-achievement-item.tier-silver {
    border-color: #C0C0C0;
    background: linear-gradient(135deg, #fff 0%, #f5f5f5 100%);
}

.ejs-achievement-item.tier-gold {
    border-color: #FFD700;
    background: linear-gradient(135deg, #fff 0%, #fffacd 100%);
}

.ejs-achievement-item.tier-platinum {
    border-color: #E5E4E2;
    background: linear-gradient(135deg, #fff 0%, #f0f8ff 100%);
}

.ejs-achievement-item.tier-diamond {
    border-color: #B9F2FF;
    background: linear-gradient(135deg, #fff 0%, #e6f3ff 100%);
}

/* Achievement Icon - FIXED: Badge on the left */
.achievement-icon {
    width: 60px; /* FIXED: Badge width */
    height: 75px; /* FIXED: Badge height (vertical aspect ratio) */
    margin-right: 12px; /* FIXED: Space between badge and text */
    flex-shrink: 0;
    position: relative;
}

.achievement-icon img {
    width: 100%;
    height: 100%;
}

/* Locked achievement styling */
.ejs-achievement-item.locked .achievement-icon img {
    filter: grayscale(100%) brightness(0.6);
    opacity: 0.7;
}

.ejs-achievement-item.locked {
    opacity: 0.6;
}

/* Achievement Info - FIXED: Text content on the right */
.achievement-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* FIXED: Align to top */
    text-align: left; /* FIXED: Left align text */
}

.achievement-title {
    font-size: 14px; /* FIXED: Appropriate size for grid */
    font-weight: 600;
    margin: 0 0 4px 0;
    color: #333;
    line-height: 1.2;
    text-align: left;
}

.achievement-description {
    font-size: 11px; /* FIXED: Smaller for compact grid */
    color: #333;
    margin: 0 0 8px 0;
    line-height: 1.3;
    text-align: left;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* FIXED: Limit to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1; /* FIXED: Take remaining space */
}

.achievement-meta {
    display: flex;
    flex-direction: column; /* FIXED: Stack vertically */
    align-items: flex-start; /* FIXED: Left align */
    gap: 4px;
    font-size: 10px;
    margin-top: auto; /* FIXED: Push to bottom */
}

.achievement-points {
    background: #007cba;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 10px;
}

.achievement-date,
.achievement-locked {
    color: #888;
    font-style: italic;
    font-size: 9px;
}

.achievement-locked {
    color: #999;
    font-weight: 500;
}

/* Earned badge indicator */
.achievement-earned-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    background: #28a745;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

/* No Achievements State */
.no-achievements {
    text-align: center;
    padding: 10px;
    color: #333;
    background: #fff;
    border-radius: 5px;
}

/* Achievement Actions */
.ejs-achievement-actions {
    margin-top: 15px;
    text-align: center;
}

.ejs-view-all-achievements {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.ejs-view-all-achievements:hover {
    transform: translateY(-1px);
    color: white;
    text-decoration: none;
}

/* Achievement Modal/Popup */
.ejs-achievement-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: none;
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.ejs-achievement-modal.show {
    display: flex;
}

.ejs-achievement-modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px 20px;
	margin: 20px;
    max-width: 1220px;
    max-height: 450px; /* FIXED: Changed from 90% to 500px */
    overflow-y: auto;
    /* FIXED: Hide vertical scrollbar but keep functionality */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    position: relative;
    animation: achievementModalIn 0.3s ease;
}

/* FIXED: Hide scrollbar for Chrome, Safari and Opera */
.ejs-achievement-modal-content::-webkit-scrollbar {
    display: none;
}

@keyframes achievementModalIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ejs-achievement-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.ejs-achievement-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* Achievement Categories - Horizontal Slider */
.ejs-achievement-categories {
    position: relative;
    margin-bottom: 20px;
    padding: 0 60px; /* FIXED: Increased padding for bigger navigation buttons */
}

.ejs-achievement-categories-container {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    padding: 10px 0;
    gap: 10px;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.ejs-achievement-categories-container::-webkit-scrollbar {
    display: none;
}

.ejs-achievement-category-filter {
    background: #f0f0f0;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    color: #666;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: fit-content;
}

.ejs-achievement-category-filter:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

.ejs-achievement-category-filter.active {
    background: #667eea;
    color: white;
}

/* FIXED: Navigation arrows for category slider - Centered alignment */
.ejs-categories-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 5px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 3;
    color: white;
    font-size: 20px; /* FIXED: Reduced font size for better centering */
    font-weight: bold;
    line-height: 1; /* FIXED: Reset line-height to prevent offset */
    padding: 0; /* FIXED: Remove any padding */
    margin: 0; /* FIXED: Remove any margin */
}

.ejs-categories-nav:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6b4190 100%);
    transform: translateY(-50%) scale(1.05);
}

.ejs-categories-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.ejs-categories-nav.prev {
    left: 0;
}

.ejs-categories-nav.next {
    right: 0;
}

.ejs-categories-nav.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    background: #ccc;
    color: #888;
    box-shadow: none;
}

/* Gradient fade effects */
.ejs-achievement-categories::before {
    content: '';
    position: absolute;
    right: 55px;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to left, rgba(255,255,255,1), rgba(255,255,255,0));
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ejs-achievement-categories.can-scroll-right::before {
    opacity: 0;
}

.ejs-achievement-categories::after {
    content: '';
    position: absolute;
    left: 55px;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, rgba(255,255,255,1), rgba(255,255,255,0));
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ejs-achievement-categories.can-scroll-left::after {
    opacity: 0;
}

/* Achievement Notification Toast */
.ejs-achievement-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    z-index: 10000;
    min-width: 320px;
    max-width: 400px;
    transform: translateX(100%);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    align-items: center;
    gap: 15px;
}

.ejs-achievement-notification.show {
    transform: translateX(0);
}

.ejs-achievement-notification.hide {
    transform: translateX(100%);
}

.ejs-achievement-notification-icon {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.ejs-achievement-notification-icon img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.3);
}

.ejs-achievement-notification-content h4 {
    margin: 0 0 5px 0;
    font-size: 16px;
    font-weight: 600;
}

.ejs-achievement-notification-content p {
    margin: 0 0 5px 0;
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.3;
}

.ejs-achievement-notification-points {
    font-size: 12px;
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
}

.ejs-achievement-notification-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.7;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.ejs-achievement-notification-close:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1);
}

/* Achievement Progress Bars */
.ejs-achievement-progress {
    margin-top: 10px;
}

.ejs-achievement-progress-bar {
    background: #e0e0e0;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
    position: relative;
}

.ejs-achievement-progress-fill {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
    position: relative;
}

.ejs-achievement-progress-text {
    font-size: 11px;
    color: #666;
    margin-top: 3px;
    text-align: center;
}

/* Achievement Tiers Legend */
.ejs-achievement-tiers {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.ejs-achievement-tier {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #666;
}

.ejs-achievement-tier-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.ejs-achievement-tier-color.bronze {
    background: #CD7F32;
}

.ejs-achievement-tier-color.silver {
    background: #C0C0C0;
}

.ejs-achievement-tier-color.gold {
    background: #FFD700;
}

.ejs-achievement-tier-color.platinum {
    background: #E5E4E2;
}

.ejs-achievement-tier-color.diamond {
    background: #B9F2FF;
}

/* Loading States */
.ejs-achievements-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
}

.ejs-achievements-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Achievement Unlock Animation */
.ejs-achievement-unlock {
    animation: achievementUnlock 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes achievementUnlock {
    0% {
        transform: scale(0.8) rotate(-5deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(2deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Achievement Sparkle Effect */
.ejs-achievement-sparkle {
    position: relative;
    overflow: visible;
}

.ejs-achievement-sparkle::before,
.ejs-achievement-sparkle::after {
    content: '✨';
    position: absolute;
    animation: sparkle 2s ease-in-out infinite;
    font-size: 16px;
    pointer-events: none;
}

.ejs-achievement-sparkle::before {
    top: -10px;
    left: -10px;
    animation-delay: 0s;
}

.ejs-achievement-sparkle::after {
    bottom: -10px;
    right: -10px;
    animation-delay: 1s;
}

@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive Design - FIXED: Correct tablet breakpoint */
@media (max-width: 1200px) {
    /* Large tablet: 4 columns */
    .ejs-achievements-grid,
    .ejs-achievements-modal-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    /* Tablet: 3 columns - FIXED: More specific breakpoint */
    .ejs-achievements-grid,
    .ejs-achievements-modal-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    .ejs-achievement-item {
        min-height: 110px;
        padding: 12px;
    }
    
    .achievement-icon {
        width: 50px;
        height: 65px;
        margin-right: 10px;
    }
    
    .achievement-title {
        font-size: 13px;
    }
    
    .achievement-description {
        font-size: 10px;
    }
}

@media (max-width: 768px) {
    /* Tablet: 3 columns - FIXED: More specific breakpoint */
    .ejs-achievements-grid,
    .ejs-achievements-modal-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    .ejs-achievement-item {
        padding: 10px;
        min-height: 100px;
    }
    
    .achievement-icon {
        width: 45px;
        height: 58px;
        margin-right: 8px;
    }
    
    .achievement-title {
        font-size: 12px;
        margin-bottom: 3px;
    }
    
    .achievement-description {
        font-size: 9px;
        -webkit-line-clamp: 2;
        margin-bottom: 6px;
    }
    
    .achievement-points {
        font-size: 9px;
        padding: 1px 4px;
    }
    
    .achievement-date,
    .achievement-locked {
        font-size: 8px;
    }
    
    .achievement-earned-badge {
        width: 16px;
        height: 16px;
        font-size: 10px;
        top: 2px;
        right: 2px;
    }
    
    .ejs-achievement-categories {
        padding: 0;
    }
    
    .ejs-achievement-categories-container {
        padding: 8px 0;
        gap: 8px;
    }
    
    .ejs-achievement-category-filter {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .ejs-categories-nav {
        display: none;
    }
    
    .ejs-achievement-categories::before {
        right: 10px;
        width: 20px;
    }
    
    .ejs-achievement-categories::after {
        left: 10px;
        width: 20px;
    }
    
    .ejs-achievement-notification {
        min-width: 280px;
        right: 10px;
        top: 10px;
        padding: 15px;
    }
    
    .ejs-achievement-notification-icon {
        width: 50px;
        height: 50px;
    }
    
    .ejs-achievement-stats {
        flex-direction: row;
        gap: 10px;
    }
    
    .ejs-achievement-tiers {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .ejs-achievement-modal-content {
        margin: 20px;
        padding: 20px;
        max-height: calc(100vh - 20px);
    }
}

@media (max-width: 480px) {
    /* Small mobile: still 2 columns but more compact */
    .ejs-achievements-grid,
    .ejs-achievements-modal-grid {
		grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }
    
    .ejs-achievement-item {
        padding: 8px;
        min-height: 90px;
    }
    
    .achievement-icon {
        width: 40px;
        height: 52px;
        margin-right: 6px;
    }
    
    .achievement-title {
        font-size: 11px;
        margin-bottom: 2px;
    }
    
    .achievement-description {
        font-size: 8px;
        -webkit-line-clamp: 1;
        margin-bottom: 4px;
    }
    
    .achievement-points {
        font-size: 8px;
    }
    
    .achievement-date,
    .achievement-locked {
        font-size: 7px;
    }
    
    .achievement-earned-badge {
        width: 14px;
        height: 14px;
        font-size: 9px;
    }
    
    .ejs-achievement-categories {
        padding: 0;
    }
    
    .ejs-achievement-category-filter {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* Achievement filter hidden state - FIXED for grid layout */
.ejs-achievement-item.ejs-achievement-hidden {
    display: none !important;
}

/* Achievement Badges Only Grid - For Profile Overview */
.ejs-achievement-badges-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 12px !important;
    margin-top: 15px;
    padding: 10px;
    background: #fff;
    border-radius: 5px;
}

/* Individual Badge Item */
.ejs-achievement-badge {
    position: relative;
    aspect-ratio: 3/4; /* Vertical badge ratio */
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

/* Badge image */
.ejs-achievement-badge img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Hover effect for badges */
.ejs-achievement-badge:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Responsive design for badges */
@media (max-width: 768px) {
    .ejs-achievement-badges-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
}

@media (max-width: 480px) {
    .ejs-achievement-badges-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
    }
    
    .achievement-earned-indicator {
        width: 14px;
        height: 14px;
        font-size: 9px;
        top: 2px;
        right: 2px;
    }
}