:root {
    /* Colors - Duolingo-ish Palette */
    --bg-color: #f7f7f7;
    /* Light gray background */
    --card-bg: #ffffff;
    --text-primary: #3c3c3c;
    --text-secondary: #777777;
    --accent-color: #58cc02;
    /* Green */
    --accent-hover: #46a302;
    --accent-secondary: #1cb0f6;
    /* Blue */
    --border-color: #e5e5e5;
    --pacer-blue: #328fde;

    /* Spacing & Radius */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;

    /* Shadows */
    --shadow-sm: 0 2px 0 #e5e5e5;
    --shadow-md: 0 4px 0 #e5e5e5;
    /* "Pop" effect */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

.app-container {
    margin: 0 auto;
    padding: 20px;
    padding-top: 90px;
    /* Account for fixed header */
    max-width: 100%;
    overflow-x: hidden;
}

/* Header */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--border-color);
    width: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.header-content {
    max-width: 1024px;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.desktop-nav {
    display: flex;
    gap: 24px;
}

.nav-item {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 14px;
    transition: color 0.2s;
}

.nav-item:hover {
    color: var(--accent-secondary);
}

.mobile-toggle {
    display: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
}

/* Layout */
.profile-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    /* 2/3 and 1/3 */
    gap: 24px;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.right-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Cards */
.section-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    /* box-shadow: var(--shadow-sm); */
}

h2 {
    font-family: 'SF Pro Rounded', sans-serif;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Section title headers (titles outside cards) */
.section-title-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.section-title-header h2 {
    margin-bottom: 0;
}

/* For standalone h2 section titles (outside sections) */
.left-column>h2 {
    margin-bottom: 4px;
}


/* Profile Header Section */
.profile-header-section {
    background: transparent;
    border: none;
    margin-bottom: 24px;
}

.profile-banner {
    height: 180px;
    background: #fbc903;
    /* Green from the ref image, or keep gradient if preferred. using image color roughly */
    border-radius: var(--radius-lg);
    width: 100%;
    /* Center avatar */
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 16px;
}

.profile-header-content {
    /* No padding, direct flow */
    position: relative;
    padding: 0;
    /* Align with left edge */
}

/* Avatar positioning */
.avatar-container {
    width: 100px;
    /* Slightly smaller to fit nicely in 180px banner? or keep large? request didn't say resize avatar. Keeping 120-140 is fine. */
    height: 100px;
    background: transparent;
    border-radius: 50%;
    padding: 0;
    border: none;
    /* No border needed if inside green area */
    margin: 0;
    /* Remove old margins */
}

.profile-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #eee;
    border: 4px solid rgba(255, 255, 255, 0.2);
    /* Optional: nice effect for avatar on colored bg */
}

.profile-info {
    text-align: left;
    /* Left align */
}

