/**
 * Afirin Achievement & Badge Design System
 * Scoped under .afirin-achievements
 */

:root {
    --ach-primary: #fa470d;
    --ach-primary-hover: #e03b05;
    --ach-primary-glow: rgba(250, 71, 13, 0.35);

    --ach-bronze-start: #b45309;
    --ach-bronze-end: #78350f;
    --ach-bronze-border: #d97706;
    --ach-bronze-glow: rgba(217, 119, 6, 0.3);

    --ach-silver-start: #94a3b8;
    --ach-silver-end: #475569;
    --ach-silver-border: #cbd5e1;
    --ach-silver-glow: rgba(203, 213, 225, 0.35);

    --ach-gold-start: #f59e0b;
    --ach-gold-end: #b45309;
    --ach-gold-border: #fbbf24;
    --ach-gold-glow: rgba(245, 158, 11, 0.4);

    --ach-platinum-start: #06b6d4;
    --ach-platinum-end: #0284c7;
    --ach-platinum-border: #67e8f9;
    --ach-platinum-glow: rgba(6, 182, 212, 0.45);

    --ach-diamond-start: #a855f7;
    --ach-diamond-end: #6b21a8;
    --ach-diamond-border: #c084fc;
    --ach-diamond-glow: rgba(168, 85, 247, 0.45);
}

/* Light Mode Defaults */
html[data-theme="light"] .afirin-achievements {
    --ach-bg: #f8fafc;
    --ach-card-bg: #ffffff;
    --ach-card-border: #e2e8f0;
    --ach-card-hover: #f1f5f9;
    --ach-text-main: #0f172a;
    --ach-text-muted: #64748b;
    --ach-hud-bg: #ffffff;
    --ach-hud-border: #e2e8f0;
    --ach-locked-bg: #f1f5f9;
    --ach-locked-border: #cbd5e1;
    --ach-progress-bg: #e2e8f0;
    --ach-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.06);
    --ach-shadow-hover: 0 10px 25px -4px rgba(15, 23, 42, 0.12);
}

/* Dark Mode */
html[data-theme="dark"] .afirin-achievements {
    --ach-bg: #090d16;
    --ach-card-bg: rgba(15, 23, 42, 0.85);
    --ach-card-border: rgba(255, 255, 255, 0.08);
    --ach-card-hover: rgba(30, 41, 59, 0.9);
    --ach-text-main: #f8fafc;
    --ach-text-muted: #94a3b8;
    --ach-hud-bg: rgba(15, 23, 42, 0.9);
    --ach-hud-border: rgba(255, 255, 255, 0.12);
    --ach-locked-bg: rgba(30, 41, 59, 0.45);
    --ach-locked-border: rgba(255, 255, 255, 0.06);
    --ach-progress-bg: rgba(51, 65, 85, 0.5);
    --ach-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
    --ach-shadow-hover: 0 12px 36px 0 rgba(0, 0, 0, 0.6);
}

/* Container */
.afirin-achievements {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    color: var(--ach-text-main);
    padding-bottom: 50px;
}

/* Hero Header */
.ach-hero {
    border-radius: 20px;
    padding: 36px 30px;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(250, 71, 13, 0.12) 0%, rgba(107, 33, 168, 0.08) 50%, rgba(6, 182, 212, 0.06) 100%);
    border: 1px solid rgba(250, 71, 13, 0.2);
    box-shadow: var(--ach-shadow);
}

.ach-hero-content {
    position: relative;
    z-index: 2;
}

