/* ==============================================================================
   FIREGUARD 4 ULTIMATE - WEB DESIGN SYSTEM (VANILLA CSS)
   Rich Aesthetics, Dark Mode Glassmorphism, Micro-animations
   ============================================================================== */

:root {
  --bg-app: #090D16;
  --bg-sidebar: #0F172A;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(51, 65, 85, 0.8);
  --bg-input: rgba(15, 23, 42, 0.8);
  
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-focus: #06B6D4;
  
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  
  --primary: #3B82F6;
  --primary-glow: rgba(59, 130, 246, 0.35);
  --accent: #06B6D4;
  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.15);
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==============================================================================
   LAYOUT
   ============================================================================== */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* SIDEBAR */
.sidebar {
  width: 290px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  user-select: none;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-x: hidden;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-glass);
}

.logo-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.6));
}

.logo-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #F87171, #FBBF24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-subtitle {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent);
  display: block;
}

.engine-badge {
  display: inline-block;
  margin-top: 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 12px 10px 6px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 3px;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  transform: translateX(3px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(6, 182, 212, 0.15));
  color: var(--text-main);
  font-weight: 600;
  border: 1px solid rgba(59, 130, 246, 0.4);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.nav-icon {
  font-size: 16px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-glass);
}

.standards-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.std-item {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
  overflow-x: hidden;
  overflow-y: hidden;
  min-width: 0;
  width: 100%;
}

/* TOPBAR */
.topbar {
  height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(12px);
  z-index: 10;
  flex-shrink: 0;
}

.breadcrumb {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* TABS CONTAINER */
.tab-content-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
  min-width: 0;
}

.tab-pane.active {
  display: block;
}

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

/* ==============================================================================
   CARDS & GRIDS
   ============================================================================== */
.grid-2-col {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 20px;
  width: 100%;
}

.grid-2-col > * {
  min-width: 0;
}

.card {
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.card-footer {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ==============================================================================
   CAD CANVAS
   ============================================================================== */
.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #080C14;
  overflow: hidden;
  box-sizing: border-box;
}

#cad-canvas {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  height: auto;
  cursor: grab;
}

#cad-canvas:active {
  cursor: grabbing;
}

.cad-tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #fff;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 50;
  max-width: 260px;
}

.cad-tooltip.hidden {
  display: none;
}

.canvas-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.layout-btn-group {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.layout-toggle-btn {
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 4px;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
  transition: var(--transition);
}

.layout-toggle-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.layout-toggle-btn.active {
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 600;
}

body.light-theme .layout-btn-group {
  background: #F1F5F9;
  border-color: #CBD5E1;
}

body.light-theme .layout-toggle-btn {
  color: #475569;
}

body.light-theme .layout-toggle-btn:hover {
  background: #E2E8F0;
  color: #0F172A;
}

body.light-theme .layout-toggle-btn.active {
  background: #2563EB;
  color: #FFFFFF;
}

.legend-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
}

