/*
  © 2025 Milos Saric. All rights reserved.
  Interactive Jupyter-like Notebook Styles
  Clean, modern Apple-inspired design
*/

:root {
  --notebook-bg: #ffffff;
  --cell-bg: #ffffff;
  --cell-border: #e5e5e7;
  --cell-hover-border: #d1d1d6;
  --code-bg: #f6f6f6;
  --code-text: #1d1d1f;
  --output-bg: #fafafa;
  --primary-blue: #007aff;
  --success-green: #30d158;
  --error-red: #ff3b30;
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.12);
  --radius-small: 8px;
  --radius-medium: 12px;
  --transition-fast: 0.2s ease;
  --transition-smooth: 0.3s ease;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --notebook-bg: #000000;
    --cell-bg: #1c1c1e;
    --cell-border: #38383a;
    --cell-hover-border: #48484a;
    --code-bg: #2c2c2e;
    --code-text: #ffffff;
    --output-bg: #1c1c1e;
    --text-primary: #ffffff;
    --text-secondary: #98989d;
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-content {
  text-align: center;
  max-width: 400px;
  padding: 2rem;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 3px solid var(--cell-border);
  border-top: 3px solid var(--primary-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

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

.loading-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.loading-content p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.progress-container {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--cell-border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-blue), #5ac8fa);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Hero Section */
.hero-section {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  padding: 120px 0 80px;
  text-align: center;
}

.hero-content h1 {
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hero-content p {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 3rem;
  line-height: 1.6;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 4rem;
  margin-top: 3rem;
}

.stat {
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-blue);
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Notebook Section */
.notebook-section {
  background: var(--notebook-bg);
  padding: 80px 0;
  min-height: 100vh;
}

.notebook-cell {
  background: var(--cell-bg);
  border: 1px solid var(--cell-border);
  border-radius: var(--radius-medium);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-light);
  transition: all var(--transition-fast);
  overflow: hidden;
}

.notebook-cell:hover {
  border-color: var(--cell-hover-border);
  box-shadow: var(--shadow-medium);
}

/* Markdown Cells */
.markdown-cell .cell-content {
  padding: 2rem;
}

.markdown-cell h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  letter-spacing: -0.01em;
}

.markdown-cell h2 {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  margin-top: 2rem;
}

.markdown-cell h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  margin-top: 1.5rem;
}

.markdown-cell p {
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
}

.markdown-cell blockquote {
  border-left: 4px solid var(--primary-blue);
  background: rgba(0, 122, 255, 0.05);
  padding: 1.5rem;
  margin: 2rem 0;
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
  font-style: italic;
}

.markdown-cell ul, .markdown-cell ol {
  margin-bottom: 1.25rem;
  padding-left: 2rem;
}

.markdown-cell li {
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.markdown-cell hr {
  border: none;
  height: 1px;
  background: var(--cell-border);
  margin: 2.5rem 0;
}

.markdown-cell strong {
  font-weight: 600;
  color: var(--text-primary);
}

.markdown-cell em {
  font-style: italic;
  color: var(--primary-blue);
}

/* Tables */
.markdown-cell table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 1rem;
}

.markdown-cell th,
.markdown-cell td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--cell-border);
}

.markdown-cell th {
  background: var(--code-bg);
  font-weight: 600;
  color: var(--text-primary);
}

.markdown-cell td {
  color: var(--text-primary);
}

.markdown-cell tr:hover {
  background: rgba(0, 122, 255, 0.02);
}

/* Code Cells */
.code-cell {
  font-family: 'JetBrains Mono', 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

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

.cell-type {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.run-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary-blue);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-small);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.run-button:hover {
  background: #0056cc;
  transform: translateY(-1px);
}

.run-button:active {
  transform: translateY(0);
}

.run-button:disabled {
  background: var(--text-secondary);
  cursor: not-allowed;
  transform: none;
}

.run-button svg {
  width: 14px;
  height: 14px;
}

/* Code Input */
.cell-input {
  position: relative;
}

.code-editor {
  width: 100%;
  min-height: 120px;
  padding: 1.5rem;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--code-text);
  resize: vertical;
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.code-editor::placeholder {
  color: var(--text-secondary);
}

.code-editor:focus {
  background: rgba(0, 122, 255, 0.02);
}

/* Code Output */
.cell-output {
  padding: 1.5rem;
  background: var(--output-bg);
  border-top: 1px solid var(--cell-border);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--code-text);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 2rem;
  display: none;
}

.cell-output.has-content {
  display: block;
}

.cell-output.error {
  background: rgba(255, 59, 48, 0.05);
  color: var(--error-red);
  border-color: rgba(255, 59, 48, 0.2);
}

.cell-output.success {
  background: rgba(48, 209, 88, 0.05);
  border-color: rgba(48, 209, 88, 0.2);
}

/* Running Animation */
.run-button.running {
  background: var(--text-secondary);
  cursor: not-allowed;
}

.run-button.running svg {
  animation: spin 1s linear infinite;
}

.cell-output.loading::before {
  content: "Running...";
  color: var(--text-secondary);
  font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
  .hero-content h1 {
    font-size: 2.5rem;
  }
  
  .hero-content p {
    font-size: 1.125rem;
  }
  
  .hero-stats {
    flex-direction: column;
    gap: 2rem;
  }
  
  .notebook-section {
    padding: 60px 0;
  }
  
  .markdown-cell .cell-content {
    padding: 1.5rem;
  }
  
  .markdown-cell h1 {
    font-size: 2rem;
  }
  
  .markdown-cell h2 {
    font-size: 1.75rem;
  }
  
  .markdown-cell h3 {
    font-size: 1.375rem;
  }
  
  .markdown-cell p,
  .markdown-cell li {
    font-size: 1rem;
  }
  
  .cell-header {
    padding: 0.75rem 1rem;
  }
  
  .code-editor,
  .cell-output {
    padding: 1rem;
  }
  
  .markdown-cell table {
    font-size: 0.875rem;
  }
  
  .markdown-cell th,
  .markdown-cell td {
    padding: 0.75rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .hero-section {
    padding: 100px 0 60px;
  }
  
  .hero-content h1 {
    font-size: 2rem;
  }
  
  .notebook-cell {
    margin-bottom: 1rem;
    border-radius: var(--radius-small);
  }
  
  .markdown-cell .cell-content {
    padding: 1rem;
  }
  
  .run-button {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
  }
  
  .code-editor {
    font-size: 0.875rem;
  }
}

/* Print Styles */
@media print {
  .loading-overlay,
  .run-button,
  .hero-section {
    display: none !important;
  }
  
  .notebook-cell {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .cell-output {
    display: block !important;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .loading-spinner {
    animation: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --cell-border: #000000;
    --cell-hover-border: #000000;
    --code-bg: #f0f0f0;
    --text-secondary: #000000;
  }
}