/* Reset and Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #8b5cf6;
  --dark: #0f172a;
  --dark-light: #1e293b;
  --gray: #64748b;
  --light: #f1f5f9;
  --white: #ffffff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--dark);
  background: var(--light);
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Navigation */
.navbar {
  background: var(--white);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--dark);
  text-decoration: none;
}

.nav-logo img {
  width: 40px;
  height: 40px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-links a {
  color: var(--gray);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--primary);
}

.nav-links a.btn-primary {
  color: var(--white);
  background: var(--gradient);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
}

.nav-links a.btn-primary:hover {
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

/* Hero Section */
.hero {
  background: var(--gradient);
  color: var(--white);
  padding: 60px 20px 40px;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.hero p {
  font-size: 1.15rem;
  opacity: 0.95;
}

/* Examples Section */
.examples-section {
  padding: 40px 20px 80px;
}

.examples-section .container {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
  align-items: start;
}

/* Sidebar */
.examples-sidebar {
  position: sticky;
  top: 100px;
  background: var(--white);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.examples-sidebar h3 {
  margin-bottom: 1rem;
  color: var(--dark);
  font-size: 1.1rem;
}

.example-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.example-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}

.example-nav-item:hover {
  background: var(--light);
}

.example-nav-item.active {
  background: var(--gradient);
  color: var(--white);
}

.example-number {
  font-weight: 700;
  font-size: 0.85rem;
  opacity: 0.7;
}

.example-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
}

.difficulty-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
}

.example-nav-item.active .difficulty-badge {
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
}

.difficulty-badge.beginner {
  background: #d1fae5;
  color: #065f46;
}

.difficulty-badge.intermediate {
  background: #fef3c7;
  color: #92400e;
}

.difficulty-badge.advanced {
  background: #fee2e2;
  color: #991b1b;
}

/* Example Display */
.example-display {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

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

.example-header h2 {
  font-size: 1.75rem;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.example-header p {
  color: var(--gray);
  font-size: 1rem;
}

.btn-try-large {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  background: var(--gradient);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn-try-large:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.3);
}

/* Code Tabs */
.code-tabs {
  display: flex;
  border-bottom: 2px solid var(--light);
  background: #fafafa;
}

.code-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-weight: 600;
  color: var(--gray);
  transition: all 0.2s;
}

.code-tab:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.code-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--white);
}

.tab-icon {
  font-size: 1.2rem;
}

/* Code Container */
.code-container {
  position: relative;
  background: var(--dark);
  max-height: 500px;
  overflow: auto;
}

.code-section {
  display: none;
  padding: 1.5rem;
}

.code-section.active {
  display: block;
}

.code-section pre {
  margin: 0;
  font-family: 'Courier New', Consolas, Monaco, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #e2e8f0;
}

.code-section code {
  display: block;
  white-space: pre;
  color: #e2e8f0;
}

/* Preview Section */
.preview-section {
  border-top: 1px solid var(--light);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: #fafafa;
  border-bottom: 1px solid var(--light);
}

.preview-header h3 {
  font-size: 1rem;
  color: var(--dark);
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--white);
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  color: var(--gray);
  transition: all 0.2s;
}

.btn-refresh:hover {
  border-color: var(--primary);
  color: var(--primary);
}

#previewFrame {
  width: 100%;
  height: 400px;
  border: none;
  background: var(--white);
}

/* Footer */
.footer {
  background: var(--dark);
  color: var(--light);
  padding: 40px 20px;
  text-align: center;
  margin-top: 60px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
}

.footer-links a {
  color: var(--gray);
  text-decoration: none;
  transition: color 0.3s;
}

.footer-links a:hover {
  color: var(--primary);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .examples-section .container {
    grid-template-columns: 1fr;
  }

  .examples-sidebar {
    position: static;
  }

  .example-nav {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 768px) {
  .nav-links a:not(.btn-primary) {
    display: none;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .example-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .btn-try-large {
    width: 100%;
    justify-content: center;
  }

  .code-tabs {
    overflow-x: auto;
  }

  .example-nav {
    grid-template-columns: 1fr;
  }

  .footer-links {
    flex-direction: column;
    gap: 0.5rem;
  }
}
