/* Profile Nav Button (In Navbar) */
.profile-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 10px;
    transition: color 0.3s;
}
.profile-nav-btn:hover {
    color: var(--primary);
    transform: scale(1.1);
}

/* Old Floating Button Removed */
/* .profile-float-btn { ... } */

/* Profile Modal */
#profileModal {
    z-index: 2500; /* Ensure higher than other elements */
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.profile-content {
    background: linear-gradient(145deg, #1a1f3a, #0f1123);
    color: white;
    width: 90%;
    max-width: 400px;
    border: 1px solid rgba(0,217,163,0.3);
    position: relative;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    margin: auto;
    /* Center in flex container */
}

/* Fix Close Button */
.profile-content .modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.profile-content .modal-close:hover {
    background: var(--danger);
    transform: rotate(90deg);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.profile-avatar-container {
    position: relative;
}
.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--primary);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    border: 3px solid rgba(255,255,255,0.2);
    overflow: hidden;
}
.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.edit-avatar-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--text-secondary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

/* Avatar Selection */
.avatar-selection {
    background: rgba(0,0,0,0.3);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
}
.avatar-selection.active { display: block; animation: fadeIn 0.3s; }
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin: 10px 0;
}
.avatar-grid img {
    width: 100%;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}
.avatar-grid img:hover { transform: scale(1.1); border-color: var(--primary); }

.custom-upload { text-align: center; margin-top: 10px; }
.custom-upload label {
    cursor: pointer;
    color: var(--primary);
    font-size: 0.9rem;
    border: 1px dashed var(--primary);
    padding: 5px 15px;
    border-radius: 5px;
}
.custom-upload input { display: none; }

.profile-info h2 { margin: 0; font-size: 1.5rem; }
.user-level { color: #aaa; font-size: 0.9rem; }
.xp-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}
.xp-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    width: 0%;
    transition: width 0.5s ease;
}
.profile-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
    background: rgba(0,0,0,0.2);
    padding: 1rem;
    border-radius: 12px;
}
.p-stat { text-align: center; }
.p-val { display: block; font-size: 1.2rem; font-weight: bold; color: var(--primary); }
.p-label { font-size: 0.75rem; color: #aaa; text-transform: uppercase; }
.profile-actions { display: flex; gap: 10px; }
.profile-actions input {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 8px;
    border-radius: 6px;
    color: white;
}
.profile-actions button {
    background: var(--primary);
    border: none;
    padding: 0 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}
.chart-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.05);
}
.chart-card h3 { margin-bottom: 1rem; color: var(--text-secondary); font-size: 1rem; }

/* Map Styles */
.impact-map-wrapper {
    height: 400px;
    width: 100%;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(0,217,163,0.2);
    margin-top: 1.5rem;
    z-index: 1; /* Keep below search dropdown */
}
.map-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* XP Toast */
.xp-toast {
    position: fixed;
    top: 100px;
    right: 20px;
    background: var(--primary);
    color: black;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: bold;
    animation: slideInRight 0.3s ease;
    z-index: 9999;
    box-shadow: 0 5px 15px rgba(0,217,163,0.4);
}
