/* 
 * Professional Cheatsheet Styles
 * Matching the clean, professional look of interview questions
 */

/* Main Content Card - Professional styling like interview questions */
.cheatsheet-content-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transform-origin: center;
}

.cheatsheet-content-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
  border-color: #e5e7eb;
}

/* Content wrapper for proper spacing */
.cheatsheet-article {
  padding: 2rem;
}

@media (min-width: 768px) {
  .cheatsheet-article {
    padding: 2.5rem;
  }
}

/* Enhanced Typography - Professional and Clean */
.cheatsheet-article h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid #e5e7eb;
  color: #1f2937;
  position: relative;
}

.cheatsheet-article h1::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(to right, #f97316, #fb923c);
}

.cheatsheet-article h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: #1f2937;
  position: relative;
  padding-left: 0;
  transition: color 0.2s ease;
}

.cheatsheet-article h2:hover {
  color: #ea580c;
}

.cheatsheet-article h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: #1f2937;
  border-left: 3px solid #f97316;
  padding-left: 0.75rem;
  transition: all 0.2s ease;
}

.cheatsheet-article h3:hover {
  border-left-width: 4px;
  padding-left: calc(0.75rem - 1px);
  color: #ea580c;
}

.cheatsheet-article h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: #374151;
}

/* Paragraph styling */
.cheatsheet-article p {
  font-size: 0.9375rem;
  line-height: 1.75;
  margin-bottom: 1rem;
  color: #4b5563;
}

/* List styling - Clean and professional */
.cheatsheet-article ul,
.cheatsheet-article ol {
  margin: 1rem 0;
  padding-left: 2rem;
}

.cheatsheet-article li {
  margin-bottom: 0.5rem;
  color: #4b5563;
  line-height: 1.75;
}

.cheatsheet-article li::marker {
  color: #f97316;
  font-size: 0.875rem;
}

/* Strong text */
.cheatsheet-article strong {
  font-weight: 600;
  color: #1f2937;
}

/* Links - Orange theme */
.cheatsheet-article a {
  color: #f97316;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: rgba(249, 115, 22, 0.3);
  text-underline-offset: 2px;
  transition: all 0.2s ease;
}

.cheatsheet-article a:hover {
  color: #ea580c;
  text-decoration-color: #ea580c;
}

/* Inline code - Matching interview questions */
.cheatsheet-article code:not(pre code) {
  background: rgba(249, 115, 22, 0.08);
  color: #c2410c;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
}

/* Code blocks - Dark theme matching interview questions */
.cheatsheet-article pre {
  background: #272822;
  border-radius: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  position: relative;
  border: none;
}

.cheatsheet-article pre:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.cheatsheet-article pre code {
  background: transparent;
  color: #f8f8f2;
  font-family: 'JetBrains Mono', Consolas, Monaco, 'Courier New', monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  padding: 0;
}

/* Override for Prism.js styled code blocks */
.cheatsheet-article pre[class*="language-"] {
  margin: 1.5rem 0;
  padding: 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  background: #272822;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cheatsheet-article code[class*="language-"] {
  font-size: 0.875rem;
  color: #f8f8f2;
  background: transparent;
}

/* Table styling - Professional and clean */
.cheatsheet-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  border-radius: 0.5rem;
  overflow: hidden;
}

.cheatsheet-article th,
.cheatsheet-article td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.cheatsheet-article th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.cheatsheet-article tr:last-child td {
  border-bottom: none;
}

.cheatsheet-article tr:hover {
  background: #f9fafb;
  transition: background 0.2s ease;
}

.cheatsheet-article tbody tr:nth-child(even) {
  background: #fafbfc;
}

/* Blockquote styling */
.cheatsheet-article blockquote {
  border-left: 3px solid #f97316;
  padding-left: 1rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: #6b7280;
  background: linear-gradient(to right, rgba(249, 115, 22, 0.03), transparent);
  padding: 1rem;
  border-radius: 0.25rem;
}

/* HR styling */
.cheatsheet-article hr {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, #e5e7eb, transparent);
  margin: 2rem 0;
}

/* Sidebar Cards - Matching interview questions style */
.sidebar-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.sidebar-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-card h3 svg {
  color: #f97316;
  width: 1.25rem;
  height: 1.25rem;
}

/* Sidebar list items */
.sidebar-card a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  margin: 0.25rem 0;
  color: #4b5563;
  font-weight: 500;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.sidebar-card a:hover {
  background: linear-gradient(to right, rgba(249, 115, 22, 0.05), transparent);
  color: #f97316;
  border-left-color: #f97316;
  transform: translateX(2px);
  text-decoration: none;
}

