/* HiveReward Modern CSS Framework - Consolidated & Clean */

/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
  /* Colors - Dark Theme with Red & Turquoise */
  --bg-primary: #0b0b0d;
  --bg-secondary: #0f1012;
  --card-bg: #141417;
  --card-bg-light: #15171b;
  --text-primary: #f5f7fa;
  --text-muted: #a8b0b7;
  --text-dim: #cdd3df;
  --border-subtle: #1b1d22;
  --border-light: rgba(255, 255, 255, 0.06);
  --brand-red: #e50914;
  --brand-red-light: #ff2d2d;
  --brand-red-dark: #b80812;
  --accent-turq: #00d4ff;
  --accent-turq-light: #29d8e5;
  
  /* Gradients */
  --gradient-red: linear-gradient(180deg, var(--brand-red-light), var(--brand-red-dark));
  --gradient-dark: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0));
  --gradient-hero: linear-gradient(135deg, rgba(255,45,45,.18), rgba(41,216,229,.10));
  --gradient-bg: radial-gradient(1200px 600px at 10% -10%, rgba(229,9,20,.08), transparent 50%),
                 radial-gradient(1000px 500px at 90% -10%, rgba(0,212,255,.07), transparent 55%);
  
  /* Spacing & Layout */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --shadow-card: 0 4px 20px rgba(0,0,0,.25);
  --shadow-button: 0 4px 12px rgba(229,9,20,.25);
  --transition: all 0.2s ease;
  --transition-fast: all 0.1s ease;
}

/* ===== BASE STYLES ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--text-primary);
  background: var(--gradient-bg), var(--bg-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.75rem 0;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

h1 { font-size: 2.5rem; font-weight: 900; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
  margin: 0 0 1rem 0;
}

a {
  color: var(--accent-turq);
  text-decoration: none;
  transition: var(--transition-fast);
}

a:hover {
  text-decoration: underline;
  color: var(--accent-turq-light);
}

/* ===== LAYOUT COMPONENTS ===== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section {
  margin: 2rem 0;
}

/* Grid System */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* Flex Utilities */
.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-wrap {
  flex-wrap: wrap;
}

