/* ============================================================
   Road Video Surveillance System Design Guide
   Solution Mall Knowledge Center - Shared Styles
   ============================================================ */

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

:root {
  --primary: #0D6EFD;
  --secondary: #198754;
  --bg-white: #FFFFFF;
  --text-dark: #212529;
  --text-gray: #6C757D;
  --bg-light: #F8F9FA;
  --border: #DEE2E6;
  --sidebar-width: 280px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text-dark);
  background: var(--bg-white);
  line-height: 1.6;
}

/* ============================================================
   LEFT SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
}

.sidebar-logo {
  padding: 12px 16px;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  text-align: center;
}

.sidebar-logo img {
  max-width: 180px;
  height: auto;
  display: block;
  margin: 0 auto 6px;
}

.sidebar-logo a {
  font-size: 0.8rem;
  color: var(--primary);
  text-decoration: none;
}

.sidebar-logo a:hover { text-decoration: underline; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  height: 5rem;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text-dark);
  border-left: 4px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  gap: 12px;
  font-size: 0.875rem;
  line-height: 1.3;
}

.nav-item:hover {
  background: var(--bg-light);
  cursor: pointer;
}

.nav-item.active {
  border-left-color: var(--primary);
  background: var(--bg-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-item svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--primary);
}

.nav-item span { flex: 1; }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-white);
}

.content-wrapper {
  max-width: 1000px;
  margin: 0 auto;
  padding: 40px 48px;
}

/* ============================================================
   HERO SECTION (Homepage)
   ============================================================ */
.hero {
  background: linear-gradient(135deg, #0D6EFD 0%, #0056CC 60%, #003A8C 100%);
  border-radius: 16px;
  padding: 48px 40px;
  color: white;
  margin-bottom: 40px;
  max-width: 1000px;
}

.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.8rem;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.3;
}

.hero p {
  font-size: 1rem;
  opacity: 0.9;
  line-height: 1.7;
  margin-bottom: 0;
  color: #FFFFFF;
}

/* ============================================================
   CHAPTER NAVIGATION CARDS
   ============================================================ */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 32px 0;
}

.chapter-card {
  background: var(--primary);
  border-radius: 12px;
  padding: 20px;
  color: white;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 130px;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}

.chapter-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(13,110,253,0.3);
}

.chapter-card svg {
  width: 28px;
  height: 28px;
  color: white;
}

.chapter-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
}

.chapter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--secondary);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  align-self: flex-end;
}

/* ============================================================
   PAGE HEADINGS
   ============================================================ */
.page-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 1rem;
  color: var(--text-gray);
  margin-bottom: 32px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary);
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.subsection-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
  margin: 28px 0 12px;
}

/* ============================================================
   BODY TEXT & PARAGRAPHS
   ============================================================ */
p {
  font-size: 1rem;
  color: var(--text-dark);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

/* ============================================================
   IMAGES & FIGURES
   ============================================================ */
.figure-block {
  margin: 28px 0;
  text-align: center;
}

.figure-block img {
  width: 100%;
  max-width: 900px;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  display: block;
  margin: 0 auto;
  aspect-ratio: 3/2;
  object-fit: cover;
}

.figure-caption {
  font-size: 0.875rem;
  color: var(--text-gray);
  margin-top: 10px;
  font-style: italic;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  margin: 24px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:nth-child(even) { background: var(--bg-light); }
tbody tr:hover { background: #e8f0fe; }

tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}

/* ============================================================
   LISTS
   ============================================================ */
ul.bullet-list, ol.numbered-list {
  margin: 16px 0 24px 20px;
  line-height: 1.6;
}

ul.bullet-list li, ol.numbered-list li {
  margin-bottom: 8px;
  color: var(--text-dark);
}

/* ============================================================
   INFO / WARNING CARDS
   ============================================================ */
.info-card {
  background: #e8f0fe;
  border-left: 4px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 20px 0;
}

.warning-card {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 20px 0;
}

.success-card {
  background: #d1e7dd;
  border-left: 4px solid var(--secondary);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 20px 0;
}

/* ============================================================
   METRIC CARDS (KPI grid)
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 24px 0;
}

.kpi-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  display: block;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-gray);
}

/* ============================================================
   SCENARIO CARDS (Chapter 3)
   ============================================================ */
.scenario-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 28px 0;
}

.scenario-header {
  background: var(--primary);
  color: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.scenario-number {
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.scenario-body { padding: 24px; }

/* ============================================================
   FOOTER
   ============================================================ */
.page-footer {
  margin-top: 60px;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-gray);
  font-size: 0.875rem;
}

/* ============================================================
   CALCULATOR STYLES (Chapter 9)
   ============================================================ */
.calc-container {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin: 24px 0;
}

.calc-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.calc-field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-gray);
  margin-bottom: 6px;
  font-weight: 500;
}

.calc-field input, .calc-field select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: white;
  color: var(--text-dark);
}

.calc-field input:focus, .calc-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}

.calc-results {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-top: 16px;
}

.calc-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.calc-result-item:last-child { border-bottom: none; }

.calc-result-label { font-size: 0.9rem; color: var(--text-gray); }

.calc-result-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.calc-result-value.warning { color: #dc3545; }
.calc-result-value.success { color: var(--secondary); }

.calc-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 8px;
}

.calc-btn:hover { background: #0056CC; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .sidebar { width: 220px; }
  .main-content { margin-left: 220px; }
  .chapter-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .calc-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .content-wrapper { padding: 24px 20px; }
  .chapter-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
}