.chip-a { background: rgba(239, 68, 68, 0.2); color: #F87171; border: 1px solid rgba(239, 68, 68, 0.4); }
.chip-b { background: rgba(249, 115, 22, 0.2); color: #FB923C; border: 1px solid rgba(249, 115, 22, 0.4); }
.chip-c { background: rgba(234, 179, 8, 0.2); color: #FACC15; border: 1px solid rgba(234, 179, 8, 0.4); }

/* ==============================================================================
   METRICS & STATS
   ============================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
  margin-top: 4px;
}

.metrics-hero {
  text-align: center;
  padding: 24px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.8), rgba(15, 23, 42, 0.4));
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  margin-bottom: 18px;
}

.metric-big {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}

.metric-num {
  font-size: 44px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: #F87171;
  text-shadow: 0 0 25px rgba(239, 68, 68, 0.4);
}

.metric-unit {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-muted);
}

.metric-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

.summary-box {
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 13px;
  color: #E2E8F0;
  margin-bottom: 18px;
  line-height: 1.6;
}

.recs-box {
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 14px;
  border: 1px solid var(--border-glass);
}

.recs-box p {
  font-size: 12.5px;
  color: #CBD5E1;
  margin-bottom: 6px;
}

.recs-box p:last-child {
  margin-bottom: 0;
}

/* ==============================================================================
   FORMS & INPUTS
   ============================================================================== */
.calc-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.col-4 { flex: 1; }
.col-6 { flex: 1; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-mono);
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #2563EB, #06B6D4);
  color: #FFFFFF;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1D4ED8, #0891B2);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-danger { background: var(--danger-bg); color: #F87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-warning { background: var(--warning-bg); color: #FBBF24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-success { background: var(--success-bg); color: #34D399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-accent { background: rgba(6, 182, 212, 0.15); color: #22D3EE; border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-new { background: rgba(168, 85, 247, 0.2); color: #C084FC; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-neutral { background: rgba(148, 163, 184, 0.15); color: #94A3B8; }

.text-danger { color: #F87171 !important; }
.text-warning { color: #FBBF24 !important; }
.text-success { color: #34D399 !important; }

/* ==============================================================================
   TABLES
   ============================================================================== */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.data-table th {
  background: rgba(15, 23, 42, 0.8);
  padding: 12px 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-glass);
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.data-table tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ==============================================================================
   TOOLS GRID
   ============================================================================== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.tool-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.tool-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.tool-res {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--accent);
}

.chart-box {
  height: 220px;
  margin-top: 14px;
}

.mt-2 { margin-top: 8px; }

/* ==============================================================================
   RESPONSIVE DESIGN SYSTEM (DESKTOP, LAPTOP, TABLET, MOBILE PHONES)
   ============================================================================== */

/* Header Top in Sidebar */
.sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.sidebar-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
  margin-right: 12px;
  transition: var(--transition);
}

.mobile-menu-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.topbar-left {
  display: flex;
  align-items: center;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 95;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* ==============================================================================
   RESPONSIVE BỐ CỤC CHO MÀN HÌNH LAPTOP & DESKTOP (<= 1440px)
   Tự động đẩy cột bên phải xuống dưới khi Sidebar mở rộng để vừa khít màn hình!
   ============================================================================== */
@media screen and (max-width: 1440px) {
  /* Khi sidebar ĐANG MỞ: Tự động đẩy cột 2 xuống dưới */
  body:not(.sidebar-collapsed):not(.layout-force-split) .grid-2-col {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  body:not(.sidebar-collapsed):not(.layout-force-split) #tab-complex .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .topbar {
    padding: 0 16px;
  }

  .breadcrumb {
    max-width: 220px;
    font-size: 14px;
  }

  .select-practical {
    max-width: 200px;
  }
}

/* Khi người dùng chủ động chọn chế độ Xếp Chồng (Stacked Mode) */
body.layout-force-stacked .grid-2-col {
  grid-template-columns: 1fr !important;
}

body.layout-force-stacked #tab-complex .stats-grid {
  grid-template-columns: repeat(4, 1fr) !important;
}

/* Khi người dùng chủ động chọn chế độ 2 Cột Song Song (Split Mode) */
body.layout-force-split .grid-2-col {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) !important;
}

body.layout-force-split #tab-complex .stats-grid {
  grid-template-columns: repeat(2, 1fr) !important;
}

/* TABLET & LAPTOP ADAPTATION (<= 1024px) */
@media screen and (max-width: 1024px) {
  .app-layout {
    position: relative;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 290px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.6);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: flex;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .main-content {
    width: 100%;
    height: 100vh;
  }

  .grid-2-col {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .tools-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* MOBILE PHONES (<= 768px) */
@media screen and (max-width: 768px) {
  .topbar {
    height: 56px;
    padding: 0 14px;
  }

  .breadcrumb {
    font-size: 13.5px;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-right {
    gap: 6px;
  }

  .topbar-right .btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .btn-label {
    display: none;
  }

  .tab-content-container {
    padding: 14px;
  }

  .card {
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .form-row {
    flex-direction: column;
    gap: 10px;
  }

  .col-4, .col-6 {
    width: 100%;
    flex: none;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card {
    padding: 10px;
  }

  .stat-label {
    font-size: 11px;
  }

  .stat-value {
    font-size: 15px;
  }

  .metric-num {
    font-size: 32px;
  }

  .metric-unit {
    font-size: 16px;
  }

  .canvas-wrapper {
    overflow-x: auto;
  }

  #cad-canvas {
    touch-action: none;
  }

  .data-table th, .data-table td {
    padding: 8px 10px;
    font-size: 11.5px;
  }

  /* Material Row responsive grid */
  .mat-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    flex-direction: unset !important;
    background: rgba(255, 255, 255, 0.02);
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.07);
    margin-bottom: 10px;
  }

  .mat-row .mat-name {
    grid-column: 1 / -1;
    width: 100% !important;
  }

  .mat-row .mat-mass,
  .mat-row .mat-lhv {
    width: 100% !important;
  }
}

/* SMALL MOBILE PHONES (<= 480px) */
@media screen and (max-width: 480px) {
  .topbar {
    padding: 0 10px;
  }

  .breadcrumb {
    max-width: 110px;
    font-size: 12.5px;
  }

  .tab-content-container {
    padding: 10px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .card-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .canvas-controls {
    flex-wrap: wrap;
    gap: 4px;
  }

  .metric-num {
    font-size: 28px;
  }

  .metrics-hero {
    padding: 14px;
  }

  .select-practical {
    max-width: 140px;
    font-size: 11px;
    padding: 4px 6px;
  }
}

/* ==============================================================================
   ULTIMATE SUITE SPECIFIC STYLES
   ============================================================================== */
.select-practical {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--border-glass);
  color: var(--accent);
  font-weight: 500;
  max-width: 280px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.select-practical:hover {
  background: rgba(30, 41, 59, 1);
  border-color: var(--accent);
}

.sign-preview-wrapper svg {
  max-width: 100%;
  height: auto;
  max-height: 380px;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.4));
  transition: transform 0.3s ease;
}

.sign-preview-wrapper svg:hover {
  transform: scale(1.02);
}

.bldg-room-row input,
.bldg-room-row select {
  font-size: 12px;
}

/* ==============================================================================
   MANUAL & PRACTICAL GUIDE (SÁCH HƯỚNG DẪN & CẨM NANG THỰC HÀNH)
   ============================================================================== */
.manual-card {
  padding: 24px;
}

.manual-subtab-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.manual-toggle-btn {
  font-weight: 600;
  transition: all 0.2s ease;
  border-radius: var(--radius-sm);
}

.manual-toggle-btn.active {
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
  border: 1px solid var(--accent);
}

.manual-toc {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-glass);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 28px;
}

.manual-toc strong {
  display: block;
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.manual-toc ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 8px 16px;
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.manual-toc li a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  display: inline-block;
  transition: color 0.15s ease, transform 0.15s ease;
}

.manual-toc li a:hover {
  color: var(--primary-light);
  transform: translateX(4px);
}

.manual-article {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  margin-bottom: 24px;
  backdrop-filter: blur(10px);
}

.manual-article h3 {
  font-size: 17px;
  font-weight: 700;
  color: #F8FAFC;
  margin-top: 0;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.manual-article p {
  color: #CBD5E1;
  font-size: 14px;
  line-height: 1.65;
  margin-bottom: 12px;
}

.manual-article ul, .manual-article ol {
  color: #CBD5E1;
  font-size: 13.5px;
  line-height: 1.6;
  padding-left: 20px;
  margin-bottom: 14px;
}

.manual-figure {
  margin: 18px 0;
  text-align: center;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.manual-figure img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  display: block;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  transition: transform 0.25s ease;
}

.manual-figure img:hover {
  transform: scale(1.01);
}

.figure-caption {
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 500;
  margin-top: 10px;
  margin-bottom: 0;
  font-style: italic;
}

.example-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 14px 0;
}

.example-box h4 {
  font-size: 14.5px;
  font-weight: 600;
  color: #38BDF8;
  margin-top: 0;
  margin-bottom: 8px;
}

.example-box p {
  font-size: 13.5px;
  margin-bottom: 6px;
}

/* ==============================================================================
   SIDEBAR TOGGLE & COLLAPSIBLE SIDEBAR (DESKTOP / LAPTOP)
   ============================================================================== */
.sidebar-toggle-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
  margin-right: 12px;
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--primary);
  transform: scale(1.06);
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  transform: translateY(-1px);
}

