/**
 * Provolution Gamification Styles
 * Modern, clean design with climate theme
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --primary-color: #2e7d32;
    --primary-light: #60ad5e;
    --primary-dark: #005005;
    --secondary-color: #1565c0;
    --accent-color: #ff9800;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --info-color: #2196f3;
    
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #666;
    --border-color: #e0e0e0;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.2);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --transition: all 0.3s ease;
}

/* ============================================
   BASE STYLES
   ============================================ */
.gamification-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
}

.section-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 2rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

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

.btn-secondary {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

/* ============================================
   GOOGLE AUTH STYLES
   ============================================ */
.google-btn-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.auth-divider span {
    padding: 0 16px;
}

.google-badge {
    display: inline-block;
    background: #4285f4;
    color: white;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
}

/* ============================================
   CHALLENGE FILTERS
   ============================================ */
.challenge-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 2rem;
}

.filter-btn {
    background: white;
    border: 2px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* ============================================
   CHALLENGE GRID & CARDS
   ============================================ */
.challenge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    padding: 0 1rem;
}

.challenge-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 2px solid transparent;
}

.challenge-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.challenge-card.joined {
    border-color: var(--primary-color);
}

.challenge-card.completed {
    opacity: 0.8;
    border-color: var(--success-color);
}

.challenge-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.challenge-icon {
    font-size: 2rem;
}

.challenge-difficulty {
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
}

.challenge-difficulty.easy {
    background: #e8f5e9;
    color: #2e7d32;
}

.challenge-difficulty.medium {
    background: #fff3e0;
    color: #e65100;
}

.challenge-difficulty.hard {
    background: #ffebee;
    color: #c62828;
}

.challenge-difficulty.expert {
    background: #f3e5f5;
    color: #6a1b9a;
}