/* Quick Links specific styling - Fix icon sizes */
.sidebar-card .group {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-card .group:hover {
  background: #fff7ed;
}

.sidebar-card .group svg {
  color: #f97316;
  transition: all 0.2s ease;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.sidebar-card .group:hover svg {
  color: #ea580c;
  transform: scale(1.1);
}

/* Ensure proper text styling next to icons */
.sidebar-card .group span {
  font-size: 0.875rem;
  line-height: 1.25rem;
}

/* TOC Container Styling */
#table-of-contents {
  background: linear-gradient(to bottom, #f9fafb, #ffffff);
  border-bottom: 1px solid #e5e7eb;
  padding: 1.5rem;
  margin-bottom: 0;
  border-radius: 0.75rem 0.75rem 0 0;
}

#table-of-contents.hidden {
  display: none;
}

#table-of-contents h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#table-of-contents h3 svg {
  color: #f97316;
}

/* TOC Links */
.toc-content a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: #4b5563;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  border-left: 2px solid transparent;
  margin-bottom: 0.25rem;
}

.toc-content a:hover {
  color: #f97316;
  background: linear-gradient(to right, rgba(249, 115, 22, 0.05), transparent);
  border-left-color: #f97316;
  transform: translateX(2px);
  text-decoration: none;
}

/* Level-based indentation for TOC */
.toc-content a[data-level="2"] {
  padding-left: 1.5rem;
}

.toc-content a[data-level="3"] {
  padding-left: 2.5rem;
  font-size: 0.8125rem;
}

/* Header styling for the cheatsheet title section */
.cheatsheet-header {
  background: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
  color: white;
  padding: 2rem 1.5rem;
  border-radius: 0.75rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.15);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.cheatsheet-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.cheatsheet-header h1 {
  position: relative;
  z-index: 1;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cheatsheet-header .divider {
  width: 4rem;
  height: 0.25rem;
  background: rgba(255, 255, 255, 0.9);
  margin: 1rem auto;
  border-radius: 2px;
}

.cheatsheet-header p {
  position: relative;
  z-index: 1;
  opacity: 0.95;
  font-style: italic;
  max-width: 600px;
  margin: 0 auto;
  font-size: 1rem;
}

/* Enhance scrollbar for code blocks - dark theme */
.cheatsheet-article pre::-webkit-scrollbar {
  height: 8px;
  background-color: #2d3748;
}

.cheatsheet-article pre::-webkit-scrollbar-thumb {
  background-color: #4a5568;
  border-radius: 4px;
}

.cheatsheet-article pre::-webkit-scrollbar-thumb:hover {
  background-color: #718096;
}

/* Smooth animations */
.cheatsheet-content-card,
.sidebar-card {
  animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive improvements */
@media (max-width: 768px) {
  .cheatsheet-article {
    padding: 1.5rem;
  }
  
  .cheatsheet-article h1 {
    font-size: 1.75rem;
  }
  
  .cheatsheet-article h2 {
    font-size: 1.25rem;
  }
  
  .cheatsheet-article h3 {
    font-size: 1.125rem;
  }
  
  .sidebar-card {
    padding: 1.25rem;
  }
  
  .cheatsheet-header {
    padding: 1.5rem 1rem;
  }
  
  .cheatsheet-header h1 {
    font-size: 1.5rem;
  }
}

/* Focus states for accessibility */
.cheatsheet-article a:focus-visible,
.sidebar-card a:focus-visible {
  outline: 2px solid #f97316;
  outline-offset: 2px;
  border-radius: 0.25rem;
}

/* Image styling within content */
.cheatsheet-article img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 1.5rem auto;
  display: block;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Professional loading state */
.cheatsheet-loading {
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
}

.cheatsheet-loading::after {
  content: '';
  width: 2rem;
  height: 2rem;
  border: 3px solid #f3f4f6;
  border-radius: 50%;
  border-top-color: #f97316;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Explain AI Button Styles - Improved */
.explain-ai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.375rem 0.875rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid #fed7aa;
  color: #ea580c;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Icon-only compact state */
.explain-ai-btn.icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  gap: 0;
}

.explain-ai-btn.icon-only .explain-text,
.explain-ai-btn.icon-only .credits-badge {
  display: none;
}

.explain-ai-btn.icon-only .explain-icon {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
}

/* Selection button special style */
.explain-ai-btn.selection-btn {
  background: rgba(255, 255, 255, 0.98);
  border: 2px solid #f97316;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.2);
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
  }
}

.explain-ai-btn:hover {
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border-color: #f97316;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.15);
}

.explain-ai-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(249, 115, 22, 0.1);
}

