/**
 * Polymarket Pro - Premium Responsive Enhancement
 * Touch-friendly, mobile-first design improvements
 * 
 * Design Principles:
 * - Pure BLACK backgrounds (#000000 / #0a0a0a)
 * - GOLD accents (#FFD700, #DAA520, #B8860B)
 * - NO green except for profit numbers
 * - Minimum 44-48px touch targets
 * - Premium, luxurious feel
 */

/* ============================================
   CSS CUSTOM PROPERTIES - Enhanced
   ============================================ */
:root {
  /* Touch-friendly sizing */
  --touch-target-min: 48px;
  --touch-target-sm: 44px;
  --button-padding-y: 0.875rem;
  --button-padding-x: 1.5rem;
  
  /* Spacing scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Enhanced Gold palette */
  --gold-primary: #FFD700;
  --gold-light: #FFED4A;
  --gold-dark: #B8860B;
  --gold-muted: #DAA520;
  --gold-glow: rgba(255, 215, 0, 0.4);
  --gold-subtle: rgba(255, 215, 0, 0.1);
  
  /* Backgrounds - Pure black */
  --bg-pure-black: #000000;
  --bg-black: #0a0a0a;
  --bg-card: #0d0d0d;
  --bg-elevated: #111111;
  --bg-surface: #141414;
  --bg-hover: #1a1a1a;
  
  /* Typography scale for mobile */
  --font-size-base: 16px;
  --font-size-sm: 14px;
  --font-size-xs: 12px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 30px;
}

/* ============================================
   BASE RESPONSIVE TYPOGRAPHY
   ============================================ */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-size: var(--font-size-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (max-width: 640px) {
  body {
    font-size: var(--font-size-base); /* Keep 16px on mobile to prevent zoom */
  }
}

/* ============================================
   SIDEBAR - Premium Touch-Friendly
   ============================================ */
.sidebar {
  background: var(--bg-pure-black);
  border-right: 1px solid rgba(255, 215, 0, 0.15);
}

/* Sidebar Header */
.sidebar .h-16 {
  height: 4.5rem;
  padding: 0.75rem 1rem;
}

/* Logo styling */
.sidebar .w-10.h-10 {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.25);
}

/* Navigation Items - Enhanced */
.nav-item {
  min-height: var(--touch-target-min) !important;
  padding: 0.875rem 1rem !important;
  margin: 0.25rem 0;
  border-radius: 12px !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: #B3B3B3;
  transition: all 0.2s ease;
  border-left: 3px solid transparent !important;
}

.nav-item:hover {
  background: rgba(255, 215, 0, 0.08) !important;
  color: var(--gold-primary) !important;
}

.nav-item.active {
  background: rgba(255, 215, 0, 0.12) !important;
  color: var(--gold-primary) !important;
  border-left-color: var(--gold-primary) !important;
}

/* Nav Item Icons - Gold filled style */
.nav-item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  stroke-width: 2;
  transition: all 0.2s ease;
}

.nav-item:hover svg,
.nav-item.active svg {
  color: var(--gold-primary);
  filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.3));
}

/* Badges - Gold styling, hide zeros */
.nav-item .ml-auto {
  font-size: 11px;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  min-width: 1.5rem;
  text-align: center;
}

/* Hide badges with "0" */
.nav-item .ml-auto:empty,
.nav-item .ml-auto[data-count="0"] {
  display: none !important;
}

/* Gold badges */
.badge-gold-premium {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(184, 134, 11, 0.15) 100%);
  color: var(--gold-primary) !important;
  border: 1px solid rgba(255, 215, 0, 0.3);
  font-size: 10px;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

/* Badge count - hide when zero */
.badge-count {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(184, 134, 11, 0.15) 100%);
  color: var(--gold-primary);
  border: 1px solid rgba(255, 215, 0, 0.3);
  font-size: 11px;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  min-width: 1.5rem;
  text-align: center;
}

.badge-count[data-count="0"],
.badge-count:empty {
  display: none !important;
}

/* Section labels */
.sidebar .text-xs.text-slate-500 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
  padding: 1rem 0.5rem 0.5rem;
  margin-top: 0.5rem;
}

/* Sidebar nav spacing */
.sidebar nav ul {
  padding: 0 0.5rem;
}

.sidebar nav ul li {
  margin-bottom: 2px;
}

/* ============================================
   BUTTONS - Premium Touch-Friendly
   ============================================ */
