/* ================================================================
   Custom Styles — Unit 7 Sorting Techniques
   Dark Mode Aesthetic
   ================================================================ */

:root {
  /* Typography */
  --font-main: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-code: 'Fira Code', 'Consolas', 'Courier New', monospace;

  /* Colors */
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;

  /* Status Colors */
  --color-default: #64748b;
  /* Gray */
  --color-comparing: #eab308;
  /* Yellow */
  --color-swapping: #ef4444;
  /* Red */
  --color-sorted: #22c55e;
  /* Green */
  --color-pivot: #a855f7;
  /* Purple */
  --color-min: #3b82f6;
  /* Blue */

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* Base Overrides for Reveal.js */
.reveal {
  font-family: var(--font-main);
  color: var(--text-main);
  background: var(--bg-dark);
  font-size: 38px;
}

.reveal .slides section {
  padding: 0 !important;
}

/* Typography matching requirements - enlarged for slide presentations */
.reveal h1.main-title {
  font-size: 48px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.5em;
}

.reveal h2.section-title {
  font-size: 38px;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 0.4em;
  border-bottom: 2px solid var(--primary);
  display: inline-block;
  padding-bottom: 0.1em;
}

.reveal h3.subsection-title {
  font-size: 30px;
  font-weight: 600;
  color: #cbd5e1;
  margin-top: 0.5em;
  margin-bottom: 0.3em;
}

.reveal p,
.reveal li {
  font-size: 24px;
  line-height: 1.5;
  color: var(--text-muted);
}

.reveal pre {
  width: 100%;
  margin: 0;
}

.reveal pre code {
  font-family: var(--font-code);
  font-size: 25px;
  border-radius: var(--radius-sm);
  padding: 10px;
  max-height: 450px;
}

.text-left {
  text-align: left;
}

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

/* Dashboard Cards */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 900px;
  margin: 40px auto;
}

.dash-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 20px;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, background 0.3s ease;
  text-align: center;
}

.dash-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.dash-card .card-number {
  font-size: 36px;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 10px;
  opacity: 0.8;
}

.dash-card h3 {
  margin: 0;
  font-size: 22px;
  color: #fff;
}

/* Split Layout */
.split-layout {
  display: flex;
  width: 100%;
  height: 820px;
  box-sizing: border-box;
  padding: 20px;
  gap: 20px;
}

.panel-left {
  flex: 0 0 45%;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  text-align: left;
}

.panel-right {
  flex: 0 0 calc(55% - 20px);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Panel Containers */
.playground-top {
  flex: 0 0 55%;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.playground-middle {
  flex: 0 0 12%;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 15px 20px;
  display: flex;
  align-items: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.playground-bottom {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 15px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Code Viewer lives inside playground-bottom */
.code-viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid #334155;
  padding-top: 8px;
}

.code-viewer .code-tabs {
  flex-shrink: 0;
  margin-bottom: 4px;
}

.code-viewer .code-content {
  flex: 1;
  overflow-y: auto;
  display: none;
}

.code-viewer .code-content.active {
  display: flex;
  flex-direction: column;
}

.code-viewer .code-content pre {
  flex: 1;
  margin: 0;
  overflow: auto;
  background: #0f172a;
  border-radius: var(--radius-sm);
}

.code-viewer .code-content pre code {
  font-size: 25px;
  line-height: 1.5;
}

/* Visualization Array */
.array-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 100%;
  width: 100%;
  padding-top: 20px;
}

.array-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  max-width: 40px;
  height: 100%;
}

.array-bar {
  width: 100%;
  background-color: var(--color-default);
  border-radius: 4px 4px 0 0;
  transition: height 0.3s ease, background-color 0.2s ease, transform 0.3s ease;
  position: relative;
}

.array-value {
  margin-top: 5px;
  font-size: 18px;
  color: #e2e8f0;
  font-weight: 600;
}

.array-index {
  font-size: 14px;
  color: var(--text-muted);
}

/* Controls */
.controls-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 15px;
  justify-content: center;
}

