/* Cloud Interview Guide — Professional Top-Nav Layout */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --sidebar-width: 280px;
  --topnav-height: 60px;

  /* Core palette */
  --content-bg: #f4f6f9;
  --content-card: #ffffff;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --accent-mid: #dbeafe;

  /* Radii */
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow: 0 4px 16px -4px rgba(0,0,0,0.09), 0 2px 6px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 12px 40px -8px rgba(0,0,0,0.13), 0 4px 14px -4px rgba(0,0,0,0.07);
  --shadow-nav: 0 1px 0 rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);

  --transition: 0.15s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  font-family: var(--font-sans);
  background: var(--content-bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

/* ========== App layout ========== */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ================================================
   TOP NAVIGATION BAR
   ================================================ */
.sidebar {
  width: 100%;
  background: #ffffff;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-nav);
  padding: 0 2rem;
  flex-shrink: 0;
  min-height: var(--topnav-height);
  gap: 0;
}

/* Logo area — with right separator */
.sidebar-header {
  flex-shrink: 0;
  padding: 0 1.5rem 0 0;
  margin-right: 1.25rem;
  border-right: 1px solid var(--border);
  height: 28px;
  display: flex;
  align-items: center;
}

.sidebar-logo {
  font-weight: 800;
  font-size: 0.9375rem;
  color: var(--text);
  letter-spacing: -0.03em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  line-height: 1;
}

.sidebar-logo::before {
  content: '';
  display: inline-block;
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  border-radius: 7px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.sidebar-logo:hover { color: var(--accent); }

/* ── Nav groups ── */
.sidebar-nav {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0;
  flex-shrink: 0;
}

.nav-menu-item {
  position: relative;
}

.nav-menu-label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.45rem 0.8rem;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  user-select: none;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.nav-menu-label::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 3.5px solid currentColor;
  transition: transform 0.2s ease;
  opacity: 0.45;
  margin-left: 1px;
}

.nav-menu-label:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.nav-menu-item.open .nav-menu-label {
  background: var(--accent-light);
  color: var(--accent);
}

.nav-menu-item.open .nav-menu-label::after {
  transform: rotate(180deg);
  opacity: 0.8;
}

/* ── Floating dropdown ── */
.nav-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: var(--radius-md);
  padding: 0.375rem;
  min-width: 215px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(0.99);
  transform-origin: top left;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 200;
}

.nav-menu-item.open .nav-menu-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ── Sidebar links (in dropdown) ── */
.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5625rem 0.75rem;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 7px;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  letter-spacing: -0.01em;
}

.sidebar-link:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.sidebar-link.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}

.sidebar-link .count {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 400;
  background: var(--content-bg);
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
  line-height: 1.3;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-link.active .count {
  color: var(--accent);
  background: var(--accent-mid);
  border-color: #bfdbfe;
}

/* ── Right-side search & filters ── */
.header-search {
  flex-shrink: 0;
  max-width: 280px;
  min-width: 160px;
  margin-left: auto;
}

.header-search .search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.4rem 0.75rem;
  border-radius: 7px;
  background: var(--content-bg);
  border: 1px solid var(--border);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.header-search .search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: #fff;
}

.header-search .search-box svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.header-search .search-box input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text);
  min-width: 0;
}

.header-search .search-box input::placeholder {
  color: var(--text-muted);
}

.header-filters {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  margin-left: 0.75rem;
}

.header-filters .filter-chip {
  padding: 0.25rem 0.625rem;
  font-size: 0.6875rem;
}

/* Progress indicator (devops.css activates this) */
.sidebar-footer { display: none; }

/* ================================================
   MAIN CONTENT AREA
   ================================================ */
.content-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Collapsed — hide top nav entirely */
.app-layout.sidebar-collapsed .sidebar { display: none; }
.app-layout.sidebar-collapsed .content-area { margin-left: 0; }

.content-panel {
  flex: 1;
  padding: 2.25rem 3rem 4rem;
  max-width: 960px;
}

/* Category content (one visible at a time) */
.category-content { display: none; }
.category-content.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

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

.category-header {
  margin-bottom: 2.25rem;
}

.category-header h1 {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: 0.4rem;
  line-height: 1.2;
}