/* Base button styles */
button,
.btn,
[role="button"] {
  min-height: var(--touch-target-sm);
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Primary Gold Button */
.btn-gold,
.btn-primary,
.bg-gold-600,
.bg-gold-500,
button[class*="bg-gold"] {
  background: linear-gradient(135deg, #FFD700 0%, #DAA520 50%, #B8860B 100%) !important;
  color: #0a0a0a !important;
  font-weight: 700;
  padding: var(--button-padding-y) var(--button-padding-x);
  border-radius: 14px;
  border: none;
  box-shadow: 
    0 4px 15px rgba(255, 215, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.btn-gold::before,
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.btn-gold:hover,
.btn-primary:hover,
.bg-gold-600:hover,
.bg-gold-500:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 8px 25px rgba(255, 215, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-gold:hover::before,
.btn-primary:hover::before {
  opacity: 1;
}

.btn-gold:active,
.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(255, 215, 0, 0.2);
}

/* Secondary/Outline Gold Button */
.btn-gold-outline,
.btn-secondary {
  background: transparent !important;
  color: var(--gold-primary) !important;
  border: 2px solid var(--gold-dark) !important;
  padding: var(--button-padding-y) var(--button-padding-x);
  border-radius: 14px;
  font-weight: 600;
}

.btn-gold-outline:hover,
.btn-secondary:hover {
  background: rgba(255, 215, 0, 0.1) !important;
  border-color: var(--gold-primary) !important;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

/* Ghost/Tertiary Button */
.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: #E5E5E5;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: var(--button-padding-y) var(--button-padding-x);
  border-radius: 12px;
}

.btn-ghost:hover {
  background: rgba(255, 215, 0, 0.08);
  border-color: rgba(255, 215, 0, 0.3);
  color: var(--gold-primary);
}

/* Icon Buttons */
.btn-icon,
button.p-2,
button.p-1\.5 {
  min-width: var(--touch-target-sm);
  min-height: var(--touch-target-sm);
  padding: 0.625rem;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   CARDS - Premium Touch-Friendly
   ============================================ */
.market-card,
.card,
.card-premium,
.event-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 215, 0, 0.08);
  border-radius: 16px;
  padding: 1.25rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

/* Gold accent bar on left */
.market-card::before,
.event-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, #FFD700 0%, #B8860B 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 16px 0 0 16px;
}

.market-card:hover,
.card:hover,
.card-premium:hover,
.event-card:hover {
  border-color: rgba(255, 215, 0, 0.25);
  transform: translateY(-4px);
  box-shadow: 
    0 12px 40px -10px rgba(0, 0, 0, 0.5),
    0 0 30px -5px rgba(255, 215, 0, 0.15);
}

.market-card:hover::before,
.event-card:hover::before {
  opacity: 1;
}

/* Card content spacing */
.market-card h3,
.card h3,
.event-card h3 {
  font-size: var(--font-size-base);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

/* Price displays - BIGGER */
.price-large,
.text-gold-400.text-lg,
.text-gold-400.text-2xl,
.market-card .text-lg.font-bold {
  font-size: var(--font-size-2xl) !important;
  font-weight: 700;
  background: linear-gradient(135deg, #FFD700 0%, #DAA520 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================
   STAT CARDS - Premium Enhancement
   ============================================ */
.stat-card,
.stat-card-premium {
  background: linear-gradient(145deg, #0d0d0d 0%, #080808 100%);
  border: 1px solid rgba(255, 215, 0, 0.1);
  border-radius: 16px;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}

.stat-card::before,
.stat-card-premium::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #FFD700, transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat-card:hover::before,
.stat-card-premium:hover::before {
  opacity: 1;
}

.stat-card .stat-value,
.stat-card-premium .stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  background: linear-gradient(135deg, #FFD700 0%, #B8860B 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card .stat-label,
.stat-card-premium .stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 0.5rem;
}

/* ============================================
   MOBILE BOTTOM NAVIGATION
   ============================================ */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 215, 0, 0.15);
  padding: 0.5rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  z-index: 1000;
}

@media (max-width: 1023px) {
  .mobile-bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
  }
  
  /* Add padding to main content for bottom nav */
  main {
    padding-bottom: 5rem;
  }
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0.5rem 0.25rem;
  border-radius: 12px;
  color: #888;
  text-decoration: none;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item svg {
  width: 24px;
  height: 24px;
  margin-bottom: 0.25rem;
  stroke-width: 2;
}

.mobile-nav-item span {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.mobile-nav-item.active,
.mobile-nav-item:active {
  color: var(--gold-primary);
  background: rgba(255, 215, 0, 0.1);
}

.mobile-nav-item.active svg {
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.5));
}

/* ============================================
   MOBILE HEADER - Enhanced
   ============================================ */
.mobile-header {
  background: rgba(0, 0, 0, 0.95) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 215, 0, 0.15) !important;
  height: 60px !important;
  padding: 0 1rem !important;
}

.mobile-header button {
  min-width: 44px;
  min-height: 44px;
}

/* ============================================
   RESPONSIVE GRID - Card Stacking
   ============================================ */
#events-grid,
#markets-grid,
.grid {
  display: grid;
  gap: 1rem;
}

/* Mobile: Single column */
@media (max-width: 639px) {
  #events-grid,
  #markets-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem;
  }
  
  .market-card,
  .event-card {
    padding: 1rem;
  }
}

/* Tablet: 2 columns */
@media (min-width: 640px) and (max-width: 1023px) {
  #events-grid,
  #markets-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem;
  }
}

/* Desktop: 3 columns */
@media (min-width: 1024px) {
  #events-grid,
  #markets-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1.25rem;
  }
}

