/* ============================================
   SilkAI — Design System
   Dark theme, modern, premium feel
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- CSS Variables --- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a28;
  --bg-card-hover: #222233;
  --bg-input: #16161f;
  --border: #2a2a3d;
  --border-light: #333350;

  --text-primary: #f0f0f5;
  --text-secondary: #9090b0;
  --text-muted: #606080;

  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.3);

  --gradient-1: linear-gradient(135deg, #6c5ce7 0%, #fd79a8 100%);
  --gradient-2: linear-gradient(135deg, #00cec9 0%, #6c5ce7 100%);
  --gradient-3: linear-gradient(135deg, #fdcb6e 0%, #e17055 100%);
  --gradient-text: linear-gradient(135deg, #a29bfe 0%, #fd79a8 50%, #fdcb6e 100%);

  --success: #00b894;
  --warning: #fdcb6e;
  --error: #ff7675;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 40px rgba(108, 92, 231, 0.15);
}

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

html {
  scroll-behavior: smooth;
}

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

a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: #fff;
}

/* --- Typography --- */
h1,
h2,
h3,
h4 {
  font-weight: 700;
  line-height: 1.2;
}

.gradient-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Layout --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 100px 0;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-1);
  color: #fff;
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(108, 92, 231, 0.6);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  color: #fff;
}

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-danger {
  background: rgba(255, 118, 117, 0.15);
  color: var(--error);
  border: 1px solid rgba(255, 118, 117, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 118, 117, 0.25);
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: all 0.3s;
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-glow);
}

/* --- Forms --- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

/* --- Navigation --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 16px 0;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(42, 42, 61, 0.5);
}

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

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
}

.nav-logo-img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
  list-style: none;
}

.nav-links a {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.nav-links a:hover {
  color: #fff;
}

/* --- Hero --- */
.hero {
  padding: 160px 0 100px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: rgba(108, 92, 231, 0.1);
  border: 1px solid rgba(108, 92, 231, 0.3);
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-light);
  margin-bottom: 32px;
}

.hero h1 {
  font-size: clamp(40px, 6vw, 72px);
  font-weight: 900;
  margin-bottom: 24px;
  letter-spacing: -1px;
}

.hero-subtitle {
  font-size: 20px;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 40px;
  line-height: 1.7;
}

.hero-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 60px;
  margin-top: 80px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.hero-stat {
  text-align: center;
}

.hero-stat-value {
  font-size: 36px;
  font-weight: 800;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-stat-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Comparison Bar --- */
.comparison {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.comparison-card {
  text-align: center;
  padding: 32px;
}

.comparison-card .price-old {
  font-size: 28px;
  color: var(--text-muted);
  text-decoration: line-through;
}

.comparison-card .price-new {
  font-size: 42px;
  font-weight: 800;
  margin: 8px 0;
}

.comparison-card .savings {
  font-size: 15px;
  font-weight: 600;
  color: var(--success);
  padding: 4px 12px;
  background: rgba(0, 184, 148, 0.1);
  border-radius: 100px;
  display: inline-block;
}

/* --- Models Grid --- */
.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.model-card {
  position: relative;
  overflow: hidden;
}

.model-card .model-provider {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-light);
  margin-bottom: 8px;
}

.model-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.model-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.model-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.model-price {
  font-size: 13px;
  color: var(--text-muted);
}

.model-price strong {
  color: var(--success);
}

.model-context {
  font-size: 12px;
  padding: 4px 10px;
  background: rgba(108, 92, 231, 0.1);
  border-radius: 100px;
  color: var(--accent-light);
}

.model-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  border-radius: 100px;
  background: var(--gradient-1);
  color: #fff;
}

/* --- Code Block --- */
.code-section {
  background: var(--bg-secondary);
}

.code-block {
  background: #0d0d14;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  overflow-x: auto;
  position: relative;
}