/* Collapsed Sidebar on Desktop Screens (>= 1025px) */
@media screen and (min-width: 1025px) {
  body.sidebar-collapsed .sidebar {
    width: 72px;
  }

  body.sidebar-collapsed .sidebar-header {
    padding: 18px 8px;
    display: flex;
    justify-content: center;
    border-bottom: 1px solid var(--border-glass);
  }

  body.sidebar-collapsed .logo-box {
    justify-content: center;
    width: 100%;
  }

  body.sidebar-collapsed .logo-icon {
    font-size: 28px;
    margin: 0 auto;
  }

  body.sidebar-collapsed .logo-title,
  body.sidebar-collapsed .logo-subtitle,
  body.sidebar-collapsed .engine-badge,
  body.sidebar-collapsed .sidebar-footer {
    display: none !important;
  }

  body.sidebar-collapsed .nav-section-title {
    height: 1px;
    background: var(--border-glass);
    margin: 12px 10px;
    padding: 0;
    text-indent: -9999px;
    overflow: hidden;
  }

  body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
    gap: 0;
    position: relative;
  }

  body.sidebar-collapsed .nav-item span:not(.nav-icon),
  body.sidebar-collapsed .nav-item .badge {
    display: none !important;
  }

  body.sidebar-collapsed .nav-icon {
    font-size: 20px;
    margin: 0;
  }

  /* Tooltip hiển thị tên chức năng khi hover vào icon lúc sidebar thu gọn */
  body.sidebar-collapsed .nav-item:hover::after {
    content: attr(title);
    position: absolute;
    left: 78px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(15, 23, 42, 0.95);
    color: #F8FAFC;
    padding: 7px 14px;
    font-size: 12.5px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border-glass);
    pointer-events: none;
    animation: fadeIn 0.15s ease;
  }

  body.light-theme.sidebar-collapsed .nav-item:hover::after {
    background: #0F172A;
    color: #FFFFFF;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
  }

  /* Icon mũi tên xoay ngược khi thu gọn */
  body.sidebar-collapsed #btn-sidebar-toggle .collapse-icon {
    display: inline-block;
    transform: rotate(180deg);
  }
}