/* Large Desktop: 4 columns */
@media (min-width: 1440px) {
  #events-grid,
  #markets-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

/* ============================================
   FORM INPUTS - Touch Friendly
   ============================================ */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
  min-height: var(--touch-target-sm);
  padding: 0.875rem 1rem;
  font-size: var(--font-size-base); /* Prevent iOS zoom */
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  transition: all 0.2s ease;
  -webkit-appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold-muted);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.15);
}

/* Select dropdown arrow */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23FFD700'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

/* ============================================
   MODAL / DRAWER - Mobile Friendly
   ============================================ */
#market-detail {
  width: 100%;
  max-width: 480px;
  background: var(--bg-black);
  border-left: 1px solid rgba(255, 215, 0, 0.15);
}

@media (max-width: 639px) {
  #market-detail {
    max-width: 100%;
    border-left: none;
    border-top: 1px solid rgba(255, 215, 0, 0.15);
  }
}

/* ============================================
   TABS - Touch Friendly
   ============================================ */
.filter-tab,
.view-toggle,
.tab {
  min-height: var(--touch-target-sm);
  padding: 0.75rem 1.25rem;
  font-size: var(--font-size-sm);
  font-weight: 600;
  border-radius: 10px;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.filter-tab.tab-active,
.view-toggle.active,
.tab.active {
  background: rgba(255, 215, 0, 0.15);
  color: var(--gold-primary);
  border-bottom-color: var(--gold-primary);
}

/* Tab container scrollable on mobile */
.flex.items-center.space-x-1.border-b {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 0.5rem;
}

.flex.items-center.space-x-1.border-b::-webkit-scrollbar {
  display: none;
}

/* ============================================
   PROGRESS BARS - Enhanced
   ============================================ */
.progress,
.h-2.bg-slate-800 {
  height: 8px;
  border-radius: 4px;
  background: var(--bg-hover);
  overflow: hidden;
}

.progress-bar,
.h-full.bg-gradient-to-r {
  background: linear-gradient(90deg, #FFD700 0%, #B8860B 100%);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ============================================
   WEBSOCKET STATUS - Premium
   ============================================ */
.ws-status {
  min-height: 36px;
  padding: 0.5rem 0.875rem;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
}

.ws-status.connected {
  background: rgba(255, 215, 0, 0.15);
  color: var(--gold-primary);
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.ws-status .dot {
  width: 8px;
  height: 8px;
  background: var(--gold-primary);
  box-shadow: 0 0 8px var(--gold-primary);
}

/* ============================================
   BADGES - Gold Only (no green except profit)
   ============================================ */
.badge,
.px-2.py-0\.5.rounded-full,
span[class*="bg-"][class*="text-"][class*="rounded"] {
  font-size: 11px;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
}

/* Override green badges to gold (except profit indicators) */
.bg-green-500\/20:not(.profit-badge),
.bg-emerald-500\/20:not(.profit-badge) {
  background: rgba(255, 215, 0, 0.15) !important;
}

.text-green-400:not(.profit-badge):not(.price-up):not(.stat-change-positive),
.text-emerald-400:not(.profit-badge):not(.price-up):not(.stat-change-positive) {
  color: var(--gold-primary) !important;
}

/* Keep green only for actual profit/positive changes */
.price-up,
.stat-change-positive,
.profit-badge {
  color: #00C853 !important;
}

/* ============================================
   SCROLLBAR - Premium Gold
   ============================================ */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-black);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #FFD700 0%, #B8860B 100%);
  border-radius: 5px;
  border: 2px solid var(--bg-black);
}

::-webkit-scrollbar-thumb:hover {
  background: #FFD700;
}

/* ============================================
   ANIMATIONS - Smooth & Premium
   ============================================ */
@keyframes goldGlow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
  }
  50% {
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.4);
  }
}

.glow-gold-animated {
  animation: goldGlow 2s ease-in-out infinite;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.touch-target {
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
}

.touch-target-sm {
  min-width: var(--touch-target-sm);
  min-height: var(--touch-target-sm);
}

.gold-gradient-text {
  background: linear-gradient(135deg, #FFD700 0%, #DAA520 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gold-border {
  border-color: rgba(255, 215, 0, 0.3);
}

.gold-border-hover:hover {
  border-color: rgba(255, 215, 0, 0.5);
}

/* Safe area insets for modern phones */
@supports (padding: env(safe-area-inset-bottom)) {
  .mobile-bottom-nav {
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  }
  
  .sidebar {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ============================================
   DARK MODE ENFORCEMENT
   ============================================ */
@media (prefers-color-scheme: light) {
  /* Force dark mode regardless of system preference */
  body,
  html {
    background: var(--bg-black) !important;
    color: #E5E5E5 !important;
  }
}

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

/* ============================================
   PRINT STYLES - Hide interactive elements
   ============================================ */
@media print {
  .mobile-bottom-nav,
  .sidebar,
  .mobile-header,
  button,
  .btn {
    display: none !important;
  }
}
