: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: 10rem 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: 8rem 1.5rem 4rem;
    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: white;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  margin-bottom: 2.5rem;
}

.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.8rem 1rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 0.8rem;
  top: unset;
  align-self: unset;
}

.facilities-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  white-space: nowrap;
  padding: 0.8rem 1.8rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.tab-btn:hover {
  background: var(--bg-light);
  color: var(--primary);
  border-color: var(--secondary);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.15);
}

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

.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.8;
  color: #475569;
  text-align: justify;
}

.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-scroll-btn {
    width: 46px;
  }

  .tabs-scroll-btn i {
    width: 30px;
    height: 30px;
  }

  /* 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;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.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-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;
}