.controls-row {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

.btn {
  background: #334155;
  color: #fff;
  border: 1px solid #475569;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover:not(:disabled) {
  background: var(--primary);
  border-color: var(--primary-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.speed-control {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  color: var(--text-muted);
}

.speed-control select {
  background: #334155;
  color: #fff;
  border: 1px solid #475569;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}

/* Step Explanation */
.step-explanation {
  font-size: 18px;
  font-weight: 500;
  color: #fff;
  margin: 0;
  width: 100%;
}

.step-explanation span.highlight {
  color: var(--primary);
  font-weight: 700;
}

/* Complexity Table */
.complexity-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
  font-size: 16px;
}

.complexity-table th,
.complexity-table td {
  padding: 8px 12px;
  border: 1px solid #334155;
  text-align: left;
}

.complexity-table th {
  background: #0f172a;
  color: #cbd5e1;
  font-weight: 600;
}

.complexity-table td {
  color: var(--text-muted);
}

/* Code Viewer Tabs */
.code-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
  border-bottom: 1px solid #334155;
}

.code-tab {
  padding: 6px 12px;
  font-size: 14px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

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

.code-content {
  display: none;
  height: 100%;
  overflow: auto;
}

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

.code-content pre {
  margin: 0;
  width: 100%;
  height: auto;
  box-shadow: none;
  background: #0f172a;
}

.code-content pre code {
  font-size: 25px;
}

/* Code Highlighting for current line */
.code-line {
  display: block;
  transition: background 0.2s;
  padding: 0 4px;
}

.code-line.active-line {
  background: rgba(59, 130, 246, 0.2);
  border-left: 2px solid var(--primary);
}

/* Legend */
.legend {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 10px;
  font-size: 14px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* Dedicated Code Slides */
.code-slide-container {
  display: flex;
  flex-direction: column;
  height: 75vh;
  width: 95%;
  margin: 0 auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  text-align: left;
}

.code-slide-container .code-viewer {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.code-slide-container .code-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}

.code-slide-container .code-tab {
  padding: 10px 20px;
  font-size: 27px;
  font-weight: 600;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}

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

.code-slide-container .code-content {
  flex: 1;
  overflow-y: auto;
  display: none;
  background: #0f172a;
  border-radius: var(--radius-sm);
  padding: 15px;
}

.code-slide-container .code-content.active {
  display: block;
}

.code-slide-container .code-content pre {
  margin: 0;
  box-shadow: none;
  background: transparent;
}

.code-slide-container .code-content pre code {
  font-size: 25px;
  line-height: 1.6;
}

/* Tighten layout inside left panels to fit the screen without scrollbars */
.panel-left h3.subsection-title {
  margin-top: 10px !important;
  margin-bottom: 4px !important;
  font-size: 20px !important;
}

.panel-left p,
.panel-left li {
  margin-bottom: 4px !important;
  line-height: 1.4 !important;
  font-size: 16px !important;
}

.panel-left ol,
.panel-left ul {
  margin-top: 2px !important;
  margin-bottom: 6px !important;
  padding-left: 20px !important;
}

.panel-left .complexity-table {
  margin-top: 6px !important;
  margin-bottom: 6px !important;
}

.panel-left .complexity-table th,
.panel-left .complexity-table td {
  padding: 4px 8px !important;
  font-size: 14px !important;
}

/* Responsive adjustments for sorting presentation */
@media (max-width: 1400px) {
  .reveal .slides section {
    padding: 20px 30px !important;
  }
  .dashboard-grid {
    gap: 12px !important;
  }
  .dash-card {
    padding: 16px !important;
  }
  .complexity-table {
    font-size: 24px !important;
  }
  .code-slide-container .code-content pre code {
    font-size: 22px !important;
  }
}

@media (max-width: 1200px) {
  .reveal .slides section {
    padding: 18px 28px !important;
  }
  .dashboard-grid {
    gap: 10px !important;
  }
  .dash-card {
    padding: 14px !important;
  }
  .complexity-table {
    font-size: 22px !important;
  }
  .code-slide-container .code-content pre code {
    font-size: 20px !important;
  }
}

@media (max-width: 900px) {
  .reveal .slides section {
    padding: 15px 20px !important;
  }
  .dashboard-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .dash-card h3 {
    font-size: 18px !important;
  }
  .complexity-table {
    font-size: 18px !important;
  }
  .panel-left h3.subsection-title {
    font-size: 16px !important;
  }
  .panel-left p,
  .panel-left li {
    font-size: 14px !important;
  }
  .code-slide-container .code-content pre code {
    font-size: 16px !important;
  }
}

@media (max-width: 600px) {
  .dashboard-grid {
    grid-template-columns: 1fr !important;
  }
  .complexity-table {
    font-size: 16px !important;
  }
}