.gap-sm { gap: 0.5rem; }
.gap { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.gap-xl { gap: 2rem; }

/* ===== SIDEBAR NAVIGATION ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: var(--card-bg);
  border-right: 1px solid var(--border-subtle);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 2rem 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-link {
  text-decoration: none;
  color: var(--text-primary);
}

.brand-text {
  font-weight: 900;
  font-size: 1.5rem;
  letter-spacing: 0.02em;
}

.brand-highlight {
  color: var(--brand-red);
}

.sidebar-user {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.user-greeting {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.user-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-item.active {
  background: rgba(229, 9, 20, 0.08);
  border-left-color: var(--brand-red);
  color: var(--brand-red);
}

.nav-item.nav-logout:hover {
  background: rgba(229, 9, 20, 0.05);
  color: var(--brand-red);
}

.nav-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  flex-shrink: 0;
}

.nav-text {
  font-size: 0.95rem;
}

.nav-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.5rem 1.5rem;
}

/* Sidebar Leaderboard Widget */
.sidebar-leaderboard {
  margin: 1rem 0;
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.leaderboard-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.leaderboard-icon {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  color: var(--brand-red);
}

.leaderboard-period {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.leaderboard-fallback {
  color: var(--brand-red);
  font-weight: bold;
  margin-left: 0.25rem;
}

.leaderboard-list {
  margin-bottom: 0.75rem;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  transition: var(--transition-fast);
  border-radius: var(--radius-sm);
}

.leaderboard-item:hover {
  background: rgba(0, 212, 255, 0.05);
  border-radius: var(--radius-sm);
  margin: 0 -0.5rem;
  padding: 0.5rem;
  transform: translateX(2px);
}

.leaderboard-top {
  font-weight: 600;
}

.leaderboard-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.leaderboard-top .leaderboard-rank {
  background: var(--gradient-red);
  color: white;
  border-color: var(--brand-red-light);
  box-shadow: 0 2px 8px rgba(229, 9, 20, 0.3);
}

.leaderboard-user {
  flex: 1;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.leaderboard-total {
  font-weight: 600;
  color: var(--accent-turq);
  font-size: 0.8rem;
  text-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
}

.leaderboard-total .hive-token {
  color: var(--brand-red);
  font-weight: 700;
  margin-left: 0.25rem;
}

.leaderboard-view-all {
  display: block;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition-fast);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
}

.leaderboard-view-all:hover {
  color: var(--brand-red);
  background: rgba(229, 9, 20, 0.05);
  text-decoration: none;
  border-color: rgba(229, 9, 20, 0.2);
  transform: translateY(-1px);
}

.leaderboard-loading,
.leaderboard-empty,
.leaderboard-error {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 1rem 0;
  font-style: italic;
}

.leaderboard-error {
  color: var(--brand-red);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 150;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 0.75rem;
  cursor: pointer;
  display: none;
  flex-direction: column;
  gap: 4px;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-card);
}

.hamburger-line {
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all 0.3s ease;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Sidebar Overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Main Content Adjustment */
.main-content {
  margin-left: 0;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

/* Mobile Styles */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .mobile-menu-toggle {
    display: flex;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  /* Mobile Leaderboard Adjustments */
  .sidebar-leaderboard {
    padding: 0 1rem 1rem;
  }
  
  .leaderboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  
  .leaderboard-item {
    gap: 0.5rem;
    padding: 0.4rem 0;
  }
  
  .leaderboard-rank {
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
  }
  
  .leaderboard-user {
    font-size: 0.8rem;
  }
  
  .leaderboard-total {
    font-size: 0.75rem;
  }
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-fast);
  background: var(--gradient-red);
  color: white;
  box-shadow: var(--shadow-button);
  border: 1px solid rgba(229, 9, 20, 0.3);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(229, 9, 20, 0.4);
  text-decoration: none;
  filter: brightness(1.05);
}

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

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.4);
}

/* Button Variants */
.btn-secondary {
  background: linear-gradient(180deg, #1a1b1f, #101114);
  color: var(--text-primary);
  border-color: var(--border-light);
  box-shadow: var(--shadow-card);
}

.btn-secondary:hover {
  box-shadow: 0 8px 20px rgba(255, 45, 45, 0.15);
  border-color: rgba(229, 9, 20, 0.4);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--brand-red);
  color: var(--brand-red);
  box-shadow: none;
}

.btn-outline:hover {
  background: var(--brand-red);
  color: white;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  box-shadow: none;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--brand-red);
}

.btn-sm {
  padding: 0.5rem 0.875rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 1rem 1.5rem;
  font-size: 1rem;
}

/* ===== CARDS ===== */
.card {
  background: var(--gradient-dark), var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

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

.card-glow {
  box-shadow: 0 12px 30px rgba(229, 9, 20, 0.15), var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.card-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0.25rem 0 0 0;
}

.card-body {
  margin: 1rem 0;
}

.card-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 1.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: var(--transition);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-turq);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* ===== TABLES ===== */
.table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.table th {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-dim);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.table tr:last-child td {
  border-bottom: none;
}

/* ===== BADGES & STATUS ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-error {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-info {
  background: rgba(0, 212, 255, 0.2);
  color: #7dd3fc;
  border: 1px solid rgba(0, 212, 255, 0.3);
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-primary { color: var(--text-primary); }
.text-brand { color: var(--brand-red); }
.text-accent { color: var(--accent-turq); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Spacing */
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.ml-0 { margin-left: 0; }
.mr-0 { margin-right: 0; }

.p-0 { padding: 0; }
.pt-0 { padding-top: 0; }
.pb-0 { padding-bottom: 0; }
.pl-0 { padding-left: 0; }
.pr-0 { padding-right: 0; }

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
  .container {
    padding: 0 1rem;
  }
}

@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.25rem; }
}

@media (max-width: 480px) {
  .container {
    padding: 0 0.75rem;
  }
  
  .card {
    padding: 1rem;
  }
  
  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible for keyboard navigation */
.btn:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid var(--accent-turq);
  outline-offset: 2px;
}