/* ============================================
   Security Systems Lightning Protection Guide
   Main Stylesheet
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: #212529;
  background: #f8f9fa;
}

/* --- Layout --- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 280px;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid #dee2e6;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}

.sidebar-logo {
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  flex-shrink: 0;
}

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

.sidebar-logo a {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: #0D6EFD;
  text-decoration: none;
}

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

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  height: 80px;
  padding: 12px 16px;
  text-decoration: none;
  color: #212529;
  font-size: 0.9rem;
  border-left: 4px solid transparent;
  transition: background 0.15s;
  gap: 16px;
  position: relative;
}

.sidebar-nav a:hover {
  background: #f8f9fa;
  cursor: pointer;
}

.sidebar-nav a.active {
  border-left-color: #0D6EFD;
  background: #f8f9fa;
  color: #0D6EFD;
  font-weight: 600;
}

.sidebar-nav a svg {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  color: #0D6EFD;
}

.sidebar-nav a span { line-height: 1.3; }

/* --- Main Content --- */
.main-content {
  margin-left: 280px;
  min-height: 100vh;
  background: #ffffff;
}

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

/* --- Hero Section --- */
.hero {
  background: linear-gradient(135deg, #0D6EFD 0%, #1a5dc8 60%, #0a4aad 100%);
  border-radius: 16px;
  padding: 60px 50px;
  margin-bottom: 40px;
  color: #fff;
}

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

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

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

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

.btn-primary-hero {
  background: #ffffff;
  color: #0D6EFD;
  padding: 10px 28px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

.btn-primary-hero:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-secondary-hero {
  background: transparent;
  color: #ffffff;
  padding: 10px 28px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  border: 2px solid rgba(255,255,255,0.7);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.btn-secondary-hero:hover { background: rgba(255,255,255,0.15); transform: translateY(-1px); }

/* --- Section Headings --- */
h1.page-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #0D6EFD;
  margin-bottom: 8px;
}

h2 {
  font-size: 2rem;
  font-weight: 700;
  color: #0D6EFD;
  margin-bottom: 16px;
  margin-top: 40px;
}

h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #0D6EFD;
  margin-bottom: 12px;
  margin-top: 32px;
}

h4 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #0D6EFD;
  margin-bottom: 10px;
  margin-top: 24px;
}

.page-subtitle {
  font-size: 0.875rem;
  color: #6c757d;
  margin-bottom: 16px;
}

.section-divider {
  border: none;
  border-top: 1px solid #dee2e6;
  margin: 16px 0 32px;
}

/* --- Paragraphs & Text --- */
p {
  font-size: 1rem;
  color: #212529;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* --- Chapter Nav Cards --- */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 32px 0;
  background: #f4f7f6;
  padding: 24px;
  border-radius: 12px;
}

.chapter-card {
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #dee2e6;
  padding: 15px;
  height: 130px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: #333333;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}

.chapter-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.chapter-card-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  color: #0D6EFD;
}

.chapter-card-title {
  font-size: 1rem;
  font-weight: 500;
  color: #333333;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

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

/* --- Images --- */
.figure-block {
  margin: 24px 0;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  background: #f8f9fa;
}

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

.figure-caption {
  padding: 10px 16px;
  font-size: 0.875rem;
  color: #6c757d;
  text-align: center;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  margin: 24px 0;
  border-radius: 8px;
  border: 1px solid #dee2e6;
}

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

thead th {
  background: #f8f9fa;
  color: #212529;
  font-weight: 700;
  font-size: 0.875rem;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid #dee2e6;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #dee2e6;
  color: #212529;
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) td { background: #f8f9fa; }

/* --- Lists --- */
ul.content-list, ol.content-list {
  padding-left: 20px;
  margin-bottom: 24px;
}

ul.content-list li, ol.content-list li {
  line-height: 1.6;
  margin-bottom: 8px;
  color: #212529;
}

ul.content-list { list-style: disc; }

/* --- Cards --- */
.info-card {
  background: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.075);
}

.info-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

/* --- Scenario Cards (Ch3) --- */
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin: 24px 0;
}

.scenario-card {
  background: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.075);
}

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

.scenario-card-body {
  padding: 16px;
}

.scenario-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: #0D6EFD;
  margin-bottom: 8px;
}

.scenario-card-desc {
  font-size: 0.875rem;
  color: #212529;
  line-height: 1.6;
  margin-bottom: 12px;
}

.scenario-metrics {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 10px 12px;
}

.scenario-metrics-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.scenario-metrics ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.scenario-metrics ul li {
  font-size: 0.8rem;
  color: #212529;
  padding: 2px 0;
  padding-left: 14px;
  position: relative;
}

.scenario-metrics ul li::before {
  content: "•";
  color: #0D6EFD;
  position: absolute;
  left: 0;
}

/* --- Calculator Section --- */
.calc-container {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 32px;
}

.calc-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0D6EFD;
  margin-bottom: 6px;
}

.calc-subtitle {
  font-size: 0.875rem;
  color: #6c757d;
  margin-bottom: 20px;
}

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

.calc-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #212529;
  margin-bottom: 6px;
}

.calc-field input[type="number"],
.calc-field select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 0.9rem;
  color: #212529;
  background: #fff;
  transition: border-color 0.15s;
}

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

.calc-field .field-hint {
  font-size: 0.75rem;
  color: #6c757d;
  margin-top: 4px;
}

.calc-btn {
  background: #0D6EFD;
  color: #fff;
  padding: 10px 28px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.calc-btn:hover { background: #0b5ed7; transform: translateY(-1px); }

.calc-results {
  margin-top: 20px;
  background: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 20px;
  display: none;
}

.calc-results.visible { display: block; }

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

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

.result-label { font-size: 0.9rem; color: #6c757d; }

.result-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0D6EFD;
}

.result-recommendation {
  margin-top: 12px;
  padding: 12px;
  background: #e7f1ff;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #0a3d8a;
}

/* Range slider */
input[type="range"] {
  width: 100%;
  accent-color: #0D6EFD;
}

/* --- Highlight boxes --- */
.highlight-box {
  background: #e7f1ff;
  border-left: 4px solid #0D6EFD;
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 20px 0;
}

.highlight-box p { margin-bottom: 0; color: #0a3d8a; }

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

.warning-box p { margin-bottom: 0; color: #664d03; }

/* --- Footer --- */
.page-footer {
  margin-top: 60px;
  padding: 24px 0;
  border-top: 1px solid #dee2e6;
  text-align: center;
  font-size: 0.875rem;
  color: #6c757d;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .sidebar { width: 240px; }
  .main-content { margin-left: 240px; }
  .content-wrapper { padding: 24px 20px; }
  .chapter-grid { grid-template-columns: repeat(2, 1fr); }
  .scenario-grid { grid-template-columns: 1fr; }
  .calc-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .chapter-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.75rem; }
}