.ach-hero-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(250, 71, 13, 0.15);
    color: #fa470d;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 5px 12px;
    border-radius: 9999px;
    margin-bottom: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ach-hero-title {
    font-size: 2.3rem;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.ach-hero-subtitle {
    font-size: 1.05rem;
    color: var(--ach-text-muted);
    max-width: 620px;
    margin-bottom: 0;
}

/* Stats HUD */
.ach-hud-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.ach-hud-card {
    background: var(--ach-hud-bg);
    border: 1px solid var(--ach-hud-border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--ach-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ach-hud-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ach-shadow-hover);
}

.ach-hud-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.ach-hud-info {
    flex: 1;
    min-width: 0;
}

.ach-hud-val {
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.2;
}

.ach-hud-label {
    font-size: 0.82rem;
    color: var(--ach-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

/* Showcase Cabinet */
.ach-showcase-shelf {
    background: var(--ach-card-bg);
    border: 1px solid var(--ach-card-border);
    border-radius: 18px;
    padding: 24px;
    margin-bottom: 30px;
    box-shadow: var(--ach-shadow);
}

.ach-shelf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 10px;
}

.ach-shelf-title {
    font-size: 1.25rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ach-shelf-slots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.ach-shelf-card {
    background: linear-gradient(135deg, rgba(250, 71, 13, 0.04) 0%, rgba(139, 92, 246, 0.04) 100%);
    border: 1.5px dashed var(--ach-primary);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    transition: all 0.2s ease;
}

.ach-shelf-card.occupied {
    border-style: solid;
    border-color: var(--ach-card-border);
    background: var(--ach-card-bg);
}

.ach-shelf-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ach-shadow-hover);
}

/* Smart Goals Section */
.ach-goals-section {
    margin-bottom: 30px;
}

.ach-goals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.ach-goal-card {
    background: var(--ach-card-bg);
    border: 1px solid var(--ach-card-border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--ach-shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    position: relative;
    overflow: hidden;
}

.ach-goal-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    width: 100%;
    background: linear-gradient(90deg, #fa470d, #f59e0b);
}

/* Category Filter Tabs */
.ach-nav-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 24px;
    scrollbar-width: thin;
}

.ach-nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 9999px;
    background: var(--ach-hud-bg);
    border: 1px solid var(--ach-hud-border);
    color: var(--ach-text-main);
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.ach-nav-tab:hover {
    background: var(--ach-card-hover);
    color: var(--ach-primary);
}

.ach-nav-tab.active {
    background: var(--ach-primary);
    border-color: var(--ach-primary);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(250, 71, 13, 0.4);
}

/* Badge Cabinet Grid */
.ach-cabinet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 20px;
}

