/* ============================================================
   The Ideal Code — Global Stylesheet
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #03030A;
  --bg-secondary: #08080F;
  --bg-tertiary: #0D0D1A;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --bg-input: rgba(255,255,255,0.05);
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.13);
  --glass: rgba(255,255,255,0.04);
  --text-primary: rgba(240,244,255,0.96);
  --text-secondary: rgba(240,244,255,0.58);
  --text-muted: rgba(240,244,255,0.3);
  --accent: #A855F7;
  --accent-hover: #c084fc;
  --accent-dark: #7e22ce;
  --accent-dim: rgba(168,85,247,0.1);
  --accent-border: rgba(168,85,247,0.3);
  --green: #10B981;
  --green-light: #34d399;
  --danger: #F43F5E;
  --amber: #F59E0B;
  --cyan: #22d3ee;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font: 'Satoshi', 'Inter', system-ui, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: var(--font); }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* --- Layout --- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.page-wrapper { padding-top: 80px; min-height: 100vh; }

/* --- Header --- */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid transparent;
  height: 64px;
  transition: background 0.35s ease, border-color 0.35s ease, backdrop-filter 0.35s ease;
}
.header.scrolled {
  background: rgba(3,3,10,0.7);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; height: 100%;
}
.header-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700;
}
.header-logo svg { color: var(--accent); }
.header-nav { display: flex; align-items: center; gap: 8px; }
.header-nav a {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  transition: all 0.2s;
}
.header-nav a:hover, .header-nav a.active {
  color: var(--text-primary); background: var(--bg-card-hover);
}
.header-actions { display: flex; align-items: center; gap: 12px; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  transition: all 0.2s; white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 50%, var(--accent-dark) 100%);
  color: #fff;
  box-shadow: 0 8px 28px rgba(168,85,247,0.35), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 36px rgba(168,85,247,0.5); }
.btn-secondary {
  background: var(--bg-card-hover); color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); background: rgba(255,255,255,0.08); }
.btn-ghost {
  color: var(--text-secondary); padding: 8px 16px;
}
.btn-ghost:hover { color: var(--text-primary); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-icon {
  width: 40px; height: 40px; padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-danger { background: rgba(244,63,94,0.1); color: var(--danger); border: 1px solid rgba(244,63,94,0.2); }
.btn-danger:hover { background: rgba(244,63,94,0.2); }

/* --- Cards --- */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.045) 0%, rgba(255,255,255,0.02) 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: inset 0 1px 0 rgba(168,85,247,0.08), 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
}
.card-hover { transition: all 0.2s; }
.card-hover:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }

/* --- Form Elements --- */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-label {
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
}
.input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px; color: var(--text-primary);
  transition: border-color 0.2s;
  outline: none; width: 100%;
}
.input:focus { border-color: var(--accent-border); }
.input::placeholder { color: var(--text-muted); }

.input-with-icon {
  position: relative;
}
.input-with-icon .input { padding-left: 40px; }
.input-with-icon .input-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}

