/* ============================================================
   Critical Data Transmission Security Design Guide
   Shared Stylesheet - Solution Mall Knowledge Center
   ============================================================ */

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

:root {
  --primary: #0D6EFD;
  --primary-dark: #0a58ca;
  --success: #198754;
  --sidebar-width: 280px;
  --content-max: 1000px;
  --text-dark: #212529;
  --text-muted: #6c757d;
  --border: #dee2e6;
  --bg-light: #f8f9fa;
  --bg-offwhite: #F4F7F6;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 8px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-dark);
  background: #fff;
}

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

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.sidebar-logo a.site-url {
  display: block;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--primary);
  text-decoration: none;
}
.sidebar-logo a.site-url:hover { text-decoration: underline; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 80px; /* 5rem */
  padding: 0 20px;
  text-decoration: none;
  color: var(--text-dark);
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.nav-item:hover { background: #f0f4ff; }

.nav-item.active {
  border-left-color: var(--primary);
  background: #e8f0fe;
  color: var(--primary);
}

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

.nav-item span { line-height: 1.3; }

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

.content-wrapper {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 40px 48px 80px;
}

/* ============================================================
   HERO SECTION (Homepage)
   ============================================================ */
.hero {
  background: linear-gradient(135deg, #0D6EFD 0%, #5DADE2 100%);
  border-radius: 16px;
  padding: 60px 50px;
  margin-bottom: 40px;
  color: #fff;
}

.hero-tag {
  display: inline-block;
  font-size: 0.875rem;
  background: rgba(255,255,255,0.2);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 16px;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: #fff !important;
  margin-bottom: 16px;
  line-height: 1.2;
}

.hero p {
  font-size: 1rem;
  line-height: 1.6;
  opacity: 0.92;
  max-width: 680px;
  margin-bottom: 28px;
}

.hero-btns { display: flex; gap: 12px; flex-wrap: wrap; }

.btn-primary-white {
  background: #fff;
  color: var(--primary);
  border: none;
  padding: 12px 28px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: opacity 0.15s;
}
.btn-primary-white:hover { opacity: 0.9; }

.btn-outline-white {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.7);
  padding: 10px 28px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s;
}
.btn-outline-white:hover { background: rgba(255,255,255,0.15); }

/* ============================================================
   CHAPTER NAVIGATION CARDS (Homepage)
   ============================================================ */
.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary);
  display: inline-block;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  background: var(--bg-offwhite);
  padding: 24px;
  border-radius: var(--radius);
  margin-bottom: 40px;
}

.chapter-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 15px;
  height: 130px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: #333;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
  overflow: hidden;
}

.chapter-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(13,110,253,0.15);
}

.chapter-card-icon {
  width: 40px; height: 40px;
  flex-shrink: 0;
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}

.chapter-card-icon svg { width: 40px; height: 40px; }

.chapter-card-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chapter-badge {
  position: absolute;
  top: 8px; right: 8px;
  width: 24px; height: 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ============================================================
   OVERVIEW SECTION (Homepage)
   ============================================================ */
.overview-section {
  margin-bottom: 40px;
}

.overview-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}

.overview-section p {
  margin-bottom: 16px;
  line-height: 1.7;
  color: var(--text-dark);
}

/* ============================================================
   CHAPTER PAGE STYLES
   ============================================================ */
.page-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.page-header .subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.section {
  margin-bottom: 48px;
}

.section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e8f0fe;
}

.section h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 12px;
  margin-top: 24px;
}

.section p {
  margin-bottom: 16px;
  line-height: 1.7;
}

/* ============================================================
   IMAGE / FIGURE STYLES
   ============================================================ */
.figure-block {
  margin: 24px 0;
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.figure-block img {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 3/2;
  object-fit: cover;
}

.figure-caption {
  padding: 10px 16px;
  font-size: 0.875rem;
  color: var(--text-muted);
  background: #f8f9fa;
  border-top: 1px solid var(--border);
  text-align: center;
  font-style: italic;
}

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

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

thead tr {
  background: var(--primary);
  color: #fff;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

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

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

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

.info-box p { margin: 0; }

.warning-box {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  padding: 16px 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 20px 0;
}

/* ============================================================
   LISTS
   ============================================================ */
.content-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.content-list li {
  padding: 6px 0 6px 20px;
  position: relative;
  line-height: 1.6;
}

.content-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

ol.content-list { counter-reset: item; }
ol.content-list li { counter-increment: item; }
ol.content-list li::before {
  content: counter(item) '.';
  font-weight: 600;
  color: var(--primary);
}

/* ============================================================
   SCENARIO CARDS (Chapter 3)
   ============================================================ */
.scenario-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 40px;
  box-shadow: var(--shadow);
}

.scenario-header {
  background: linear-gradient(135deg, var(--primary) 0%, #5DADE2 100%);
  color: #fff;
  padding: 20px 24px;
}

.scenario-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.scenario-body { padding: 24px; }

.scenario-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.metric-item {
  background: #f0f4ff;
  border-radius: 8px;
  padding: 12px 16px;
  border-left: 3px solid var(--primary);
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}

/* ============================================================
   CALCULATOR STYLES (Chapter 9)
   ============================================================ */
.calc-container {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 40px;
  box-shadow: var(--shadow);
}

.calc-header {
  background: linear-gradient(135deg, #0D6EFD 0%, #5DADE2 100%);
  color: #fff;
  padding: 20px 24px;
}

.calc-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 4px;
}

.calc-header p {
  font-size: 0.875rem;
  opacity: 0.85;
  margin: 0;
}

.calc-body {
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.calc-inputs h4, .calc-outputs h4 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.input-group {
  margin-bottom: 14px;
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.input-group input[type="number"],
.input-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text-dark);
  background: #fff;
  transition: border-color 0.15s;
}

.input-group input[type="number"]:focus,
.input-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}

.input-group input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.range-display {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.output-item {
  background: #f0f4ff;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
  border-left: 3px solid var(--primary);
}

.output-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.output-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

.output-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 4px;
}

.output-highlight {
  background: linear-gradient(135deg, #0D6EFD 0%, #5DADE2 100%);
  color: #fff;
  border-radius: 8px;
  padding: 16px;
  margin-top: 8px;
  text-align: center;
}

.output-highlight .output-label { color: rgba(255,255,255,0.8); }
.output-highlight .output-value { color: #fff; font-size: 1.8rem; }
.output-highlight .output-unit { color: rgba(255,255,255,0.8); }

/* ============================================================
   PRODUCT STACK CARDS (Chapter 5)
   ============================================================ */
.product-stack {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 24px 0;
}

.product-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.product-card-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 18px;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.product-card-body {
  padding: 16px 18px;
}

.product-card-body ul {
  list-style: none;
  padding: 0;
}

.product-card-body ul li {
  padding: 4px 0 4px 16px;
  position: relative;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-dark);
}

.product-card-body ul li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: 700;
  font-size: 0.8rem;
}

/* ============================================================
   FOOTER
   ============================================================ */
.page-footer {
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.page-footer a { color: var(--primary); text-decoration: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .content-wrapper { padding: 24px 20px 60px; }
  .hero { padding: 40px 24px; }
  .hero h1 { font-size: 1.8rem; }
  .chapter-grid { grid-template-columns: 1fr 1fr; }
  .calc-body { grid-template-columns: 1fr; }
  .product-stack { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .chapter-grid { grid-template-columns: 1fr; }
}
