/* NTU CCMS Foreground Stylesheet — clean modern CSS faithful to legacy CCMS design */
:root {
  --bg: #f7f7f7;
  --surface: #ffffff;
  --text: #333333;
  --muted: #666666;
  --border: #dddddd;
  --border-light: #eeeeee;
  --accent: #0f4c81;
  --accent-hover: #0a365c;
  --pinned: #af2626;
  --max-width: 1170px;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font-family: "Merriweather Sans", "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", "Heiti TC", sans-serif;
  font-size: 15px;
  line-height: 1.65;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: #23527c;
  text-decoration: none;
}

a:hover, a:focus {
  color: #163753;
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

.site-wrapper {
  flex: 1 0 auto;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

/* --- Header & Navigation --- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid #e7e7e7;
  position: relative;
  z-index: 100;
}

.navbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  gap: 12px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  padding: 10px 0;
  flex-shrink: 0;
}

.brand-logo img {
  max-height: 54px;
  width: auto;
  display: block;
}

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid #cccccc;
  border-radius: 4px;
  padding: 8px 10px;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #555555;
  margin: 4px 0;
}

.nav-collapse {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  margin-left: 16px;
}

.nav-list, .nav-tools {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-item {
  position: relative;
}

.nav-link, .tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 10px 12px;
  color: #555555;
  font-size: 14px;
  background: transparent;
  border: 0;
  cursor: pointer;
  white-space: nowrap;
}

.nav-link:hover, .tool-btn:hover {
  color: #111111;
  text-decoration: none;
}

.nav-link.small-font {
  font-size: 13.5px;
}

.tool-btn img, .nav-tools a img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
}

.caret {
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 4px solid currentColor;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  list-style: none;
  margin: 0;
  padding: 6px 0;
  z-index: 200;
}

.dropdown-menu.align-right {
  left: auto;
  right: 0;
  min-width: 140px;
}

.nav-item.open > .dropdown-menu {
  display: block;
}

.dropdown-menu li a {
  display: block;
  padding: 8px 16px;
  color: #333333;
  font-size: 14px;
  white-space: nowrap;
}

.dropdown-menu li a:hover {
  background: #f3f4f6;
  text-decoration: none;
}

@media (min-width: 992px) {
  .nav-item:hover > .dropdown-menu {
    display: block;
  }
}

/* --- Section Banner Figure --- */
.banner-img {
  width: 100%;
  aspect-ratio: 32 / 5;
  overflow: hidden;
  background: #e5e7eb;
}

.banner-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* --- Homepage Carousel Slider --- */
.slider-section {
  background: var(--surface);
  border-bottom: 1px solid #e5e7eb;
  padding: 20px 0 28px;
}

.slider-wrapper {
  position: relative;
}

.slider-track {
  overflow: hidden;
}

.slide-card {
  display: none;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
  align-items: center;
}

.slide-card.active {
  display: grid;
}

.slide-text {
  border-top: 8px solid #333333;
  padding: 18px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.slide-text h2 {
  margin: 0 0 12px;
  font-size: 24px;
  line-height: 1.3;
}

.slide-text p {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
}

.slide-img img {
  width: 100%;
  max-height: 460px;
  object-fit: cover;
  display: block;
  border-radius: 2px;
}

.slider-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.85);
  border: 0;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  padding: 0;
}

.slider-nav-btn img {
  height: 28px;
  width: auto;
}

.slider-nav-btn.prev { left: -12px; }
.slider-nav-btn.next { right: -12px; }

.slider-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.slider-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 0;
  background: #cccccc;
  cursor: pointer;
  padding: 0;
}

.slider-dot.active {
  background: #333333;
}

/* --- Main Content & Breadcrumbs --- */
#main_body {
  padding-top: 22px;
  padding-bottom: 40px;
}

.breadcrumb {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 20px;
  padding: 8px 14px;
  background: #eeeeee;
  border-radius: 4px;
  font-size: 13.5px;
}

.breadcrumb li + li::before {
  content: "/";
  margin-right: 6px;
  color: #999999;
}

.flash-notice {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 18px;
}

/* --- Homepage Grid --- */
.homepage-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 32px;
}

.homepage-item {
  margin-bottom: 32px;
}

.homepage-item h2 {
  font-size: 22px;
  margin: 0 0 18px;
  padding-bottom: 6px;
  border-bottom: 2px solid #333333;
}

.homepage-block {
  margin-bottom: 18px;
}

.homepage-block h4 {
  font-size: 16px;
  line-height: 1.4;
  margin: 0 0 6px;
}

.homepage-block .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.homepage-block .subtitle::after,
#article-content::after {
  display: block;
  width: 40px;
  height: 1px;
  background-color: #dddddd;
  content: "";
  margin-top: 12px;
}

.more-link, .back-link {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}

/* --- Listing Tables (News / Awards / Jobs / Seminars) --- */
.item-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
}

.item-table tr {
  border-top: 1px solid #e5e7eb;
}

.item-table tr:first-child {
  border-top: 0;
}

.item-table td {
  padding: 14px 12px;
  vertical-align: top;
}

.item-table td.ind-col {
  width: 20px;
  padding-right: 4px;
}

.indicator {
  display: inline-block;
  width: 5px;
  height: 22px;
  border-radius: 1px;
  vertical-align: middle;
}

.dateline, .italic-date {
  font-style: italic;
  color: var(--muted);
  font-size: 13.5px;
  margin: 4px 0 0;
}