/* --- Tabs --- */
.tabs {
  display: flex; gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.tab {
  flex: 1; padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s; text-align: center;
}
.tab:hover { color: var(--text-secondary); }
.tab.active {
  background: var(--bg-card-hover); color: var(--text-primary);
}

/* --- Badge --- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-emerald { background: rgba(16,185,129,0.1); color: var(--green); }
.badge-purple { background: var(--accent-dim); color: var(--accent); }
.badge-red { background: rgba(244,63,94,0.1); color: var(--danger); }
.badge-violet { background: rgba(139,92,246,0.1); color: #8b5cf6; }

/* --- Stat Card --- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}
.stat-card .stat-label {
  font-size: 13px; color: var(--text-muted); margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 28px; font-weight: 700; margin-bottom: 4px;
}
.stat-card .stat-change {
  font-size: 13px; display: flex; align-items: center; gap: 4px;
}
.stat-card .stat-change.positive { color: var(--green); }
.stat-card .stat-change.negative { color: var(--danger); }

/* --- Table --- */
.table-wrapper {
  overflow-x: auto;
}
table {
  width: 100%; border-collapse: collapse;
}
th {
  text-align: left; padding: 12px 16px;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 14px 16px;
  font-size: 14px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* --- Grid Helpers --- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* --- Toggle Switch --- */
.toggle {
  position: relative; width: 44px; height: 24px;
  background: rgba(255,255,255,0.1); border-radius: 12px;
  cursor: pointer; transition: background 0.2s;
}
.toggle.active { background: var(--accent); }
.toggle::after {
  content: ''; position: absolute;
  top: 2px; left: 2px; width: 20px; height: 20px;
  background: white; border-radius: 50%;
  transition: transform 0.2s;
}
.toggle.active::after { transform: translateX(20px); }

/* --- Range Slider --- */
input[type="range"] {
  -webkit-appearance: none; width: 100%; height: 6px;
  background: rgba(255,255,255,0.1); border-radius: 3px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  background: var(--accent); border-radius: 50%; cursor: pointer;
  border: 2px solid var(--bg-primary);
}

/* --- Color Input --- */
input[type="color"] {
  -webkit-appearance: none; border: none;
  width: 36px; height: 36px; border-radius: 8px;
  cursor: pointer; padding: 0;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border-radius: 6px; border: none; }

/* --- Dropdown Menu --- */
.dropdown {
  position: relative;
}
.dropdown-menu {
  position: absolute; top: 100%; right: 0;
  min-width: 180px; padding: 6px;
  background: rgba(10,10,18,0.96); backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  display: none; z-index: 50;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px;
  font-size: 14px; color: var(--text-secondary);
  transition: all 0.15s; width: 100%;
}
.dropdown-item:hover { background: rgba(168,85,247,0.08); color: var(--text-primary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: rgba(244,63,94,0.1); }

/* --- Section Headers --- */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.section-title { font-size: 22px; font-weight: 700; }
.section-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* --- Empty State --- */
.empty-state {
  text-align: center; padding: 60px 20px;
}
.empty-state .empty-icon {
  width: 64px; height: 64px; margin: 0 auto 20px;
  background: var(--accent-dim); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.empty-state h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }

/* --- Progress Bar --- */
.progress-bar {
  width: 100%; height: 6px;
  background: rgba(255,255,255,0.06); border-radius: 3px;
  overflow: hidden;
}
.progress-bar .progress-fill {
  height: 100%; background: var(--accent);
  border-radius: 3px; transition: width 0.3s;
}

/* --- Tooltip --- */
.tooltip {
  position: relative;
}
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  padding: 6px 12px; border-radius: 6px;
  background: rgba(10,10,18,0.96); border: 1px solid var(--border-hover);
  font-size: 12px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.tooltip:hover::after { opacity: 1; }

/* --- Ambient Orbs (global) --- */
@keyframes orbDrift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(60px, -40px) scale(1.08); }
  66% { transform: translate(-40px, 30px) scale(0.95); }
}
@keyframes orbDrift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-50px, 30px) scale(0.92); }
  66% { transform: translate(40px, -25px) scale(1.06); }
}
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(80px);
}
body::before {
  width: 600px;
  height: 600px;
  top: -8%;
  right: -6%;
  background: rgba(168,85,247,0.18);
  animation: orbDrift1 22s ease-in-out infinite;
}
body::after {
  width: 500px;
  height: 500px;
  bottom: -5%;
  left: -4%;
  background: rgba(34,211,238,0.12);
  animation: orbDrift2 28s ease-in-out infinite;
}
.page-wrapper, .auth-page { position: relative; z-index: 1; }

/* --- Animation --- */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-pulse { animation: pulse 2s infinite; }
.animate-spin { animation: spin 1s linear infinite; }
.fade-in { animation: fadeIn 0.3s ease-out; }

/* --- Skeleton Loading --- */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- Ecosystem Banner (compact, for secondary pages) --- */
.eco-banner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.05);
  background: rgba(255,255,255,0.015);
}
.eco-banner-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.3s;
  text-decoration: none;
}
.eco-banner-item:hover {
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  transform: translateY(-1px);
}
.eco-banner-item .eco-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.eco-banner-item .eco-icon.emerald {
  background: rgba(52,211,153,0.1);
  color: #34d399;
}
.eco-banner-item .eco-icon.violet {
  background: rgba(168,85,247,0.1);
  color: #a855f7;
}
.eco-banner-item .eco-icon.amber {
  background: rgba(251,191,36,0.1);
  color: #fbbf24;
}
.eco-banner-item .eco-icon.blue {
  background: rgba(96,165,250,0.1);
  color: #60a5fa;
}
.eco-banner-item .eco-icon.orange {
  background: rgba(245,158,11,0.1);
  color: #f59e0b;
}
.eco-banner-item .eco-icon.pink {
  background: rgba(236,72,153,0.1);
  color: #ec4899;
}
.eco-banner-item .eco-icon.cyan {
  background: rgba(34,211,238,0.1);
  color: #22d3ee;
}
.eco-banner-label {
  font-weight: 700;
}
.eco-banner-desc {
  color: var(--text-muted);
  font-weight: 400;
}
.eco-banner-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
}
@media (max-width: 768px) {
  .eco-banner {
    flex-wrap: wrap;
    gap: 8px;
  }
  .eco-banner-dot { display: none; }
  .eco-banner-item {
    padding: 6px 12px;
    font-size: 12px;
  }
  .eco-banner-desc { display: none; }
}

/* --- Mobile Menu Toggle --- */
.mobile-menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
}
.mobile-menu-toggle svg { width: 20px; height: 20px; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .header-nav { display: none; }
  .mobile-menu-toggle { display: flex; }
  .container { padding: 0 16px; }
  .page-wrapper { padding-top: 70px; }
  .header-actions .btn-secondary.btn-icon { display: none; }
  .section-title { font-size: 18px; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .card { padding: 18px; }
  .table-wrapper { -webkit-overflow-scrolling: touch; }
  .footer-bottom { flex-direction: column; gap: 12px; text-align: center; }
}
@media (max-width: 480px) {
  .container { padding: 0 12px; }
  .header-inner { padding: 0 12px; }
  .btn-lg { padding: 12px 20px; font-size: 14px; }
}