/* ==============================================================================
   LIGHT THEME (CHẾ ĐỘ SÁNG HIỆN ĐẠI & THANH LỊCH)
   ============================================================================== */
body.light-theme {
  --bg-app: #F8FAFC;
  --bg-sidebar: #FFFFFF;
  --bg-card: rgba(255, 255, 255, 0.96);
  --bg-card-hover: #F1F5F9;
  --bg-input: #FFFFFF;
  
  --border-glass: rgba(226, 232, 240, 0.9);
  --border-focus: #0284C7;
  
  --text-main: #0F172A;
  --text-muted: #475569;
  --text-dim: #94A3B8;
  
  --primary: #2563EB;
  --primary-glow: rgba(37, 99, 235, 0.2);
  --accent: #0284C7;
  --danger: #DC2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --warning: #D97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  --success: #059669;
  --success-bg: rgba(5, 150, 105, 0.08);
  
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
}

body.light-theme {
  background-color: #F8FAFC;
  color: #0F172A;
}

body.light-theme .topbar {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

body.light-theme .breadcrumb {
  color: #0F172A;
}

body.light-theme .sidebar {
  background-color: #FFFFFF;
  border-right: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
}

body.light-theme .sidebar-header {
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
}

body.light-theme .sidebar-footer {
  border-top: 1px solid rgba(226, 232, 240, 0.95);
}

body.light-theme .sidebar-toggle-btn {
  background: #F1F5F9;
  color: #475569;
  border: 1px solid #CBD5E1;
}

body.light-theme .sidebar-toggle-btn:hover {
  background: #E2E8F0;
  color: #0F172A;
  border-color: #2563EB;
}

body.light-theme .mobile-menu-btn {
  background: #F1F5F9;
  color: #475569;
  border: 1px solid #CBD5E1;
}

body.light-theme .card,
body.light-theme .glass-card {
  background: #FFFFFF;
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.04);
}