/* Badge Card */
.ach-card {
    background: var(--ach-card-bg);
    border: 1px solid var(--ach-card-border);
    border-radius: 18px;
    padding: 22px 18px;
    box-shadow: var(--ach-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
}

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

/* Locked Card Style */
.ach-card.locked {
    background: var(--ach-locked-bg);
    border-color: var(--ach-locked-border);
    opacity: 0.88;
}

.ach-card.locked .ach-medallion {
    filter: grayscale(85%) contrast(80%);
    opacity: 0.65;
}

/* Badge Medallion & Tiers */
.ach-medallion {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    position: relative;
    transition: transform 0.3s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.ach-card:hover .ach-medallion {
    transform: scale(1.08) rotate(3deg);
}

/* Tier: Bronze */
.ach-medallion.tier-bronze {
    background: linear-gradient(135deg, var(--ach-bronze-start), var(--ach-bronze-end));
    border: 3px solid var(--ach-bronze-border);
    box-shadow: 0 6px 20px var(--ach-bronze-glow);
    color: #fff;
}

/* Tier: Silver */
.ach-medallion.tier-silver {
    background: linear-gradient(135deg, var(--ach-silver-start), var(--ach-silver-end));
    border: 3px solid var(--ach-silver-border);
    box-shadow: 0 6px 20px var(--ach-silver-glow);
    color: #fff;
}

/* Tier: Gold */
.ach-medallion.tier-gold {
    background: linear-gradient(135deg, var(--ach-gold-start), var(--ach-gold-end));
    border: 3px solid var(--ach-gold-border);
    box-shadow: 0 6px 24px var(--ach-gold-glow);
    color: #fff;
}

/* Tier: Platinum */
.ach-medallion.tier-platinum {
    background: linear-gradient(135deg, var(--ach-platinum-start), var(--ach-platinum-end));
    border: 3px solid var(--ach-platinum-border);
    box-shadow: 0 6px 26px var(--ach-platinum-glow);
    color: #fff;
}

/* Tier: Diamond */
.ach-medallion.tier-diamond {
    background: linear-gradient(135deg, var(--ach-diamond-start), var(--ach-diamond-end));
    border: 3px solid var(--ach-diamond-border);
    box-shadow: 0 6px 28px var(--ach-diamond-glow);
    color: #fff;
}

.ach-tier-badge {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 9999px;
    margin-bottom: 8px;
    display: inline-block;
}

.ach-tier-badge.tier-bronze { background: rgba(217, 119, 6, 0.15); color: #d97706; }
.ach-tier-badge.tier-silver { background: rgba(148, 163, 184, 0.2); color: #64748b; }
.ach-tier-badge.tier-gold { background: rgba(245, 158, 11, 0.2); color: #d97706; }
.ach-tier-badge.tier-platinum { background: rgba(6, 182, 212, 0.18); color: #0284c7; }
.ach-tier-badge.tier-diamond { background: rgba(168, 85, 247, 0.2); color: #7e22ce; }

.ach-card-name {
    font-size: 1.12rem;
    font-weight: 800;
    margin-bottom: 6px;
    line-height: 1.25;
}

.ach-card-desc {
    font-size: 0.84rem;
    color: var(--ach-text-muted);
    margin-bottom: 14px;
    line-height: 1.4;
    flex: 1;
}

/* Progress bar inside badge card */
.ach-progress-wrap {
    width: 100%;
    margin-top: auto;
}

.ach-progress-bar-bg {
    width: 100%;
    height: 8px;
    background: var(--ach-progress-bg);
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 6px;
}

.ach-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #fa470d, #f59e0b);
    border-radius: 9999px;
    transition: width 0.4s ease;
}

.ach-progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--ach-text-muted);
}

/* Feature Pin Button */
.ach-feature-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #94a3b8;
}

.ach-feature-btn:hover {
    color: #f59e0b;
    transform: scale(1.15);
}

.ach-feature-btn.active {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
}

/* Unlocked Stamp */
.ach-earned-stamp {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #10b981;
    font-size: 0.78rem;
    font-weight: 700;
    margin-top: auto;
}

/* Modal Styling */
.ach-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.ach-modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.ach-modal-content {
    background: var(--ach-card-bg);
    border: 1px solid var(--ach-card-border);
    border-radius: 22px;
    padding: 32px 28px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    box-shadow: var(--ach-shadow-hover);
    transform: scale(0.92);
    transition: transform 0.2s ease;
    position: relative;
}

.ach-modal-backdrop.open .ach-modal-content {
    transform: scale(1);
}

.ach-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--ach-text-muted);
    cursor: pointer;
}

/* Toast / Unlock popup */
.ach-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ach-toast-card {
    background: var(--ach-card-bg);
    border: 1.5px solid #fa470d;
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 12px 32px rgba(250, 71, 13, 0.25);
    animation: achSlideUp 0.35s ease;
    max-width: 380px;
}

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

/* Responsive Styles */
@media (max-width: 768px) {
    .ach-hero-title {
        font-size: 1.8rem;
    }
    .ach-hud-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .ach-cabinet-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .ach-card {
        padding: 16px 12px;
    }
    .ach-medallion {
        width: 64px;
        height: 64px;
        font-size: 1.6rem;
    }
    .ach-card-name {
        font-size: 0.98rem;
    }
    .ach-card-desc {
        font-size: 0.78rem;
    }
}

@media (max-width: 430px) {
    .ach-cabinet-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .ach-hud-grid {
        grid-template-columns: 1fr;
    }
    .ach-shelf-slots {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 340px) {
    .ach-cabinet-grid {
        grid-template-columns: 1fr;
    }
}