/* --- Article / Story Detail --- */
.story-card {
  max-width: 820px;
  margin: 0 auto;
  background: var(--surface);
  padding: 28px 32px;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
}

.story-card h1 {
  margin: 8px 0 18px;
  font-size: 26px;
  line-height: 1.35;
}

#article-content {
  overflow-x: auto;
  margin-bottom: 24px;
}

#article-content img {
  max-width: 100%;
  height: auto;
}

#article-content iframe {
  max-width: 100%;
}

/* --- Seminars Filters & Tabs --- */
.semester-list {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid #cccccc;
  border-radius: 4px;
  background: var(--surface);
  color: #333333;
  font-size: 13.5px;
  cursor: pointer;
}

.btn:hover {
  background: #f3f4f6;
  text-decoration: none;
}

.btn-active, .btn-disable {
  background: #333333;
  border-color: #333333;
  color: #ffffff;
}

.btn-active:hover, .btn-disable:hover {
  background: #333333;
  color: #ffffff;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #ffffff;
}

.category-tabs {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.category-tabs li a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  color: #444444;
  font-size: 14px;
}

.category-tabs li a.active,
.category-tabs li a:hover {
  background: var(--surface);
  border-color: var(--border);
  text-decoration: none;
}

.seminar-meta {
  text-align: right;
  font-style: italic;
  color: var(--muted);
  margin: 4px 0;
}

/* --- Research Fields & Groups --- */
.fields-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.fields-card {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  padding: 20px;
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid #e5e7eb;
  border-radius: 4px;
}

.fields-card h3 {
  margin-top: 0;
}

.lab-links a {
  display: block;
  margin-top: 6px;
}

/* --- Members Grid & Profile --- */
.members-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.member-card {
  display: flex;
  gap: 16px;
  align-items: center;
  background: var(--surface);
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
}

.member-card img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.member-information h2 {
  margin: 0 0 6px;
  font-size: 19px;
}

.member-information p {
  margin: 2px 0;
  color: var(--muted);
  font-size: 13.5px;
}

.member-profile {
  max-width: 920px;
  margin: 0 auto;
  background: var(--surface);
  padding: 28px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
}

.member-header {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}

.member-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.btn-member {
  display: block;
  text-align: center;
  padding: 12px;
  border: 1px solid #cccccc;
  background: #fafafa;
  color: #333333;
  font-weight: 600;
}

.btn-member:hover {
  background: #eeeeee;
  text-decoration: none;
}

.btn-member.invalid {
  color: #aaaaaa;
  background: #f9f9f9;
  cursor: default;
}

.well {
  background: #f5f5f5;
  border: 1px solid #e3e3e3;
  border-radius: 4px;
  padding: 16px;
  margin: 16px 0;
}

.member-lab-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid #eeeeee;
}

.member-entry-block {
  margin-top: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #eeeeee;
}

.member-entry-title {
  display: block;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

/* --- Regulations & General Affairs --- */
.regulation-card {
  background: var(--surface);
  padding: 16px 20px;
  margin-bottom: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
}

.regulation-card h3 {
  margin: 0 0 10px;
}

.affairs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.affair-card {
  background: var(--surface);
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 12px;
  text-align: center;
}

.affair-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 2px;
  margin-bottom: 8px;
}

/* --- Center Affairs & Auth --- */
.center-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-card {
  max-width: 440px;
  margin: 24px auto;
  background: var(--surface);
  padding: 28px 30px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cccccc;
  border-radius: 4px;
  font-size: 15px;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 12px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 14px;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 22px 0 0;
  justify-content: center;
}

.pagination a, .pagination span {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid #dddddd;
  background: var(--surface);
  border-radius: 4px;
  font-size: 14px;
}

.pagination .active span {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* --- Search Modal --- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 900;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  width: 100%;
  max-width: 760px;
  background: var(--surface);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.modal-header, .modal-footer {
  padding: 14px 20px;
  border-bottom: 1px solid #eeeeee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-footer {
  border-bottom: 0;
  border-top: 1px solid #eeeeee;
  justify-content: flex-end;
}

.modal-body {
  padding: 20px;
  min-height: 120px;
}

/* --- Footer --- */
#footer {
  flex-shrink: 0;
  background: #eeeeee;
  border-bottom: 5px solid #333333;
}

#footer-text {
  text-align: center;
  padding: 12px 16px;
  font-size: 13.5px;
  color: #444444;
}

/* --- Responsive --- */
@media (max-width: 991px) {
  .nav-toggle {
    display: block;
  }

  .navbar-inner {
    flex-wrap: wrap;
  }

  .nav-collapse {
    display: none;
    width: 100%;
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
    padding: 8px 0 14px;
    border-top: 1px solid #eeeeee;
  }

  .nav-collapse.open {
    display: flex;
  }

  .nav-list, .nav-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .dropdown-menu {
    position: static;
    box-shadow: none;
    border: 0;
    padding-left: 16px;
    background: #fafafa;
  }

  .homepage-grid,
  .members-grid,
  .fields-card,
  .member-header,
  .member-lab-row {
    grid-template-columns: 1fr;
  }

  .affairs-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .slide-card {
    grid-template-columns: 1fr;
  }

  .member-buttons {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  .story-card {
    padding: 18px;
  }
  .affairs-grid {
    grid-template-columns: 1fr;
  }
}
