/* Achievements Page Styles — KiwisCAD */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --primary: #27c96d;
    --secondary: #1a4d2e;
    --ach-bg-body: #f8fafc;
    --ach-panel-bg: #ffffff;
    --ach-border-color: #e2e8f0;
    --ach-text-main: #0f172a;
    --ach-text-muted: #64748b;
    --ach-primary: #27c96d;
    --ach-primary-hover: #1eab59;
    --ach-primary-light: rgba(39, 201, 109, 0.08);
    --ach-glow-primary: rgba(39, 201, 109, 0.06);
    --ach-color-gold: #d97706;
    --ach-color-silver: #475569;
    --ach-color-bronze: #b45309;
    --ach-unlocked-glow: 0 4px 16px rgba(39, 201, 109, 0.06);
}

body.achievements-body {
    background-color: var(--ach-bg-body);
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--ach-text-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Page Spacing — clear fixed navbar (top 24px + 72px bar) */
.achievements-container {
    flex: 1 0 auto;
    max-width: 1240px;
    width: 100%;
    min-width: 0;
    margin: 0 auto;
    padding: 128px 5% 80px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    box-sizing: border-box;
}

/* Header & Intro */
.ach-header-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ach-badge-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--ach-primary-light);
    border: 1px solid rgba(39, 201, 109, 0.15);
    color: var(--ach-primary);
    padding: 6px 12px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    align-self: flex-start;
}

.ach-header-section h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 38px;
    font-weight: 800;
    line-height: 1.15;
    margin: 4px 0 0 0;
    letter-spacing: -0.02em;
    color: var(--ach-text-main);
}