.challenge-featured-badge {
    background: linear-gradient(135deg, #ffd700, #ffab00);
    color: #333;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
}

.challenge-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.challenge-desc {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.challenge-meta {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.challenge-impact {
    background: #e8f5e9;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.impact-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.impact-value {
    font-weight: 700;
    color: var(--primary-color);
}

.challenge-badge {
    margin-bottom: 12px;
}

.badge-preview {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.challenge-participants {
    margin-bottom: 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.challenge-cta {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.challenge-cta:hover {
    background: var(--primary-dark);
}

.challenge-cta.active {
    background: var(--secondary-color);
}

.challenge-cta.completed {
    background: var(--success-color);
    cursor: default;
}

/* ============================================
   LEADERBOARD
   ============================================ */
.leaderboard-section {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem;
}

.leaderboard-tabs {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.leaderboard-tab {
    background: white;
    border: 2px solid var(--border-color);
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.leaderboard-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.leaderboard-period {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.leaderboard-list {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.leaderboard-entry:last-child {
    border-bottom: none;
}

.leaderboard-entry:hover {
    background: #f5f5f5;
}

.leaderboard-entry.top-1 {
    background: linear-gradient(90deg, #fff9c4, #fff);
}

.leaderboard-entry.top-2 {
    background: linear-gradient(90deg, #f5f5f5, #fff);
}

.leaderboard-entry.top-3 {
    background: linear-gradient(90deg, #ffe0b2, #fff);
}

.leaderboard-entry .rank {
    width: 50px;
    font-size: 1.2rem;
    font-weight: 700;
}

.leaderboard-entry .user-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.leaderboard-entry .avatar {
    font-size: 1.5rem;
}

.leaderboard-entry .username {
    font-weight: 600;
}

.leaderboard-entry .score {
    text-align: right;
}

.leaderboard-entry .score-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.leaderboard-entry .score-unit {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.my-rank-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px dashed var(--border-color);
}

.my-rank-section h4 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.my-rank-card {
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.my-rank-card .rank {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* ============================================
   AUTH UI
   ============================================ */
.auth-buttons {
    display: flex;
    gap: 12px;
}

.btn-login,
.btn-register {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-login {
    background: transparent;
    border: 2px solid white;
    color: white;
}

.btn-login:hover {
    background: rgba(255,255,255,0.1);
}

.btn-register {
    background: white;
    border: 2px solid white;
    color: var(--primary-color);
}

.btn-register:hover {
    background: rgba(255,255,255,0.9);
}

.user-profile-mini {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255,255,255,0.95);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.user-avatar {
    font-size: 2rem;
}

.user-info {
    flex: 1;
}

.user-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
}

.user-xp {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.user-actions {
    display: flex;
    gap: 8px;
}

.btn-profile,
.btn-logout {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-profile {
    background: var(--secondary-color);
    color: white;
    border: none;
}

.btn-logout {
    background: transparent;
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

/* ============================================
   AUTH FORMS
   ============================================ */
.auth-form {
    max-width: 400px;
    margin: 0 auto;
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: var(--transition);
}

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

.form-group small {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 4px;
}

.form-error {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    min-height: 1.2rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

/* ============================================
   PROFILE VIEW
   ============================================ */
.profile-view {
    text-align: center;
}

.profile-header {
    margin-bottom: 2rem;
}

.profile-avatar {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.profile-header h2 {
    margin-bottom: 0.5rem;
}

.profile-level {
    background: var(--accent-color);
    color: white;
    padding: 4px 16px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
}

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

.stat-card {
    background: #f5f5f5;
    padding: 16px;
    border-radius: var(--radius-sm);
}

.stat-card .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.profile-details {
    text-align: left;
    background: #f9f9f9;
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
}

.profile-details p {
    margin: 8px 0;
}

.profile-details code {
    background: #e0e0e0;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    background: #f0f0f0;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ============================================
   NOTIFICATIONS
   ============================================ */
.notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

.notification-success {
    background: var(--success-color);
}

.notification-error {
    background: var(--error-color);
}

.notification-info {
    background: var(--info-color);
}

.notification-warning {
    background: var(--warning-color);
}

.notification.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .challenge-grid {
        grid-template-columns: 1fr;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .user-profile-mini {
        flex-wrap: wrap;
    }
    
    .user-actions {
        width: 100%;
        justify-content: center;
        margin-top: 12px;
    }
    
    .profile-stats {
        grid-template-columns: 1fr;
    }
    
    .notification {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
    
    .auth-buttons {
        flex-direction: column;
        gap: 8px;
    }
}

/* ============================================
   MY CHALLENGES SECTION
   ============================================ */
.my-challenges-section {
    margin-bottom: 40px;
    padding-bottom: 40px;
    border-bottom: 2px solid var(--border-color);
}

.my-challenges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.active-challenge-card {
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.active-challenge-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.active-challenge-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.active-challenge-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.active-challenge-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.active-challenge-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.active-challenge-actions .btn-secondary,
.active-challenge-actions .btn-primary {
    flex: 1;
    min-width: 120px;
    padding: 10px 16px;
    font-size: 0.9rem;
}

/* ============================================
   CHALLENGE PROGRESS BAR
   ============================================ */
.challenge-progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
}

.challenge-progress-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.challenge-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    border-radius: 4px;
    transition: width 0.5s ease-out;
}

.challenge-progress-text {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 45px;
    text-align: right;
}

/* Progress modal specific */
.progress-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.progress-actions .btn-primary {
    flex: 1;
    min-width: 140px;
}

/* ============================================
   COMPLETION CELEBRATION
   ============================================ */
.completion-celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.completion-celebration.active {
    opacity: 1;
    visibility: visible;
}

.celebration-content {
    background: white;
    padding: 48px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 420px;
    width: 90%;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.completion-celebration.active .celebration-content {
    transform: scale(1);
    animation: celebrationPulse 0.5s ease;
}

@keyframes celebrationPulse {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.celebration-confetti {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: confettiBounce 0.6s ease infinite alternate;
}

@keyframes confettiBounce {
    from { transform: translateY(0) rotate(-5deg); }
    to { transform: translateY(-10px) rotate(5deg); }
}

.celebration-content h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.celebration-challenge-name {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.celebration-rewards {
    background: linear-gradient(135deg, #fff9c4, #fff3e0);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

.reward-xp,
.reward-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 8px 0;
}

.reward-icon {
    font-size: 1.5rem;
}

.reward-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.celebration-close {
    min-width: 200px;
}

/* ============================================
   RESPONSIVE - MY CHALLENGES
   ============================================ */
@media (max-width: 768px) {
    .my-challenges-grid {
        grid-template-columns: 1fr;
    }
    
    .active-challenge-actions {
        flex-direction: column;
    }
    
    .active-challenge-actions .btn-secondary,
    .active-challenge-actions .btn-primary {
        width: 100%;
    }
    
    .celebration-content {
        padding: 32px 24px;
    }
    
    .celebration-content h2 {
        font-size: 1.5rem;
    }
}
