/* CSS reset and custom variables */
:root {
    --bg-dark: #09090b;
    --card-bg: rgba(24, 24, 27, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    
    /* Currency Colors */
    --color-money: #10b981; /* Emerald */
    --color-money-glow: rgba(16, 185, 129, 0.15);
    --color-coins: #eab308; /* Gold */
    --color-coins-glow: rgba(234, 179, 8, 0.15);
    --color-purple: #8b5cf6; /* Violet */
    --color-purple-glow: rgba(139, 92, 246, 0.15);
    --color-blue: #3b82f6; /* Blue */
    --color-blue-glow: rgba(59, 130, 246, 0.15);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Starry background overlay */
.stars-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(1px 1px at 20px 30px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 40px 70px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 50px 160px, rgba(255,255,255,0.7), rgba(0,0,0,0)),
        radial-gradient(1px 1px at 90px 40px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 130px 80px, rgba(255,255,255,0.6), rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0.15;
    z-index: -3;
}

/* Glow Orbs */
.glow-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.12;
    z-index: -2;
    pointer-events: none;
    animation: pulseOrbs 12s infinite alternate ease-in-out;
}

.orb-1 {
    top: -10%;
    left: 10%;
    width: 400px;
    height: 400px;
    background-color: var(--color-purple);
}

.orb-2 {
    bottom: -10%;
    right: 10%;
    width: 450px;
    height: 450px;
    background-color: var(--color-blue);
}

@keyframes pulseOrbs {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.2) translate(30px, 30px); }
}

/* Glassmorphic Container */
.dashboard-container {
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Glass panel style */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Header styling */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
}

.server-logo {
    font-family: 'Outfit', sans-serif;
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--color-purple), var(--color-blue));
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.logo-text h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 1px;
}

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