.ach-header-section h1 span.accent {
    background: linear-gradient(135deg, var(--ach-text-main) 40%, var(--ach-primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.ach-header-section p {
    font-size: 15px;
    color: var(--ach-text-muted);
    margin: 0;
    max-width: 650px;
    line-height: 1.5;
}

/* Main Dashboard Layout */
.ach-dashboard-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 32px;
    align-items: start;
    position: relative;
    min-height: 480px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

/* Left Column Wrapper */
.ach-left-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

/* Left Panel: Profile and Ranks */
.ach-profile-panel {
    background: var(--ach-panel-bg);
    border: 1px solid var(--ach-border-color);
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.04);
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 24px;
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Circular Progress Ring */
.xp-ring-container {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.xp-svg-ring {
    transform: rotate(-90deg);
}

.xp-ring-bg {
    fill: none;
    stroke: #f1f5f9;
    stroke-width: 8px;
}

.xp-ring-bar {
    fill: none;
    stroke: var(--ach-primary);
    stroke-dasharray: 377;
    stroke-dashoffset: 377;
    stroke-linecap: round;
    stroke-width: 8px;
    transition: none;
}

.xp-ring-bar.is-animating {
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.xp-ring-text {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.xp-ring-level {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 800;
    color: var(--ach-text-main);
    line-height: 1;
}

.xp-ring-label {
    font-size: 9px;
    text-transform: uppercase;
    color: var(--ach-text-muted);
    letter-spacing: 0.1em;
    margin-top: 4px;
}

.ach-user-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ach-username {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--ach-text-main);
}

.ach-rank-title {
    font-size: 13px;
    color: var(--ach-primary);
    font-weight: 600;
    background: var(--ach-primary-light);
    padding: 4px 12px;
    border-radius: 99px;
    border: 1px solid rgba(39, 201, 109, 0.12);
}

.ach-xp-breakdown {
    width: 100%;
    border-top: 1px solid var(--ach-border-color);
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.xp-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 13.5px;
}

.xp-stat-label {
    color: var(--ach-text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.xp-stat-label i {
    width: 15px;
    height: 15px;
    color: var(--ach-primary);
}

.xp-stat-value {
    color: var(--ach-text-main);
    font-weight: 600;
}

/* Category Filter Tabs */
.ach-tabs-container {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--ach-border-color);
    padding-bottom: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.ach-tabs-container::-webkit-scrollbar {
    display: none;
}

.ach-tab-btn {
    background: transparent;
    border: none;
    color: var(--ach-text-muted);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.ach-tab-btn i {
    width: 16px;
    height: 16px;
}

.ach-tab-btn:hover {
    color: var(--ach-text-main);
    background: #f1f5f9;
}

.ach-tab-btn.is-active {
    color: var(--ach-primary);
    background: var(--ach-primary-light);
}

/* Achievements Grid */
.ach-grid-wrapper {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
    max-width: 100%;
}

.ach-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: 20px;
    width: 100%;
    min-width: 0;
}

/* Achievement Card */
.ach-card {
    background: var(--ach-panel-bg);
    border: 1px solid var(--ach-border-color);
    border-radius: 16px;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.02);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Locked State */
.ach-card.is-locked {
    opacity: 0.6;
}

.ach-card.is-locked:hover {
    opacity: 0.8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

/* Unlocked State */
.ach-card.is-unlocked {
    border-color: rgba(39, 201, 109, 0.25);
    background: linear-gradient(145deg, #ffffff 0%, #f0fdf4 100%);
    box-shadow: var(--ach-unlocked-glow);
}

.ach-card.is-unlocked:hover {
    transform: translateY(-4px);
    border-color: rgba(39, 201, 109, 0.45);
    box-shadow: 0 8px 24px rgba(39, 201, 109, 0.1);
}

/* Tier Specific Glow / Borders */
.ach-card.tier-gold.is-unlocked {
    border-color: rgba(217, 119, 6, 0.25);
    background: linear-gradient(145deg, #ffffff 0%, #fffbeb 100%);
    box-shadow: 0 4px 16px rgba(217, 119, 6, 0.04);
}

.ach-card.tier-gold.is-unlocked:hover {
    border-color: rgba(217, 119, 6, 0.45);
    box-shadow: 0 8px 24px rgba(217, 119, 6, 0.08);
}

/* Icon Box */
.ach-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ach-card.is-locked .ach-icon-box {
    background: #f1f5f9;
    color: #94a3b8;
    border: 1px solid #e2e8f0;
}

.ach-card.is-unlocked .ach-icon-box {
    background: rgba(39, 201, 109, 0.12);
    color: var(--ach-primary);
    border: 1px solid rgba(39, 201, 109, 0.25);
}

.ach-card.tier-gold.is-unlocked .ach-icon-box {
    background: rgba(217, 119, 6, 0.1);
    color: var(--ach-color-gold);
    border: 1px solid rgba(217, 119, 6, 0.2);
}

/* XP Badge */
.ach-xp-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 99px;
    letter-spacing: 0.02em;
}

.ach-card.is-locked .ach-xp-badge {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.ach-card.is-unlocked .ach-xp-badge {
    background: rgba(39, 201, 109, 0.15);
    color: var(--ach-primary);
    border: 1px solid rgba(39, 201, 109, 0.2);
}

.ach-card.tier-gold.is-unlocked .ach-xp-badge {
    background: rgba(217, 119, 6, 0.1);
    color: var(--ach-color-gold);
    border: 1px solid rgba(217, 119, 6, 0.15);
}

/* Card Header */
.ach-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Card Body */
.ach-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ach-card-title {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--ach-text-main);
    line-height: 1.25;
}

.ach-card-desc {
    font-size: 12px;
    color: var(--ach-text-muted);
    line-height: 1.45;
}

/* Progress bar inside card */
.ach-card-progress-wrapper {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ach-card-progress-bar {
    height: 5px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
}

.ach-card-progress-fill {
    height: 100%;
    border-radius: 99px;
    width: 0%;
    transition: width 1s ease;
}

.ach-card.is-locked .ach-card-progress-fill {
    background: #cbd5e1;
}

.ach-card.is-unlocked .ach-card-progress-fill {
    background: var(--ach-primary);
}

.ach-card.tier-gold.is-unlocked .ach-card-progress-fill {
    background: var(--ach-color-gold);
}

.ach-card-progress-text {
    font-size: 11px;
    color: var(--ach-text-muted);
    display: flex;
    justify-content: space-between;
}

.ach-card-unlocked-at {
    font-size: 11px;
    color: var(--ach-primary);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-weight: 600;
}

.ach-card.tier-gold .ach-card-unlocked-at {
    color: var(--ach-color-gold);
}

/* Logged-Out / Empty State Overlay */
.ach-logged-out-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 250, 252, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 20;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.ach-logged-out-card {
    max-width: 420px;
    background: #ffffff;
    border: 1px solid var(--ach-border-color);
    border-radius: 18px;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.08);
    padding: 40px 32px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.ach-logged-out-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--ach-primary-light);
    color: var(--ach-primary);
    border: 1px solid rgba(39, 201, 109, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(39, 201, 109, 0.1);
}

.ach-logged-out-icon i {
    width: 28px;
    height: 28px;
}

.ach-logged-out-card h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--ach-text-main);
    margin: 0;
}

.ach-logged-out-card p {
    font-size: 14.5px;
    color: var(--ach-text-muted);
    line-height: 1.5;
    margin: 0;
}

.ach-cta-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-top: 10px;
}

.ach-cta-btn {
    flex: 1;
    padding: 11px 16px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
}

.ach-cta-btn.primary {
    background: var(--ach-primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(39, 201, 109, 0.2);
}

.ach-cta-btn.primary:hover {
    background: var(--ach-primary-hover);
    box-shadow: 0 6px 16px rgba(39, 201, 109, 0.3);
    transform: translateY(-1px);
}

.ach-cta-btn.secondary {
    background: #ffffff;
    color: var(--ach-text-main);
    border: 1px solid var(--ach-border-color);
}

.ach-cta-btn.secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

/* Responsive Grid layouts */
@media (max-width: 1024px) {
    .ach-dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .achievements-container {
        padding: 108px 5% 56px;
    }

    .ach-cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ach-profile-panel {
        padding: 28px 24px;
    }

    .ach-header-section h1 {
        font-size: clamp(30px, 4vw, 38px);
    }
}

@media (max-width: 768px) {
    .achievements-container {
        padding: 96px 4% 48px;
        gap: 24px;
    }

    .ach-profile-panel {
        flex-direction: column;
        text-align: center;
        padding: 24px 18px;
        gap: 20px;
    }

    .ach-xp-breakdown {
        border-left: none;
        border-top: 1px solid var(--ach-border-color);
        padding-left: 0;
        padding-top: 20px;
    }

    .ach-user-details {
        align-items: center;
    }

    .ach-header-section h1 {
        font-size: clamp(26px, 7vw, 32px);
    }

    .ach-header-section p {
        font-size: 14px;
    }

    .ach-cards-grid {
        grid-template-columns: 1fr;
    }

    .ach-leaderboard-panel {
        padding: 18px;
    }

    .ach-cta-btn {
        padding: 9px 14px;
        font-size: 12.5px;
    }
}

@media (max-width: 480px) {
    .achievements-container {
        padding: 88px 4% 40px;
    }

    .xp-stat-row {
        font-size: 12.5px;
        gap: 8px;
    }

    .ach-tab-btn {
        padding: 8px 14px;
        font-size: 12.5px;
    }
}

/* Leaderboard Card Styles */
.ach-leaderboard-panel {
    background: var(--ach-panel-bg);
    border: 1px solid var(--ach-border-color);
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.04);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
    width: 100%;
}

.ach-leaderboard-title {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--ach-text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--ach-border-color);
    padding-bottom: 12px;
    margin: 0;
}

.ach-leaderboard-title i {
    color: var(--ach-color-gold);
}

.ach-leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.leaderboard-item.is-current-user {
    background: var(--ach-primary-light);
    border-color: rgba(39, 201, 109, 0.2);
    box-shadow: 0 2px 8px rgba(39, 201, 109, 0.04);
}

.rank-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #f1f5f9;
    color: var(--ach-text-muted);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.leaderboard-item:nth-child(1) .rank-badge {
    background: #fef3c7;
    color: var(--ach-color-gold);
}

.leaderboard-item:nth-child(2) .rank-badge {
    background: #f1f5f9;
    color: #475569;
}

.leaderboard-item:nth-child(3) .rank-badge {
    background: #ffedd5;
    color: var(--ach-color-bronze);
}

.leaderboard-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #e2e8f0;
    color: var(--ach-text-main);
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.leaderboard-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.leaderboard-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ach-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-sub {
    font-size: 10.5px;
    color: var(--ach-text-muted);
}

.leaderboard-xp-val {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--ach-primary);
}

.leaderboard-item.is-current-user .leaderboard-xp-val {
    color: var(--ach-primary);
}