.category-header .lead {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* ── In-page topic nav ── */
.topic-nav {
  background: var(--content-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 0;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.topic-nav-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 0 1.25rem 0.5rem;
}

.topic-nav-list { list-style: none; }

.topic-nav-list a {
  display: block;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}

.topic-nav-list a:hover {
  background: var(--content-bg);
  color: var(--accent);
}

.topic-nav-list a.active-topic {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  border-left: 2px solid var(--accent);
  padding-left: calc(1.25rem - 2px);
}

/* ── Topic blocks ── */
.topic-block {
  margin-bottom: 2.5rem;
  scroll-margin-top: 1.5rem;
}

.topic-block h2 {
  font-size: 1.1875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.875rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.02em;
}

.topic-block .topic-body {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.75;
  background: var(--content-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow-xs);
}

.topic-block .topic-body pre,
.topic-block .topic-body code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.topic-block .topic-body b,
.topic-block .topic-body strong {
  color: var(--text);
  font-weight: 600;
}

/* Diagrams */
.fundamentals-diagram, .topic-diagram {
  margin: 0 0 1.5rem;
}

.fundamentals-diagram img, .topic-diagram img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.fundamentals-diagram figcaption, .topic-diagram figcaption {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.welcome-content {
  padding: 3rem 0;
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
}

.welcome-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.welcome-content p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* ================================================
   SIDEBAR TOGGLE — mobile hamburger only
   ================================================ */
.sidebar-toggle {
  position: fixed;
  top: 0.75rem;
  right: 1.25rem;
  bottom: auto;
  left: auto;
  z-index: 200;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--content-card);
  color: var(--text);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition);
}

.sidebar-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* Overlay — unused with top nav but kept for JS compatibility */
.sidebar-overlay { display: none !important; }

/* Dropdown backdrop */
.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: none;
}
.nav-backdrop.active { display: block; }

/* ================================================
   MOBILE — collapsible top nav
   ================================================ */
@media (max-width: 900px) {
  .sidebar {
    flex-wrap: wrap;
    padding: 0 1rem;
    padding-right: 3.75rem;
  }

  .sidebar-header {
    border-right: none;
    margin-right: 0;
    padding-right: 0;
  }

  .sidebar-toggle { display: flex; }

  .sidebar-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    padding: 0.5rem 0 0.875rem;
    border-top: 1px solid var(--border);
    gap: 0;
    background: #fff;
  }

  .sidebar.open .sidebar-nav { display: flex; }

  .nav-menu-item { margin-bottom: 0.125rem; }

  .nav-menu-label {
    width: 100%;
    padding: 0.5625rem 0.875rem;
    font-size: 0.8125rem;
    justify-content: space-between;
  }

  .nav-menu-dropdown {
    position: static;
    display: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0 0 0.5rem 1rem;
    margin: 0.125rem 0 0 0.75rem;
    border-left: 2px solid var(--border);
    min-width: 0;
    opacity: 1;
    transform: none;
    visibility: visible;
  }

  .nav-menu-item.open .nav-menu-dropdown { display: block; }

  .sidebar-link {
    padding: 0.4375rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 6px;
    margin-bottom: 0.0625rem;
  }

  /* Search — hidden in nav bar row, shown inside expanded nav */
  .header-search {
    display: none;
    width: 100%;
    padding: 0.625rem 0.875rem 0;
    margin-left: 0;
    max-width: none;
    min-width: 0;
  }

  .sidebar.open .header-search { display: block; }

  .header-search .search-box {
    max-width: none;
  }

  /* Filters — same treatment */
  .header-filters {
    display: none;
    width: 100%;
    padding: 0.5rem 0.875rem 0.875rem;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-left: 0;
  }

  .sidebar.open .header-filters { display: flex; }

  .content-panel { padding: 1.75rem 1.25rem 2.5rem; }
}

@media (max-width: 480px) {
  .sidebar { padding-right: 3.25rem; }
  .nav-menu-label { font-size: 0.8125rem; }
}

/* ================================================
   RICH CONTENT STYLES
   ================================================ */

/* Answer blocks */
.answer-block {
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}

.answer-block h4 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.answer-block.correct {
  background: #f0fdf4;
  border-left: 3px solid #22c55e;
}

.answer-block.correct h4 { color: #15803d; }

.answer-block.incorrect {
  background: #fef2f2;
  border-left: 3px solid #f87171;
}

.answer-block.incorrect h4 { color: #dc2626; }

/* Service grid */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.875rem;
  margin-top: 1rem;
}

.service-category {
  background: var(--content-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.service-category h3 {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border);
}

.service-category ul { list-style: none; }

.service-category li {
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 0.2rem 0;
}

/* Topic tables */
.topic-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.875rem 0;
  font-size: 0.875rem;
}

.topic-table th, .topic-table td {
  text-align: left;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
}

.topic-table th {
  background: var(--content-bg);
  font-weight: 600;
  color: var(--text);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.topic-table td { color: var(--text-secondary); }

/* Content lists */
.topic-body ul, .topic-body ol {
  margin: 0.625rem 0 0.625rem 1.375rem;
}

.topic-body li { margin-bottom: 0.4rem; }

.topic-body p { margin-bottom: 0.875rem; }
.topic-body p:last-child { margin-bottom: 0; }

.topic-body h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.125rem 0 0.5rem;
  letter-spacing: -0.01em;
}

.topic-body h4:first-child { margin-top: 0; }

.topic-body code {
  background: var(--content-bg);
  padding: 0.125rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.8125rem;
}

/* Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
