/* ============================================
   Custom Styles for FreeCodeTutorials.com
   ============================================ */

/* ===== Color Variables ===== */
:root {
  --primary-brand: #2563eb;
  --primary-brand-hover: #1d4ed8;
  --secondary-brand: #7c3aed;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --code-bg-light: #f8fafc;
  --code-bg-dark: #1e293b;
  --link-color: #2563eb;
  --link-hover: #1d4ed8;
}

[data-bs-theme="dark"] {
  --code-bg-light: #1e293b;
  --code-bg-dark: #0f172a;
}

/* ===== Typography Improvements ===== */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.7;
  letter-spacing: 0.01em;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; line-height: 1.2; }
h2 { font-size: 2rem; line-height: 1.3; }
h3 { font-size: 1.5rem; line-height: 1.4; }

article p {
  margin-bottom: 1.5rem;
  font-size: 1.05rem;
}

/* ===== Code Block Styling ===== */
pre {
  background: var(--code-bg-light);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  border: 1px solid rgba(0, 0, 0, 0.1);
  position: relative;
}

[data-bs-theme="dark"] pre {
  background: var(--code-bg-dark);
  border-color: rgba(255, 255, 255, 0.1);
}

code {
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 0.9em;
  font-feature-settings: "liga" 1, "calt" 1;
}

pre code {
  font-size: 0.875rem;
  line-height: 1.6;
}

/* Inline code */
p code, li code, td code {
  background: rgba(135, 131, 120, 0.15);
  color: #eb5757;
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

[data-bs-theme="dark"] p code,
[data-bs-theme="dark"] li code,
[data-bs-theme="dark"] td code {
  background: rgba(255, 255, 255, 0.1);
  color: #ff8a8a;
}

/* Copy button for code blocks */
.code-copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-bs-theme="dark"] .code-copy-button {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

pre:hover .code-copy-button {
  opacity: 1;
}

.code-copy-button:hover {
  background: rgba(255, 255, 255, 1);
}

[data-bs-theme="dark"] .code-copy-button:hover {
  background: rgba(30, 41, 59, 1);
}

.code-copy-button.copied {
  background: var(--accent-green);
  color: white;
  border-color: var(--accent-green);
}

/* ===== Link Improvements ===== */
article a:not(.btn):not(.badge):not(.card-link) {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

article a:not(.btn):not(.badge):not(.card-link):hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

/* ===== Card Enhancements ===== */
.card {
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
  overflow: hidden;
  height: 100%;
}

[data-bs-theme="dark"] .card {
  border-color: rgba(255, 255, 255, 0.1);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

[data-bs-theme="dark"] .card:hover {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
}

.card-body {
  padding: 1.5rem;
}

/* Homepage cards - compact padding */
.row.g-4 > [class*="col-"] > .card > .card-body.p-3 {
  padding: 0.75rem !important;
}

/* Homepage card title - remove top margin */
.row.g-4 > [class*="col-"] > .card .card-title {
  margin-top: 0 !important;
  font-size: 1.1rem;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* ===== Hero Section ===== */
.hero-section {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 16px;
  margin-bottom: 3rem;
}

[data-bs-theme="dark"] .hero-section {
  background: linear-gradient(135deg, #4338ca 0%, #6b21a8 100%);
}

.hero-section h1 {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hero-section .btn-primary {
  background: white;
  color: #667eea;
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.hero-section .btn-primary:hover {
  background: #f8f9fa;
  transform: translateY(-2px);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.hero-section .btn-outline-secondary {
  border-color: white;
  color: white;
}

.hero-section .btn-outline-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: white;
  color: white;
}

/* ===== Button Improvements ===== */
.btn {
  border-radius: 8px;
  padding: 0.625rem 1.5rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary-brand);
  border-color: var(--primary-brand);
}

.btn-primary:hover {
  background: var(--primary-brand-hover);
  border-color: var(--primary-brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

/* ===== Badge Improvements ===== */
.badge {
  font-weight: 500;
  padding: 0.4em 0.8em;
  border-radius: 6px;
  font-size: 0.875rem;
}

.difficulty-badge {
  display: inline-block;
  margin-left: 0.5rem;
}

.difficulty-beginner {
  background: var(--accent-green);
  color: white;
}

.difficulty-intermediate {
  background: var(--accent-orange);
  color: white;
}

.difficulty-advanced {
  background: #dc2626;
  color: white;
}

/* ===== Alert Box Improvements ===== */
.alert {
  border-radius: 8px;
  border-left: 4px solid;
  margin: 1.5rem 0;
}

.alert-info {
  border-left-color: var(--primary-brand);
  background: rgba(37, 99, 235, 0.1);
}

[data-bs-theme="dark"] .alert-info {
  background: rgba(37, 99, 235, 0.15);
}

/* ===== Table of Contents ===== */
.toc {
  background: var(--code-bg-light);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

[data-bs-theme="dark"] .toc {
  background: var(--code-bg-dark);
  border-color: rgba(255, 255, 255, 0.1);
}

.toc ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.toc ul ul {
  padding-left: 1.5rem;
  margin-top: 0.5rem;
}

.toc li {
  margin: 0.5rem 0;
}

.toc a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

.toc a:hover {
  color: var(--primary-brand);
}

/* ===== Article Navigation ===== */
.article-navigation {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .article-navigation {
  border-top-color: rgba(255, 255, 255, 0.1);
}

.article-nav-link {
  flex: 1;
  padding: 1.5rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
}

[data-bs-theme="dark"] .article-nav-link {
  border-color: rgba(255, 255, 255, 0.1);
}

.article-nav-link:hover {
  border-color: var(--primary-brand);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.article-nav-link .nav-label {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.article-nav-link .nav-title {
  font-weight: 600;
  font-size: 1rem;
}

/* ===== Reading Time ===== */
.reading-time {
  display: inline-block;
  margin-left: 1rem;
  color: #6b7280;
  font-size: 0.875rem;
}

/* ===== Breadcrumb Improvements ===== */
nav[aria-label="breadcrumb"] {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.breadcrumb {
  background: transparent;
  padding: 0 !important;
  margin-bottom: 0 !important;
  font-size: 0.85rem;
}

.breadcrumb-item {
  padding: 0.25rem 0;
}

/* ===== Smooth Scrolling ===== */
html {
  scroll-behavior: smooth;
}

/* ===== Sidebar Fixes ===== */
.col-lg-4 .card {
  max-height: none;
  height: auto !important;
}

.col-lg-4 .card-body {
  padding: 1rem;
  font-size: 0.9rem;
  height: auto !important;
  min-height: auto !important;
}

.col-lg-4 .card-header {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
}

/* Google Adsense container */
.col-lg-4 .adsbygoogle {
  display: block !important;
  min-height: 250px !important;
  max-height: 600px !important;
  height: auto !important;
  overflow: hidden !important;
}

/* ===== Utility Classes ===== */
.mt-section {
  margin-top: 4rem;
}

.mb-section {
  margin-bottom: 4rem;
}

/* ===== Responsive Improvements ===== */
@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.35rem; }

  article p {
    font-size: 1rem;
  }

  .article-navigation {
    flex-direction: column;
  }

  .card:hover {
    transform: none;
  }
}

/* ===== Print Styles ===== */
@media print {
  .navbar, .sidebar, .breadcrumb, .article-navigation, .code-copy-button {
    display: none;
  }

  pre {
    border: 1px solid #ccc;
  }
}