/* Subtle hover animation effect */
.explain-ai-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(249, 115, 22, 0.1), transparent);
  transition: left 0.5s ease;
}

.explain-ai-btn:hover::before {
  left: 100%;
}

/* AI Icon styling */
.explain-ai-btn .explain-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  opacity: 0.8;
  transition: opacity 0.2s ease, transform 0.3s ease;
}

.explain-ai-btn:hover .explain-icon {
  opacity: 1;
  transform: rotate(180deg);
}

/* Text styling */
.explain-ai-btn .explain-text {
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* AI superscript indicator */
.explain-ai-btn .ai-indicator {
  font-size: 0.625rem;
  margin-left: 0.125rem;
  opacity: 0.85;
  vertical-align: super;
  font-weight: 600;
  color: inherit;
}

/* Credits badge styling */
.explain-ai-btn .credits-badge {
  background: #fff7ed;
  color: #c2410c;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  margin-left: 0.25rem;
  border: 1px solid rgba(194, 65, 12, 0.2);
  transition: all 0.2s ease;
}

.explain-ai-btn:hover .credits-badge {
  background: #fed7aa;
  border-color: rgba(194, 65, 12, 0.3);
}

/* Code block explain button positioning */
.code-block-wrapper {
  position: relative;
}

.code-block-wrapper .explain-ai-btn {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  z-index: 10;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
}

/* Dark theme code blocks - adjust button for visibility */
.cheatsheet-article pre .explain-ai-btn {
  background: rgba(249, 115, 22, 0.15);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(249, 115, 22, 0.5);
  color: #fbbf24;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.cheatsheet-article pre .explain-ai-btn.icon-only {
  background: rgba(249, 115, 22, 0.2);
  border-color: rgba(249, 115, 22, 0.4);
}

.cheatsheet-article pre .explain-ai-btn:hover {
  background: rgba(249, 115, 22, 0.25);
  border-color: #f97316;
  color: #fcd34d;
}

.cheatsheet-article pre .explain-ai-btn .credits-badge {
  background: rgba(249, 115, 22, 0.3);
  border-color: rgba(249, 115, 22, 0.5);
  color: #fef3c7;
}

/* Heading explain button positioning */
.heading-with-explain {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.heading-with-explain .explain-ai-btn {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 0.25rem 0.625rem;
}

/* Smaller button variant for headings */
.explain-ai-btn.explain-btn-small {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
}

.explain-ai-btn.explain-btn-small .explain-icon {
  width: 0.875rem;
  height: 0.875rem;
}

.explain-ai-btn.explain-btn-small .credits-badge {
  font-size: 0.625rem;
  padding: 0.0625rem 0.25rem;
}

/* Loading state for explain buttons */
.explain-ai-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.explain-ai-btn.loading .explain-icon {
  animation: spin 1s linear infinite;
}

/* Heading explain wrapper */
.heading-explain-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

/* Smooth transitions for hover states */
.cheatsheet-article pre,
.cheatsheet-article h2 {
  transition: box-shadow 0.2s ease;
}

.cheatsheet-article pre:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.cheatsheet-article h2:hover {
  color: #ea580c;
}

/* CSS hover fallback for trackpads - show button on hover */
.cheatsheet-article pre:hover .explain-ai-btn,
.cheatsheet-article h2:hover .explain-ai-btn {
  opacity: 1 !important;
  visibility: visible !important;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Ensure button area is hoverable */
.cheatsheet-article pre {
  position: relative;
}

/* Create hover area for better trackpad detection */
.cheatsheet-article pre::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 60px;
  height: 60px;
  z-index: 1;
  pointer-events: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .explain-ai-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
  }
  
  .explain-ai-btn.icon-only {
    width: 32px;
    height: 32px;
  }
  
  .heading-with-explain {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .heading-with-explain .explain-ai-btn {
    align-self: flex-end;
    margin-top: 0.5rem;
  }
  
  /* Better hover detection for different devices */
  @media (hover: hover) and (pointer: fine) {
    /* Devices with precise pointer and hover (mouse/trackpad) */
    .explain-ai-btn {
      transition: opacity 0.2s ease, visibility 0.2s ease;
    }
  }
  
  @media (hover: none) or (pointer: coarse) {
    /* Touch devices - always show buttons */
    .explain-ai-btn {
      opacity: 1 !important;
      visibility: visible !important;
    }
  }
}

/* Loading Spinner */
.border-3 {
  border-width: 3px;
}