/* =========================================
   XZENTOSIA - MODERN DASHBOARD THEME
   Inspired by 5minLab / Game UI
   ========================================= */

:root {
  /* Palette */
  --bg-app: #121418;       /* Deepest background */
  --bg-panel: #1b1e24;     /* Card background */
  --bg-input: #0f1114;     /* Input background */
  
  --primary: #FFC107;      /* Smash Legends Yellow/Gold */
  --primary-hover: #ffca2c;
  --accent: #4fc3f7;       /* Cyan accent */
  
  --text-main: #ffffff;
  --text-muted: #8b9bb4;
  
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  --shadow-card: 0 4px 6px rgba(0, 0, 0, 0.2);
  --radius: 8px;           /* Sharper corners for game feel */
  
  /* Layout */
  --nav-height: 60px;
  --content-width: 1400px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
}

/* ================= NAV BAR ================= */
.navbar {
  height: var(--nav-height);
  background: #16181d;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-brand h1 {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.5px;
  color: #fff;
}

.nav-brand h1 span { color: var(--primary); }

.badge {
  background: #2a2e36;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
}

.nav-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-info small { color: var(--text-muted); font-size: 12px; }

.nav-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.nav-link:hover { text-decoration: underline; }

/* ================= SUB HEADER (TABS) ================= */
.sub-header {
  background: #1b1e24;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.tab-container {
  max-width: var(--content-width);
  margin: 0;
  display: flex;
  gap: 24px;
}

.tab-link {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 14px 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.tab-link:hover { color: #fff; }

.tab-link.active {
  color: var(--primary);
}

.tab-link.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

/* ================= MAIN LAYOUT ================= */
.main-content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 24px;
}

/* Animations */
.fade-in { animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* ================= SEARCH SECTION ================= */
.search-section {
  background: var(--bg-panel);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.section-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.input-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: #fff;
  padding: 0 16px;
  height: 44px;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  flex: 1;
  min-width: 200px;
}

.form-input:focus {
  border-color: var(--primary);
}

.btn-primary {
  background: var(--primary);
  color: #000;
  font-weight: 800;
  border: none;
  padding: 0 24px;
  height: 44px;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  font-size: 14px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-primary:hover { background: var(--primary-hover); }

.badge-cache {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: bold;
  color: var(--accent);
}
.badge-cache:not(:empty)::before {
  content: "Cached";
  margin-right: 6px;
  opacity: 0.7;
}

.status-line {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-family: monospace;
}

/* ================= DASHBOARD GRID ================= */
.dashboard-grid {
  display: grid;
  grid-template-columns: 350px 1fr; /* Fixed width user card, flexible heroes */
  gap: 24px;
  margin-bottom: 24px;
}

.dash-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.card-title {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border-left: 3px solid var(--primary);
  padding-left: 10px;
}

/* ================= USER PROFILE CARD (FINAL FIX) ================= */
.profile-layout {
  display: flex; /* Use Flexbox for clean left/right separation */
  align-items: flex-start; /* Align to top */
  gap: 24px; /* Big gap between images and text */
  margin-bottom: 20px;
  padding-left: 0; /* Ensures it starts at the very left */
}

/* --- LEFT COLUMN: VISUALS --- */
.profile-visuals {
  display: flex;
  flex-direction: column;
  gap: 12px; /* Space between Avatar and Banner */
  width: 180px; /* Fixed width matching the banner size */
  flex-shrink: 0; /* Prevents squishing */
}

/* Avatar - Left Aligned */
.profile-visuals .avatar {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  border: 2px solid var(--border);
  overflow: hidden;
  position: relative;
  background: #000;
  /* No margin: auto; keeps it left aligned */
}
.profile-visuals .avatar img.icon { width: 100%; height: 100%; object-fit: cover; }
.profile-visuals .avatar img.frame { position: absolute; top:0; left:0; width:100%; height:100%; pointer-events:none; }

/* Banner */
.clanbox {
  width: 100%; /* Fills the 180px container */
  height: 50px;
  display: flex;
  flex-direction: column;
}
.clan-banner {
  width: 100%;
  height: 100%;
  background: #0c0e12;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.clan-banner img { width: 100%; height: 100%; object-fit: cover; }
.clan-caption { display: none; } /* Hide caption to keep it clean */


/* --- RIGHT COLUMN: TEXT INFO --- */
.profile-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 8px; /* Slight offset to align with avatar top */
  gap: 6px;
}

/* Name */
.profile-info .name, 
.profile-info h2 {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  margin: 0;
  line-height: 1;
}

/* UID */
.profile-info .uid,
.profile-info p {
  font-size: 14px;
  color: var(--text-muted);
  font-family: monospace;
  font-weight: 700;
  margin: 0;
  background: rgba(255,255,255,0.06);
  padding: 4px 8px;
  border-radius: 4px;
  align-self: flex-start; /* Wraps tightly around text */
}

/* Date */
.profile-info .date {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.6;
  margin-top: 4px;
}

.clan-banner {
  width: 100%;
  height: 60px;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}
.clan-banner img { width: 100%; height: 100%; object-fit: cover; }
.clan-caption { 
  font-size: 12px; 
  color: var(--text-muted); 
  font-weight: 700; 
  margin-top: 6px; 
  margin-left: 2px;
}

/* Stats Grid */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 16px;
  margin-top: 0;
}

.stat-box {
  background: rgba(255,255,255,0.03);
  padding: 10px;
  border-radius: 4px;
}

.stat-box span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-box b {
  font-size: 16px;
  color: var(--primary);
}

/* ================= TOP HEROES SECTION (FIXED) ================= */
.top-heroes {
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-header h3 { 
  margin: 0; 
  font-size: 18px; 
  border-left: 4px solid var(--accent); 
  padding-left: 12px;
  line-height: 1;
}

.mode-indicator {
  background: rgba(255,255,255,0.08);
  padding: 6px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mode-icon-sm { width: 16px; height: 16px; object-fit: contain; display: none; }
.mode-indicator:has(.mode-icon-sm[src]) .mode-icon-sm { display: block; }
#modeTitle { font-size: 13px; font-weight: 700; color: #fff; }

#grandTotal {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 600;
  margin-top: -10px;
}

.heroes-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); 
  gap: 16px;
}

.hero {
  background: linear-gradient(145deg, rgba(35, 39, 46, 0.6), rgba(25, 28, 34, 0.9));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hero:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.3);
  border-color: rgba(255,255,255,0.2);
}

