:root {
  --primary: #0f172a;
  --secondary: #f27200;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --bg-light: #f8fafc;
  --border: #e2e8f0;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.facilities-hero {
  padding: 12rem 2rem 5rem;
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.75)), url('assets/images/hero_bg.png');
  background-size: cover;
  background-position: center;
  color: white;
  text-align: center;
  position: relative;
  overflow: hidden;
  min-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .facilities-hero {
    padding: 18rem 1.5rem 8rem;
    min-height: 300px;
    text-align: center;
  }

  .facilities-hero-content {
    text-align: center;
    width: 100%;
  }
}

.facilities-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 30% 60%, rgba(242, 114, 0, 0.15), transparent 60%),
    radial-gradient(ellipse at 70% 40%, rgba(242, 114, 0, 0.08), transparent 50%);
  pointer-events: none;
}

.facilities-hero h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin-bottom: 1rem;
  font-family: 'Outfit', sans-serif;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.facilities-hero p {
  font-size: 1.2rem;
  color: #cbd5e1;
  max-width: 700px;
  margin: 0 auto;
  text-align: center;
}

@media (max-width: 768px) {
  .facilities-hero h1 {
    font-size: 2.2rem;
    margin-bottom: 0.75rem;
    text-align: center !important;
  }

  .facilities-hero p {
    font-size: 1.05rem;
    padding: 0 0.5rem;
    text-align: center !important;
    margin-left: auto;
    margin-right: auto;
  }

  .facilities-hero .hero-subtitle {
    text-align: center;
    margin-bottom: 0.5rem;
  }
}

.facilities-hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--secondary), transparent);
}

.facilities-container {
  max-width: 1280px;
  margin: 2rem auto 4rem;
  padding: 0 2rem;
  display: block;
  /* Stack vertically for full width content */
  height: auto;
  position: static;
  min-height: unset;
}

/* Horizontal Tabs Bar */
.tabs-mobile-wrapper {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  margin-bottom: 2.5rem;
}

@media (max-width: 768px) {
  .tabs-mobile-wrapper {
    margin-bottom: 2rem;
  }
}

.facilities-tabs {
  flex: 1;
  min-width: 0;
  position: static;
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  overflow-y: visible;
  height: auto;
  max-height: none;
  padding: 0.5rem 0 0.75rem 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  gap: 0.5rem;
  top: unset;
  align-self: unset;
}

.facilities-tabs::-webkit-scrollbar {
  display: block;
  height: 5px;
}

.facilities-tabs::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
}

.facilities-tabs::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.facilities-tabs::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

@media (max-width: 768px) {
  .facilities-tabs {
    padding: 0.5rem 0 1rem 0;
    gap: 0.5rem;
  }
}

.tab-btn {
  white-space: nowrap;
  padding: 0.9rem 1.25rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .tab-btn {
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
  }
}

.tab-btn i {
  display: none;
  /* Hide internal arrow */
}

.tab-btn:hover {
  border-color: #f27200;
  color: #0f172a;
  background: #fff;
}

@media (max-width: 768px) {
  .tab-btn:hover {
    transform: translateY(-1px);
  }
}

.tab-btn.active {
  background: #0f172a;
  color: white;
  border-color: #0f172a;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
}

.tabs-mobile-wrapper > .tabs-scroll-btn {
  display: none !important;
}

.tabs-scroll-btn {
  display: flex;
  flex-shrink: 0;
  position: static;
  width: 56px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: white;
  color: var(--secondary);
  cursor: pointer;
  z-index: 20;
  transition: opacity 0.25s ease, background 0.2s ease;
}

.tabs-scroll-btn.tabs-scroll-left {
  border-right: 1px solid #f1f5f9;
}

.tabs-scroll-btn.tabs-scroll-right {
  border-left: 1px solid #f1f5f9;
}

/* OBE sub-tabs scroll layout */
.obe-nav-scroll {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
}

.obe-nav-scroll .tabs-scroll-btn {
  width: 40px;
  background: transparent;
  border: none;
}

.obe-nav-scroll .tabs-scroll-btn.obe-scroll-left {
  border-right: 1px solid #e2e8f0;
}

.obe-nav-scroll .tabs-scroll-btn.obe-scroll-right {
  border-left: 1px solid #e2e8f0;
}