.code-block pre {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.code-block .comment {
  color: var(--text-muted);
}

.code-block .keyword {
  color: var(--accent-light);
}

.code-block .string {
  color: #00b894;
}

.code-block .function {
  color: #fdcb6e;
}

.code-copy {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 6px 14px;
  font-size: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.code-copy:hover {
  background: var(--bg-card-hover);
  color: #fff;
}

/* --- Pricing --- */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  max-width: 960px;
  margin: 0 auto;
}

.pricing-card {
  text-align: center;
  padding: 40px 32px;
  position: relative;
}

.pricing-card.featured {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.pricing-card.featured::before {
  content: 'Most Popular';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--gradient-1);
  color: #fff;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.pricing-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.pricing-price {
  font-size: 48px;
  font-weight: 800;
  margin: 16px 0;
}

.pricing-price span {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
}

.pricing-features {
  list-style: none;
  margin: 24px 0;
  text-align: left;
}

.pricing-features li {
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pricing-features li::before {
  content: '✓';
  color: var(--success);
  font-weight: 700;
}

/* --- Footer --- */
.footer {
  padding: 60px 0 30px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 24px;
  list-style: none;
}

.footer-links a {
  font-size: 14px;
  color: var(--text-muted);
}

.footer-copy {
  font-size: 13px;
  color: var(--text-muted);
}

/* --- Dashboard Styles --- */
.dashboard {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 24px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 40px;
}

.sidebar-logo span {
  font-size: 24px;
}

.sidebar-nav {
  list-style: none;
  flex: 1;
}

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--bg-card);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(108, 92, 231, 0.15);
  color: var(--accent-light);
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px 40px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 28px;
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  padding: 24px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 800;
  margin-top: 8px;
}

.stat-card .stat-value.gradient {
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* API Key list */
.key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.key-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.key-name {
  font-weight: 600;
  font-size: 15px;
}

.key-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.key-actions {
  display: flex;
  gap: 8px;
}

/* Playground */
.playground {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.playground-panel {
  display: flex;
  flex-direction: column;
}

.playground textarea {
  width: 100%;
  min-height: 300px;
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  resize: vertical;
  outline: none;
}

.playground textarea:focus {
  border-color: var(--accent);
}

.playground-output {
  min-height: 300px;
  padding: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-y: auto;
  color: var(--text-secondary);
}

.playground-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}

.playground-controls select {
  padding: 10px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

/* Auth modal */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px;
  width: 440px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}

.auth-modal h2 {
  font-size: 28px;
  margin-bottom: 8px;
  text-align: center;
}

.auth-modal .auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}

.auth-toggle {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-muted);
}

.auth-toggle a {
  font-weight: 600;
}

.auth-error {
  padding: 12px;
  background: rgba(255, 118, 117, 0.1);
  border: 1px solid rgba(255, 118, 117, 0.3);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

/* Chart */
.chart-container {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 20px;
}

.chart-bar {
  flex: 1;
  background: var(--gradient-1);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 4px;
  position: relative;
  transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-bar:hover {
  opacity: 0.8;
}

.chart-bar-label {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.chart-bar-value {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Section headers */
.section-header {
  text-align: center;
  margin-bottom: 60px;
}

.section-header h2 {
  font-size: 36px;
  margin-bottom: 16px;
}

.section-header p {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--error);
}

@keyframes slideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .hero-stats {
    flex-direction: column;
    gap: 24px;
  }

  .nav-links {
    display: none;
  }

  .playground {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .models-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp 0.6s ease forwards;
}

.delay-1 {
  animation-delay: 0.1s;
}

.delay-2 {
  animation-delay: 0.2s;
}

.delay-3 {
  animation-delay: 0.3s;
}

.delay-4 {
  animation-delay: 0.4s;
}

/* Page view toggle (for dashboard sections) */
.page-view {
  display: none;
}

.page-view.active {
  display: block;
}

/* Responsive log table */
.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.log-table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}

.log-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(42, 42, 61, 0.3);
  color: var(--text-secondary);
}

.log-table tr:hover td {
  background: rgba(108, 92, 231, 0.05);
}

.status-badge {
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}

.status-badge.success {
  background: rgba(0, 184, 148, 0.15);
  color: var(--success);
}

.status-badge.error {
  background: rgba(255, 118, 117, 0.15);
  color: var(--error);
}