/* Search bar styling */
.search-box {
    display: flex;
    align-items: center;
    background: rgba(9, 9, 11, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px 6px;
    width: 320px;
    max-width: 100%;
    transition: all 0.3s ease;
}

.search-box:focus-within {
    border-color: var(--color-purple);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

.search-icon {
    color: var(--text-secondary);
    margin-left: 12px;
    font-size: 14px;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    padding: 8px;
    flex-grow: 1;
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

.search-btn {
    background: linear-gradient(135deg, var(--color-purple), var(--color-blue));
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.search-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.search-btn:active {
    transform: translateY(0);
}

/* Cards Row */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.card {
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
}

.card-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.card-info h3 {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-value {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 700;
    margin-top: 4px;
}

/* Colored Card Accents */
.border-green { border-left: 4px solid var(--color-money); }
.border-green:hover { box-shadow: 0 8px 30px var(--color-money-glow); }
.icon-green { background: rgba(16, 185, 129, 0.1); color: var(--color-money); }
.text-green { color: var(--color-money); }

.border-gold { border-left: 4px solid var(--color-coins); }
.border-gold:hover { box-shadow: 0 8px 30px var(--color-coins-glow); }
.icon-gold { background: rgba(234, 179, 8, 0.1); color: var(--color-coins); }
.text-gold { color: var(--color-coins); }

.border-purple { border-left: 4px solid var(--color-purple); }
.border-purple:hover { box-shadow: 0 8px 30px var(--color-purple-glow); }
.icon-purple { background: rgba(139, 92, 246, 0.1); color: var(--color-purple); }
.text-purple { color: var(--color-purple); }

.border-blue { border-left: 4px solid var(--color-blue); }
.border-blue:hover { box-shadow: 0 8px 30px var(--color-blue-glow); }
.icon-blue { background: rgba(59, 130, 246, 0.1); color: var(--color-blue); }
.text-blue { color: var(--color-blue); }

/* Main views container */
.main-content {
    position: relative;
    width: 100%;
}

/* Main View Header (Dynamic Breadcrumb) */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 16px 24px;
}

.view-title-area {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.view-badge {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 6px;
}

.badge-global {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-money);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-player {
    background: rgba(139, 92, 246, 0.1);
    color: var(--color-purple);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

#view-title-text {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 600;
}

/* Grid layout for analytics */
.dashboard-grid {
    display: none;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dashboard-grid.active {
    display: grid;
    opacity: 1;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.panel-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-wrapper {
    width: 100%;
    position: relative;
}

/* Leaderboard List */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 8px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.leaderboard-item:hover {
    transform: translateX(4px);
    border-color: rgba(255, 255, 255, 0.15);
}

.item-rank {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--text-secondary);
    width: 30px;
}

.rank-1 { color: #facc15; }
.rank-2 { color: #cbd5e1; }
.rank-3 { color: #b45309; }

.item-name {
    flex-grow: 1;
    font-weight: 600;
    font-size: 14px;
}

.item-stats {
    text-align: right;
}

.item-stats .qty {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

.item-stats .rev {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Table styling */
.table-wrapper {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

th {
    color: var(--text-secondary);
    font-weight: 500;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

.td-player-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.td-player {
    font-weight: 600;
    color: var(--color-blue);
    cursor: pointer;
    transition: color 0.2s ease;
}

.td-player:hover {
    color: var(--color-purple);
    text-decoration: underline;
}

.player-avatar-table {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    object-fit: cover;
    object-position: top center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}


.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-money {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-money);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-coins {
    background: rgba(234, 179, 8, 0.1);
    color: var(--color-coins);
    border: 1px solid rgba(234, 179, 8, 0.2);
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 12px;
    color: #ef4444;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* User profile detailed view */
.user-header-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.back-btn {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    outline: none;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.user-profile-header {
    display: flex;
    align-items: center;
    gap: 18px;
}

.player-avatar-bust {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
    object-fit: cover;
    object-position: top center;
    padding: 2px;
}

.user-profile-details h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 700;
}

.user-profile-details p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}


/* Item breakdown breakdown item styles */
.item-breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.breakdown-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.breakdown-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
}

.breakdown-info span:first-child {
    font-weight: 600;
}

.breakdown-info span:last-child {
    color: var(--text-secondary);
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--color-purple), var(--color-blue));
    width: 0;
    transition: width 0.8s ease;
}

/* Spinner and helpers */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 40px;
}

.no-data-msg {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 40px;
}

.margin-top {
    margin-top: 30px;
}

/* Footer style */
.main-footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-secondary);
    font-size: 12px;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Minecraft Item Icons styling */
.item-icon-leaderboard {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    margin-right: 12px;
    object-fit: contain;
    flex-shrink: 0;
}

.td-item-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.item-icon-table {
    width: 22px;
    height: 22px;
    image-rendering: pixelated;
    object-fit: contain;
    flex-shrink: 0;
}

.item-name-with-icon {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.item-icon-breakdown {
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
    object-fit: contain;
    flex-shrink: 0;
}

/* Users View UI Additions */
.view-users-btn {
    align-self: flex-start;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.4);
    outline: none;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.view-users-btn:hover {
    background: rgba(139, 92, 246, 0.3);
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.25);
}

.chart-toggle-buttons {
    display: flex;
    gap: 8px;
}

.toggle-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.toggle-btn.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--color-purple);
    color: var(--text-primary);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.15);
}

.glass-select {
    background: rgba(9, 9, 11, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass-select:focus {
    border-color: var(--color-purple);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.2);
}

.glass-select option {
    background: #18181b;
    color: var(--text-primary);
}

.user-avatar-leaderboard {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    object-position: top center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

/* Logout Button */
.logout-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    outline: none;
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.25);
}

.logout-btn:active {
    transform: scale(0.97);
}

/* ==========================================================================
   Responsive Mobile & Tablet Layout Overrides
   ========================================================================== */

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column;
        gap: 20px;
    }
    
    .left-col, .right-col {
        width: 100% !important;
    }
    
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        padding: 16px 12px;
        gap: 16px;
    }
    
    .glass-panel {
        padding: 16px;
    }
    
    .main-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        text-align: center;
    }
    
    .logo-area {
        justify-content: center;
    }
    
    .search-area {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 12px;
    }
    
    .search-box {
        width: 100%;
    }
    
    .logout-btn {
        width: 100%;
        justify-content: center;
    }
    
    .view-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 16px;
        padding: 16px;
    }
    
    .view-title-area {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    
    .view-users-btn, .back-btn {
        width: 100%;
        justify-content: center;
    }
    
    .stats-overview {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        text-align: center;
    }
    
    .panel-header h2 {
        justify-content: center;
    }
    
    .chart-toggle-buttons {
        display: flex;
        width: 100%;
        gap: 8px;
    }
    
    .toggle-btn {
        flex: 1;
        justify-content: center;
    }
    
    .sort-container {
        width: 100%;
    }
    
    .glass-select {
        width: 100%;
        text-align: center;
    }
    
    /* Player Profile Responsive details */
    .user-profile-header {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }
    
    .player-avatar-bust {
        margin: 0 auto;
        width: 70px;
        height: 70px;
    }
    
    .user-profile-details {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .server-logo {
        width: 44px;
        height: 44px;
        font-size: 22px;
        border-radius: 10px;
    }
    
    .logo-text h1 {
        font-size: 20px;
    }
    
    .logo-text p {
        font-size: 11px;
    }
    
    #view-title-text {
        font-size: 15px;
    }
    
    .card {
        padding: 14px;
        gap: 12px;
    }
    
    .card-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .card-value {
        font-size: 20px;
    }
    
    .main-footer {
        font-size: 11px;
        text-align: center;
    }
}