.profile-name {
    font-family: 'SF Pro Rounded', sans-serif;
    font-size: 24px;
    /* Reduced from 32px */
    font-weight: 800;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.profile-meta {
    display: flex;
    justify-content: flex-start;
    /* Left align */
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    /* Reduced spacing */
    flex-wrap: wrap;
}

.profile-id {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 14px;
    /* Reduced from 16 */
}

.profile-country {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: transparent;
    /* Clean look */
    padding: 0;
    border: none;
}

.profile-description {
    font-size: 15px;
    /* Reduced from 16 */
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.5;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.joined-date {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.follow-stats {
    display: flex;
    justify-content: flex-start;
    /* Left align */
    gap: 24px;
    font-size: 15px;
    /* Reduced from 16 */
    color: var(--pacer-blue);
    font-weight: 600;
    font-family: 'SF Pro Rounded', sans-serif;
}

.follow-btn {
    margin-top: 16px;
    padding: 12px 32px;
    background-color: #328fde;
    color: white;
    border: none;
    border-radius: 12px;
    font-family: 'SF Pro Rounded', sans-serif;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 3px 0 #2B70AA;
    transition: transform 0.1s, box-shadow 0.1s;
    width: 66.67%;
    display: block;
}

.follow-btn:hover {
    transform: translateY(1px);
    box-shadow: 0 2px 0 #2B70AA;
}

.follow-btn:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #2B70AA;
}

/* Section Separator */
.section-separator {
    height: 2px;
    /* Thicker */
    background-color: var(--border-color);
    /* Match card borders */
    margin-bottom: 24px;
    width: 100%;
}


/* Weekly Progress - Line Chart */
.chart-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.line-chart {
    position: relative;
    width: 100%;
    height: 240px;
    padding: 10px 0;
}

.chart-svg {
    width: 100%;
    height: 100%;
}

.chart-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawLine 1.5s ease-out forwards;
}

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

.chart-dot {
    opacity: 0;
    animation: fadeInDot 0.5s ease-out forwards;
    transition: r 0.2s ease, fill 0.2s ease;
    cursor: pointer;
}

.chart-dot:nth-child(4) {
    animation-delay: 0.2s;
}

.chart-dot:nth-child(5) {
    animation-delay: 0.4s;
}

.chart-dot:nth-child(6) {
    animation-delay: 0.6s;
}

.chart-dot:nth-child(7) {
    animation-delay: 0.8s;
}

.chart-dot:nth-child(8) {
    animation-delay: 1s;
}

.chart-dot:nth-child(9) {
    animation-delay: 1.2s;
}

.chart-dot:nth-child(10) {
    animation-delay: 1.4s;
}

@keyframes fadeInDot {
    to {
        opacity: 1;
    }
}

.chart-dot:hover {
    r: 8;
    fill: #2675b8;
}

.day-label {
    font-size: 14px;
    font-weight: 700;
    fill: var(--text-secondary);
    font-family: 'Inter', sans-serif;
}

.y-axis-label {
    font-size: 12px;
    font-weight: 600;
    fill: var(--text-secondary);
    font-family: 'Inter', sans-serif;
}

.chart-summary {
    display: flex;
    justify-content: space-around;
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.summary-item .label {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.summary-item .value {
    font-size: 20px;
    font-weight: 800;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Gradient backgrounds for specific stat cards */
.stat-card.fire {
    background: linear-gradient(135deg, #ffc801, #ffd148);
    border-color: #ffc801;
}

.stat-card.league {
    background: linear-gradient(135deg, #919ad7, #8c95ca);
    border-color: #919ad7;
}

/* White text for gradient cards */
.stat-card.fire .value,
.stat-card.fire .label,
.stat-card.league .value,
.stat-card.league .label {
    color: white;
}

.stat-card .icon {
    font-size: 24px;
}

.stat-card .stat-details {
    display: flex;
    flex-direction: column;
}

.stat-card .value {
    font-weight: 800;
    font-size: 18px;
}

.stat-card .label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Posts Feed */
.post-item {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.post-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

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

.post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #eee;
}

.post-meta {
    display: flex;
    flex-direction: column;
}

.post-author {
    font-family: 'SF Pro Rounded', sans-serif;
    font-weight: 700;
    font-size: 15px;
}

.post-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.post-content {
    font-size: 15px;
    line-height: 1.5;
}

.post-image {
    width: 100%;
    max-height: 300px;
    max-width: 300px;
    border-radius: var(--radius-md);
    margin-top: 12px;
    object-fit: cover;
}

.btn-see-more {
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    background: none;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-see-more:hover {
    background: var(--bg-color);
    border-color: var(--pacer-blue);
    color: var(--pacer-blue);
}

/* Friends Widget */
.friends-widget {
    padding: 0;
    /* Custom padding handling */
    overflow: hidden;
}

.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 16px;
    background: none;
    border: none;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    /* Overlap border */
}

.tab-btn.active {
    color: var(--accent-secondary);
    border-bottom-color: var(--accent-secondary);
}

.friends-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.friend-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-secondary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.friend-info {
    display: flex;
    flex-direction: column;
}

.friend-name {
    font-family: 'SF Pro Rounded', sans-serif;
    font-weight: 700;
    font-size: 14px;
}

.friend-streak {
    font-size: 12px;
    color: #f59e0b;
    /* Orange/Gold */
    font-weight: 600;
}

.view-all {
    width: 100%;
    padding: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
    cursor: pointer;
    border-top: 2px solid var(--border-color);
}

.view-all:hover {
    background: #f9f9f9;
}

/* Badges Section */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.badge-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    font-weight: 700;
}

.badge-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Clubs Section */
.clubs-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.club-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: transform 0.2s;
}

.club-item:hover {
    transform: translateY(-2px);
    border-color: var(--pacer-blue);
}

/* Remove underline from club hyperlinks */
.clubs-list .club-item {
    text-decoration: none;
}

.club-image {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.club-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.club-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

.club-members {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Challenges Section */
.challenges-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.challenge-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.challenge-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Add hover effect for challenge items */
.challenge-item {
    transition: background-color 0.2s;
    padding: 8px;
    border-radius: var(--radius-sm);
    margin: -8px;
}

.challenge-item:hover {
    background-color: var(--bg-color);
}

/* Remove underline from challenge hyperlinks */
.challenges-list .challenge-item {
    text-decoration: none;
}

.challenge-icon {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.challenge-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.challenge-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

.challenge-status {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.challenge-status.active {
    color: var(--pacer-blue);
}

/* Section Header Utility */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h2 {
    margin-bottom: 0;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
    cursor: pointer;
}

.btn-text:hover {
    color: var(--pacer-blue);
}

/* Friends title - hide on desktop, show on mobile */
.friends-title {
    display: none;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 2px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-family: 'SF Pro Rounded', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background-color: var(--bg-color);
}

.modal-body {
    padding: 24px;
    text-align: center;
}

.qr-code {
    width: 200px;
    height: 200px;
    border-radius: 12px;
    margin-bottom: 20px;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.modal-text {
    font-size: 16px;
    color: var(--text-primary);
    line-height: 1.5;
    margin: 0;
    font-weight: 500;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-container {
        padding: 12px;
        padding-top: 80px;
        /* Account for fixed header on mobile */
    }

    .follow-btn {
        width: 80%;
        margin-left: auto;
        margin-right: auto;
    }

    .profile-layout {
        grid-template-columns: 1fr;
        /* Stack columns */
    }

    .right-column {
        order: 1;
        /* Ensure it stays below main content if needed, or adjust order */
        gap: 0;
        /* Remove gap between Friends title and widget on mobile */
    }

    /* Show Friends title on mobile */
    .friends-title {
        display: block;
    }

    /* Header Mobile */
    .desktop-nav {
        display: none;
    }

    .mobile-toggle {
        display: block;
        margin-left: auto;
    }

    /* Ensure cards don't overflow */
    .section-card,
    .profile-card,
    .stat-card {
        max-width: 100%;
    }

    /* Badges grid - 2 columns on mobile */
    .badges-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Stats grid - keep 2 columns but reduce gap */
    .stats-grid {
        gap: 12px;
    }

    .stat-card {
        padding: 12px;
    }

    /* Club and challenge items */
    .club-item,
    .challenge-item {
        max-width: 100%;
    }
    
    /* Clubs list - single column on mobile */
    .clubs-list {
        grid-template-columns: 1fr;
    }

    .club-image {
        width: 50px;
        height: 50px;
        flex-shrink: 0;
    }

    .club-name,
    .challenge-name {
        word-break: break-word;
    }

    /* Post images */
    .post-image {
        max-width: 100%;
    }

    /* Per PRD: "Put the Follower/Following list as a Friends section below Statistics" */
    /* In grid, left column comes first, so right column naturally falls below it when stacked. */
    /* However, "below Statistics" implies it might need to be inserted *between* sections if Statistics isn't the last thing in Left Column. */
    /* Current Left Column: Profile -> Weekly -> Stats -> Posts. */
    /* If we want it below Stats but above Posts, we'd need to change HTML structure or use display: contents hack. */
    /* For now, let's just let it stack at the bottom, or we can move it in HTML if strictly required. */
    /* Let's stick to simple stacking for now as it's a mock. */
}