body.light-theme .card-title {
  color: #0F172A;
}

body.light-theme .card-desc {
  color: #64748B;
}

body.light-theme .form-control,
body.light-theme .select-practical {
  background: #FFFFFF;
  color: #0F172A;
  border: 1px solid #CBD5E1;
}

body.light-theme .form-control:focus,
body.light-theme .select-practical:focus {
  border-color: #0284C7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

body.light-theme .form-label {
  color: #334155;
}

body.light-theme .data-table th {
  background: #F8FAFC;
  color: #475569;
  border-bottom: 1px solid #E2E8F0;
}

body.light-theme .data-table td {
  border-bottom: 1px solid #F1F5F9;
  color: #1E293B;
}

body.light-theme .data-table tr:hover {
  background: #F8FAFC;
}

body.light-theme .nav-item {
  color: #475569;
}

body.light-theme .nav-item:hover {
  background: #F1F5F9;
  color: #0F172A;
}

body.light-theme .nav-item.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(2, 132, 199, 0.1));
  color: #1D4ED8;
  border: 1px solid rgba(37, 99, 235, 0.3);
}

body.light-theme .btn-secondary {
  background: #F1F5F9;
  color: #334155;
  border: 1px solid #CBD5E1;
}

body.light-theme .btn-secondary:hover {
  background: #E2E8F0;
  color: #0F172A;
}

body.light-theme .btn-ghost {
  color: #475569;
}

body.light-theme .btn-ghost:hover {
  color: #0F172A;
  background: #F1F5F9;
}

body.light-theme .manual-article {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

body.light-theme .manual-article h3 {
  color: #0F172A;
  border-bottom: 1px solid #F1F5F9;
}

body.light-theme .manual-article p,
body.light-theme .manual-article ul,
body.light-theme .manual-article ol {
  color: #334155;
}

body.light-theme .manual-toc {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-left: 4px solid var(--primary);
}

body.light-theme .manual-toc strong {
  color: #0284C7;
}

body.light-theme .manual-toc li a {
  color: #475569;
}

body.light-theme .manual-toc li a:hover {
  color: #2563EB;
}

body.light-theme .example-box {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-left: 4px solid #0284C7;
}

body.light-theme .example-box h4 {
  color: #0284C7;
}

body.light-theme .manual-figure {
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
}

body.light-theme .metrics-hero {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(2, 132, 199, 0.05));
  border: 1px solid rgba(37, 99, 235, 0.2);
}

body.light-theme .formula-box {
  background: #F1F5F9;
  color: #1E293B;
  border: 1px solid #E2E8F0;
}

body.light-theme .canvas-wrapper {
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
}

body.light-theme .canvas-btn {
  background: #F1F5F9;
  color: #334155;
  border: 1px solid #CBD5E1;
}

body.light-theme .canvas-btn:hover {
  background: #E2E8F0;
  color: #0F172A;
}

body.light-theme .cad-legend {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #CBD5E1;
  color: #0F172A;
}

body.light-theme .stat-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

body.light-theme .stat-value {
  color: #0F172A;
}

body.light-theme .stat-label {
  color: #64748B;
}


