@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-gradient: linear-gradient(135deg, #0f172a, #1e1b4b);
  --panel-bg: rgba(30, 41, 59, 0.7);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --success: #10b981;
  --error: #ef4444;
  --sidebar-bg: rgba(15, 23, 42, 0.85);
  
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'Fira Code', 'SFMono-Regular', Consolas, monospace;
}

* { 
  box-sizing: border-box; 
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

header {
  padding: 1.5rem 2rem;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.header-content {
  flex: 1;
}

header h1 { 
  margin: 0; 
  font-size: 1.75rem; 
  color: var(--accent); 
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline { 
  margin: 0.25rem 0 0; 
  color: var(--text-muted); 
  font-size: 0.95rem; 
}

.header-links {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.back-link { 
  color: var(--accent); 
  text-decoration: none; 
  font-size: 0.9rem; 
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.1);
}

.back-link:hover {
  background: rgba(56, 189, 248, 0.2);
  transform: translateY(-1px);
}

.layout { 
  display: flex; 
  min-height: calc(100vh - 85px); 
  flex-direction: row;
}

.sidebar {
  width: 280px;
  flex: 0 0 280px;
  border-right: 1px solid var(--panel-border);
  padding: 1.5rem 1rem;
  background: var(--sidebar-bg);
  backdrop-filter: blur(12px);
  overflow-y: auto;
}

.sidebar h2 { 
  font-size: 0.85rem; 
  text-transform: uppercase; 
  color: var(--text-muted); 
  letter-spacing: 0.1em; 
  margin-top: 0;
  padding-left: 0.6rem;
}

.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li { margin: 0.25rem 0; }
.sidebar a {
  display: block;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}
.sidebar a:hover { 
  background: rgba(255, 255, 255, 0.05); 
}
.sidebar a.active { 
  background: var(--accent); 
  color: #0f172a; 
  font-weight: 600; 
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.25);
}

.content { 
  flex: 1; 
  padding: 2rem; 
  overflow-x: auto; 
  max-width: 1200px;
  margin: 0 auto;
}

.content h2 { 
  color: var(--text); 
  font-size: 1.8rem;
  margin-top: 0;
}

.content code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.3);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
  color: #e2e8f0;
}

.content pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 1.2rem;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
}

.content table { 
  border-collapse: collapse; 
  margin: 1rem 0; 
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
}

.content th, .content td { 
  padding: 0.75rem 1rem; 
  border-bottom: 1px solid var(--panel-border);
}

.content th { 
  background: rgba(255, 255, 255, 0.05); 
  font-weight: 600;
  text-align: left;
}

.panel {
  margin-top: 2rem;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.panel h3 { 
  margin-top: 0; 
  color: var(--accent); 
  font-size: 1.3rem;
}

.hint { 
  color: var(--text-muted); 
  font-size: 0.9rem; 
}

#sql-input, #sql-in {
  width: 100%;
  min-height: 140px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  resize: vertical;
}

#sql-input:focus, #sql-in:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.editor-layout { 
  display: flex; 
  gap: 1.5rem; 
  flex-wrap: wrap; 
}

.editor-col { 
  flex: 1; 
  min-width: 320px; 
}

.example-bar { 
  margin: 1rem 0; 
  display: flex; 
  gap: 0.5rem; 
  flex-wrap: wrap; 
}

.example-bar button { 
  background: rgba(255, 255, 255, 0.1); 
  color: var(--text); 
  font-size: 0.85rem; 
  padding: 0.4rem 0.8rem; 
  border-radius: 6px;
  font-weight: 500;
}

.example-bar button:hover {
  background: rgba(255, 255, 255, 0.15);
}

.schema-box { 
  background: rgba(0, 0, 0, 0.2); 
  border: 1px solid var(--panel-border); 
  border-radius: 12px; 
  padding: 1rem 1.5rem; 
}

.schema-box h4 { 
  margin: 0.5rem 0; 
  color: var(--accent); 
}

.schema-box ul { 
  margin: 0 0 0.5rem; 
  padding-left: 1.2rem; 
  color: var(--text-muted); 
}

.actions { 
  margin-top: 1rem; 
  display: flex; 
  gap: 0.8rem; 
}

button {
  background: var(--accent);
  color: #0f172a;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover { 
  background: var(--accent-hover); 
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

#reset-btn { 
  background: rgba(255, 255, 255, 0.1); 
  color: var(--text); 
}

#reset-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.result { 
  margin-top: 1.5rem; 
  overflow-x: auto;
}

.result table { 
  width: 100%; 
  border-radius: 8px;
  overflow: hidden;
}

.result th, .result td { 
  text-align: left; 
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.result th {
  background: rgba(0,0,0,0.2);
  color: var(--accent);
}

.error { 
  color: var(--error); 
  background: rgba(239, 68, 68, 0.1);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.info { color: var(--success); }
em { color: var(--text-muted); font-style: normal; }

.notebook-btn {
  display: inline-block;
  background: var(--success);
  color: #0f172a;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  margin: 0.5rem 0;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.notebook-btn:hover {
  background: #059669;
  transform: translateY(-1px);
}

.pyspark-live { 
  margin-top: 1.5rem; 
  border-top: 1px dashed var(--panel-border); 
  padding-top: 1.2rem; 
}

.code-out {
  background: rgba(0, 0, 0, 0.3);
  color: #a5f3fc;
  padding: 1.2rem;
  border-radius: 10px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  white-space: pre;
  margin: 0;
  border: 1px solid var(--panel-border);
}

/* Prevent horizontal overflow on mobile */
html, body { overflow-x: hidden; max-width: 100vw; }
* { min-width: 0; }

/* Responsive adjustments */
@media (max-width: 768px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--panel-border);
    max-height: 250px;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1rem;
  }

  header h1 { font-size: 1.35rem; line-height: 1.2; }
  .tagline { font-size: .875rem; }

  .header-links {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: .5rem;
  }

  .back-link { font-size: .8rem; padding: .35rem .6rem; }

  .content {
    padding: 1.5rem 1rem;
    overflow-x: hidden;
  }

  .editor-layout { gap: 1rem; }
  .editor-col {
    min-width: 100%;
  }

  /* === Hub page mobile fixes (index.html) === */
  .hub-hero { padding: 2rem 1rem 1.5rem !important; }
  .hub-hero h1 { font-size: 1.7rem !important; line-height: 1.2; }
  .hub-hero p { font-size: .95rem !important; padding: 0 .5rem; }

  .hub-grid,
  .hub-grid[style],
  div.hub-grid[style],
  section.hub-grid[style] {
    grid-template-columns: 1fr !important;
    padding: 0 1rem !important;
    gap: 1rem !important;
  }

  .hub-card { padding: 1.25rem !important; }
  .hub-card h2 { font-size: 1.25rem; }
  .hub-card__actions { flex-direction: column; }
  .hub-card__actions .btn-primary,
  .hub-card__actions .btn-secondary { width: 100%; justify-content: center; text-align: center; }

  .lessons-section { padding: 0 1rem !important; margin: 2rem auto !important; }
  .lesson-grid,
  .lesson-grid[style],
  div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  footer[style] { padding: 1.5rem 1rem !important; }

  /* Tables and code should scroll, not overflow viewport */
  .content table, .result table, .panel { max-width: 100%; }
  .content pre, .code-out, .result pre {
    font-size: .8125rem;
    padding: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: pre;
    word-wrap: normal;
  }
  .result { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 400px) {
  .hub-hero h1 { font-size: 1.45rem !important; }
  header h1 { font-size: 1.15rem; }
}