.hero img {
  width: 72px;
  height: 72px;
  background: #0c0e12;
  border-radius: 8px;
  object-fit: contain;
  border: 2px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.hero-info {
  flex: 1;
  min-width: 0;
}

.hero-name {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 12px;
  display: block;
  letter-spacing: 0.5px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 12px;
}

.hero-stats div {
  display: flex;
  flex-direction: column;
}

.hero-stats span {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 2px;
}

.hero-stats b {
  font-size: 15px;
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
}

.hero-stats > div:nth-child(n+5) {
  display: none; 
}

/* ================= CHARTS GRID (2x2 LAYOUT) ================= */
.charts-grid {
  display: grid;
  /* Creates 2 equal columns */
  grid-template-columns: repeat(2, 1fr); 
  gap: 24px;
  width: 100%;
}

.chart-container {
  min-height: 320px;
  display: flex;
  flex-direction: column;
  /* Ensures the chart stays contained within its grid cell */
  min-width: 0; 
}

.chart-wrapper {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
}

/* Responsive: Stack them nicely on smaller screens/tablets */
@media (max-width: 1000px) {
  .charts-grid {
    grid-template-columns: 1fr; /* Switch to 1 column */
  }
}

/* ================= RANK GRID ================= */
.rank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.rankcard {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 6px;
}

.rankhead {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.rankhead .s { font-weight: bold; color: var(--primary); }
.rankhead .pill { font-size: 11px; color: var(--text-muted); }

.rankbody { display: flex; align-items: center; gap: 10px; }
.rankimg { width: 48px; height: 48px; object-fit: contain; }
.rankmeta b { display: block; font-size: 14px; }
.rankmeta small { font-size: 12px; color: var(--text-muted); }

/* ================= CUSTOM DROPDOWN ================= */
.mode-dropdown {
  position: relative;
  min-width: 220px;
}
.modebtn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: #fff;
  padding: 0 16px;
  height: 44px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 14px;
}
.modemenu {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: #252932;
  border: 1px solid var(--border);
  border-radius: 4px;
  z-index: 50;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 4px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}
.modemenu li {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.modemenu li:hover { background: rgba(255,255,255,0.05); color: var(--primary); }

/* ================= FOOTER ================= */
.footer {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.banner-error {
  background: #e74c3c;
  color: #fff;
  text-align: center;
  padding: 12px;
  font-weight: bold;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    height: auto;
    padding: 12px;
    align-items: flex-start;
    gap: 12px;
  }
  
  .nav-info { width: 100%; justify-content: space-between; }
  
  .tab-container {
    gap: 16px;
    overflow-x: auto;
  }
  
  .input-group {
    flex-direction: column;
  }
  
  .btn-primary, .form-input, .mode-dropdown {
    width: 100%;
  }
  
  .main-content {
    padding: 16px;
  }
  
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .hero-stats {
    width: 100%;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}


/* Update the existing .stat-box span rule and add .stat-icon */
.stat-box span {
  display: flex;       /* Aligns icon next to text */
  align-items: center; /* Vertically centers them */
  gap: 6px;            /* Space between icon and text */
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-icon {
  width: 18px;         /* Icon size */
  height: 18px;
  object-fit: contain;
  opacity: 0.9;        /* Slight blend with dark theme */
}


/* ================= MODE DROPDOWN (STYLED) ================= */

/* host */
.mode-dropdown {
  position: relative;
  min-width: 220px;
  flex: 0 0 auto;
}

/* button */
.modebtn {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: #fff;
  height: 44px;
  border-radius: 4px;
  padding: 0 14px;

  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;

  font-size: 14px;
  font-weight: 700;
  transition: border-color 0.15s, background 0.15s;
}

.modebtn:hover {
  border-color: var(--border-hover);
}

.modebtn:focus-visible {
  outline: 2px solid rgba(255, 193, 7, 0.35);
  outline-offset: 2px;
}

/* label should take space */
#modeBtnLabel {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* caret */
.modebtn::after {
  content: "▾";
  opacity: 0.75;
  font-size: 12px;
  transform: translateY(-1px);
}

/* icons used in button + list */
.modeicon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex: 0 0 auto;
  opacity: 0.95;
}

/* menu */
.modemenu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  background: #252932;
  border: 1px solid var(--border);
  border-radius: 6px;
  z-index: 999;

  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  margin: 0;

  box-shadow: 0 14px 26px rgba(0,0,0,0.55);
}

/* items */
.modemenu li {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px 12px;
  border-radius: 6px;

  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #fff;

  transition: background 0.12s, color 0.12s, transform 0.12s;
}

.modemenu li:hover {
  background: rgba(255,255,255,0.06);
  color: var(--primary);
  transform: translateX(1px);
}

/* smooth scroll bar */
.modemenu::-webkit-scrollbar {
  width: 10px;
}
.modemenu::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
}
.modemenu::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.18);
}