.tabs-scroll-btn:active {
  background: #fff7f0;
}

.tabs-scroll-btn i {
  background: var(--secondary);
  color: white;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  box-shadow: 0 3px 10px rgba(242, 114, 0, 0.35);
  transition: transform 0.15s ease;
}

.tabs-scroll-btn:active i {
  transform: scale(0.88);
}

/* Content Area */
.facility-content-wrapper {
  position: relative;
  height: auto;
  overflow-y: visible;
  padding-right: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--secondary) transparent;
}

.facility-content-wrapper.enable-internal-scroll {
  overflow-y: visible;
  padding-right: 0;
  overscroll-behavior: auto;
}

.normal-detail-scroll .facilities-container {
  position: static;
  height: auto;
  min-height: unset;
}

.normal-detail-scroll .facility-content-wrapper,
.normal-detail-scroll .facility-content-wrapper.enable-internal-scroll {
  height: auto;
  overflow-y: visible;
  padding-right: 0;
  overscroll-behavior: auto;
}

.facility-content-wrapper::-webkit-scrollbar {
  width: 6px;
}

.facility-content-wrapper::-webkit-scrollbar-thumb {
  background-color: var(--secondary);
  border-radius: 10px;
}

.facility-panel {
  display: none;
  animation: fadeIn 0.5s ease-out;
  overflow-x: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

.facility-panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.facility-panel img {
  width: 100%;
  height: 450px;
  object-fit: cover;
  border-radius: 24px;
  margin-bottom: 2.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.facility-panel h2 {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 1.5rem;
  font-family: 'Outfit', sans-serif;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.facility-panel h2::after {
  content: '';
  height: 4px;
  width: 60px;
  background: var(--secondary);
  border-radius: 2px;
}

.facility-description {
  font-size: 1.1rem;
  line-height: 1.6;
  color: #475569;
  text-align: left;
}

.facility-features {
  margin-top: 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}

.feature-box {
  background: var(--bg-light);
  padding: 1.5rem;
  border-radius: 16px;
  border: 1px solid var(--border);
}

.feature-box h4 {
  color: var(--primary);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.feature-box p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Mobile Responsiveness */
@media (max-width: 992px) {
  .facilities-container {
    padding: 0 1rem;
    margin: 1rem auto 3rem;
  }

  .tabs-mobile-wrapper {
    margin-bottom: 1.5rem;
  }

  .facilities-tabs {
    padding: 0.6rem;
    gap: 0.5rem;
  }

  .tab-btn {
    padding: 0.7rem 1.1rem;
    font-size: 0.9rem;
  }

  .tabs-mobile-wrapper > .tabs-scroll-btn {
    display: none !important;
  }

  /* Content panel on mobile */
  .facility-content-wrapper {
    height: auto;
    overflow-y: visible;
    padding-right: 0;
    /* Disable internal scroll on mobile */
  }

  .facility-content-wrapper.enable-internal-scroll {
    overflow-y: visible;
  }

  .facility-panel img {
    height: 240px;
  }

}

/* Advanced Blocks */
.block-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.stat-item {
  background: white;
  padding: 1.5rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  text-align: center;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.stat-item:hover {
  transform: translateY(-5px);
  border-color: var(--secondary);
  box-shadow: var(--shadow-md);
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--secondary);
  font-family: 'Outfit', sans-serif;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.block-table-wrapper {
  overflow-x: auto;
  margin: 2rem 0;
}

.block-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.block-table th {
  background: var(--bg-light);
  color: var(--primary);
  padding: 1rem;
  text-align: left;
  font-weight: 700;
  border-bottom: 2px solid var(--border);
}

.block-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.95rem;
}

.block-table tr:hover td {
  background: var(--bg-light);
}

.block-achievement {
  background: linear-gradient(135deg, var(--primary), #1e293b);
  color: white;
  padding: 1.5rem 2rem;
  border-radius: 16px;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  box-shadow: var(--shadow-md);
}

.achievement-year {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--secondary);
  padding-right: 2rem;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  min-width: 150px;
}

.achievement-year {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--secondary);
  padding-right: 2rem;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  min-width: 150px;
}

.achievement-content {
  flex: 1;
  font-size: 1.05rem;
  line-height: 1.6;
}

/* Mobile Responsiveness for Advanced Blocks */
@media (max-width: 768px) {
  .block-achievement {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .achievement-year {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
    padding-right: 0;
    width: 100%;
  }
}

/* Facilities/department detail pages must use the document as the only vertical scroller. */
body.normal-detail-scroll {
  overflow-y: auto;
}

body.normal-detail-scroll .facilities-hero {
  position: relative;
}

body.normal-detail-scroll .facilities-container {
  position: static !important;
  top: auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

body.normal-detail-scroll .facilities-tabs {
  position: sticky !important;
  top: 100px !important;
  height: auto !important;
  max-height: calc(100vh - 120px) !important;
  overflow-y: auto !important;
}

body.normal-detail-scroll .facility-content-wrapper,
body.normal-detail-scroll .facility-content-wrapper.enable-internal-scroll {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: visible !important;
  padding-right: 0 !important;
  overscroll-behavior: auto !important;
}

/* ==========================================================================
   Content Block Responsiveness (Mobile Fixes)
   ========================================================================== */
@media (max-width: 768px) {

  /* General Container Spacing */
  .block-paragraph,
  .block-list,
  .block-table-wrapper,
  .block-document-wrapper,
  .block-stats-grid {
    margin: 1.25rem 0 !important;
  }

  /* Table Fixes: Ensure scrollability and prevent squashing */
  .block-table-wrapper {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: 12px;
    margin: 1.5rem 0 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  }

  .block-table {
    min-width: 850px !important;
    /* Force width to trigger scroll */
    width: 100% !important;
    table-layout: auto !important;
  }

  .block-table th,
  .block-table td {
    padding: 1rem !important;
    font-size: 0.9rem !important;
    line-height: 1.5 !important;
    white-space: normal !important;
  }

  .block-table th,
  .block-table td:nth-child(1),
  .block-table td:nth-child(3) {
    white-space: nowrap !important;
    /* Keep No and Date on one line, allow Industry to wrap */
  }

  /* Support for tables nested inside paragraph/rich_table blocks (Summernote) */
  .block-paragraph table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    margin-bottom: 1.5rem !important;
    border-collapse: collapse !important;
    background: white !important;
  }

  .block-paragraph table th {
    background: var(--primary) !important;
    padding: 1rem 1.25rem !important;
    text-align: left !important;
    color: white !important;
    font-weight: 700 !important;
    border-bottom: 3px solid var(--secondary) !important;
    border-right: 1px solid rgba(255,255,255,0.1) !important;
  }

  .block-paragraph table td {
    padding: 1rem 1.25rem !important;
    border-bottom: 1px solid var(--border) !important;
    border-right: 1px solid var(--border) !important;
    color: #475569 !important;
    font-size: 0.95rem !important;
    min-width: 150px;
  }

  /* List Fixes: Switch to single column and fix spacing */
  .block-list {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .block-list li {
    padding: 1rem 1.25rem 1rem 2.8rem !important;
    font-size: 0.95rem !important;
  }

  .block-list li::before {
    left: 1rem !important;
    top: 1.1rem !important;
  }

  /* Standard UL/OL inside Paragraphs - Aggressive Reset for Mobile */
  .block-paragraph ul,
  .block-paragraph ol {
    padding-left: 1.25rem !important;
    margin: 1rem 0 !important;
    list-style-position: outside !important;
    display: block !important;
  }

  .block-paragraph li {
    margin-bottom: 0.5rem !important;
    line-height: 1.5 !important;
    padding-left: 0.25rem !important;
    margin-left: 0 !important;
    text-indent: 0 !important;
    /* Fixes the 'huge gap' issue */
    word-break: break-word !important;
  }

  /* Document Link (Cards) on Mobile */
  .block-document-link {
    padding: 1rem !important;
    border-radius: 12px;
  }

  .block-document-link .doc-icon {
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
    margin-right: 1rem;
  }

  .block-document-link .doc-name {
    font-size: 0.95rem;
  }

  /* Stats Grid Fixes */
  .block-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem;
  }

  .stat-item {
    padding: 1.25rem 0.5rem;
  }

  .stat-value {
    font-size: 1.5rem !important;
  }
}

@media (max-width: 480px) {
  .block-stats-grid {
    grid-template-columns: 1fr !important;
  }

  .section-title {
    font-size: 1.75rem !important;
  }
}