/* ========================================================
   GLOBAL VARIABLES & BRAND DESIGN TOKENS (Mahidol Theme)
   ======================================================== */
:root {
  /* Brand Colors (โทนสีฟ้ากำลังดี ไม่สว่างหรือเข้มเกินไป) */
  --mu-blue: #008bcc;
  --mu-blue-dark: #006699;
  --mu-blue-mid: #007ab3;
  --mu-blue-light: #33aadd;
  --mu-blue-pale: #e6f7ff;
  --mu-gold: #C8A84B;
  --mu-gold-light: #e8ca70;
  --mu-gold-dark: #a08030;

  /* Neutrals */
  --white: #ffffff;
  --off-white: #f8f9fc;
  --gray-50: #f4f5f7;
  --gray-100: #e8eaed;
  --gray-200: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Typography */
  --font-thai: 'Sarabun', sans-serif;
  --font-en: 'Inter', sans-serif;
  --font-base: var(--font-thai);

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Utilities & Grid Setup */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(25, 68, 136, 0.1);
  --shadow-lg: 0 10px 40px rgba(25, 68, 136, 0.15);
  --shadow-xl: 0 20px 60px rgba(25, 68, 136, 0.2);
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;
  --container-max: 1180px;
  --navbar-height: 68px;
  --topbar-height: 40px;
}

/* ========================================================
   BASE RESETS
   ======================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-base); background-color: var(--off-white); color: var(--gray-700); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; transition: color var(--transition-fast); }
ul { list-style: none; }

.mn-wrapper {
  max-width: var(--container-max);
  margin: 0 auto;
  background: var(--white);
  box-shadow: var(--shadow-xl);
  min-height: 100vh;
  position: relative;
}

/* Container & Layout */
.content-area {
    max-width: 100%;
    margin: 0 auto;
    padding: 35px 25px;
    background: var(--white);
}

/* =========================================
   1. TOP BAR
   ========================================= */
.topbar { background: var(--mu-blue-dark); height: var(--topbar-height); display: flex; align-items: center; padding: 0 24px; gap: 16px; }
.topbar-links { display: flex; align-items: center; gap: 4px; flex: 1; }
.topbar-links a { color: var(--white); font-size: 13px; font-weight: 500; padding: 4px 8px; border-radius: var(--radius-sm); text-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.topbar-links a:hover { color: var(--mu-gold-light); }
.topbar-links .sep { color: rgba(255,255,255,0.5); font-size: 12px; margin: 0 4px; }
.topbar-social { display: flex; align-items: center; gap: 8px; }
.topbar-social a { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--radius-full); background: rgba(255,255,255,0.1); }
.topbar-social a:hover { background: var(--mu-gold); transform: translateY(-1px); }
.topbar-social img { width: 16px; height: 16px; filter: brightness(0) invert(1); }
.topbar-lang a { display: flex; align-items: center; gap: 4px; color: rgba(255,255,255,0.75); font-size: 12px; padding: 3px 10px; border: 1px solid rgba(255,255,255,0.2); border-radius: var(--radius-full); }
.topbar-lang a:hover { background: var(--mu-gold); border-color: var(--mu-gold); color: white; }
.topbar-lang img { width: 20px; height: 14px; border-radius: 2px; }

/* =========================================
   2. SITE HEADER
   ========================================= */
.site-header {
  background: linear-gradient(135deg, var(--mu-blue-dark) 0%, var(--mu-blue) 60%, var(--mu-blue-light) 100%);
  padding: 24px; display: flex; align-items: center; gap: 20px; position: relative; overflow: hidden;
}
.site-header::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--mu-gold) 0%, var(--mu-gold-light) 50%, var(--mu-gold) 100%); }
.header-logo { flex-shrink: 0; height: 75px; display: flex; align-items: center; }
.header-logo img { width: auto; height: 100%; max-width: 250px; object-fit: contain; }
.header-text { flex: 1; }
.header-dept-name { font-size: clamp(18px, 2.5vw, 26px); font-weight: 600; color: var(--white); line-height: 1.3; text-shadow: 0 1px 4px rgba(0,0,0,0.4); }
.header-faculty-name { font-size: clamp(13px, 1.8vw, 16px); color: rgba(255,255,255,0.75); margin-top: 4px; }
.header-univ-name { font-size: clamp(12px, 1.5vw, 14px); color: var(--mu-gold-light); margin-top: 4px; font-weight: 500; letter-spacing: 0.5px; }

/* =========================================
   3. NAVIGATION BAR (DESKTOP)
   ========================================= */
.navbar { background: var(--mu-blue); position: sticky; top: 0; z-index: 1000; box-shadow: 0 4px 20px rgba(25, 68, 136, 0.3); }
.navbar-inner { display: flex; align-items: center; justify-content: space-between; height: var(--navbar-height); padding: 0 var(--space-4); }
.navbar-brand { color: var(--white); font-size: 16px; font-weight: 400; line-height: 1.2; margin-right: 20px; }
.nav-menu { display: flex; align-items: center; height: 100%; }
.nav-item { position: relative; height: 100%; display: flex; align-items: center; }
.nav-link { display: flex; align-items: center; gap: 5px; padding: 0 11px; height: 100%; color: var(--white); font-size: 15px; font-weight: 600; white-space: nowrap; transition: all var(--transition-fast); cursor: pointer; border: none; background: none; text-shadow: 0 1px 4px rgba(0,0,0,0.3); }
.nav-link::after { content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 0; height: 3px; background: var(--mu-gold); border-radius: var(--radius-full) var(--radius-full) 0 0; transition: width var(--transition-base); }
.nav-link:hover, .nav-link.active { background: rgba(255, 255, 255, 0.1); }
.nav-link:hover::after, .nav-link.active::after { width: 60%; }
.nav-arrow { font-size: 10px; opacity: 0.7; transition: transform var(--transition-fast); }
.nav-item:hover .nav-arrow { transform: rotate(180deg); }

/* Dropdown เมนูย่อย */
.dropdown { position: absolute; top: calc(100% + 4px); left: 0; min-width: 240px; background: var(--white); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); overflow: hidden; opacity: 0; visibility: hidden; transform: translateY(-8px); transition: all var(--transition-base); border: 1px solid var(--gray-100); z-index: 1100; }
.nav-item:hover .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item { display: block; padding: var(--space-3) var(--space-5); color: var(--gray-700); font-size: 14.5px; border-bottom: 1px solid var(--gray-50); transition: all var(--transition-fast); position: relative; }
.dropdown-item::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--mu-blue); transition: width var(--transition-fast); }
.dropdown-item:hover { background: var(--mu-blue-pale); color: var(--mu-blue); padding-left: calc(var(--space-5) + 8px); }
.dropdown-item:hover::before { width: 4px; }
.dropdown-item:last-child { border-bottom: none; }

/* Hamburger ปุ่มเมนูมือถือ */
.hamburger { display: none; flex-direction: column; gap: 5px; cursor: pointer; padding: var(--space-2); border-radius: var(--radius-sm); border: none; background: none; }
.hamburger span { display: block; width: 24px; height: 2px; background: white; transition: all var(--transition-base); }
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile Menu Panel */
.mobile-menu { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 2000; background: rgba(0,0,0,0); backdrop-filter: blur(0px); transition: all var(--transition-slow); pointer-events: none; }
.mobile-menu.open { display: block; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); pointer-events: all; }
.mobile-nav-panel { position: fixed; top: 0; right: -100%; width: min(320px, 85vw); height: 100%; background: var(--mu-blue-dark); overflow-y: auto; transition: right var(--transition-slow) cubic-bezier(0.25, 0.46, 0.45, 0.94); display: flex; flex-direction: column; }
.mobile-menu.open .mobile-nav-panel { right: 0; }
.mobile-nav-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-5) var(--space-5); border-bottom: 1px solid rgba(255,255,255,0.1); background: var(--mu-blue); }
.mobile-nav-title { color: white; font-size: 15px; font-weight: 600; }
.mobile-close { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-full); border: none; background: rgba(255,255,255,0.1); color: white; font-size: 20px; cursor: pointer; }
.mobile-nav-list { padding: var(--space-4) 0; flex: 1; }
.mobile-nav-item { border-bottom: 1px solid rgba(255,255,255,0.06); }
.mobile-nav-link { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); color: var(--white); font-size: 15px; font-weight: 500; cursor: pointer; }
.mobile-dropdown { display: none; background: rgba(0,0,0,0.2); }
.mobile-dropdown.open { display: block; }
.mobile-dropdown a { display: block; padding: var(--space-3) var(--space-5) var(--space-3) calc(var(--space-5) + 16px); color: rgba(255,255,255,0.9); font-size: 14px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.mobile-dropdown a::before { content: '– '; opacity: 0.5; }

/* =========================================
   4. HERO SLIDESHOW SECTION
   ========================================= */
.hero-slider {
    position: relative;
    width: 100%;
    height: 400px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin-bottom: 45px;
}
.slides-wrapper { position: relative; width: 100%; height: 100%; }
.slide { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 1.8s ease-in-out; z-index: 1; overflow: hidden; }
.slide.active { opacity: 1; z-index: 2; }
.slide img { width: 100%; height: 100%; object-fit: cover; transform: scale(1); transition: transform 8s ease-out; }
.slide.active img { transform: scale(1.06); }

/* Slideshow Indicator Dots */
.slider-dots { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 10; display: flex; gap: 8px; }
.dot { width: 12px; height: 12px; background: rgba(255,255,255,0.4); border-radius: 50%; cursor: pointer; transition: all 0.3s ease; }
.dot.active { background: var(--mu-gold); transform: scale(1.2); box-shadow: 0 0 5px rgba(0,0,0,0.3); }

/* ==========================================================================
   5. MODERN 4-COLUMN HORIZONTAL NEWS GRID & INLINE HEADER
   ========================================================================== */

/* หัวข้อและปุ่มดูทั้งหมดอยู่บรรทัดเดียวกัน */
.news-header-inline {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--gray-100);
    padding-bottom: 15px;
}

.header-title h2 {
    font-size: 26px;
    color: var(--mu-blue-dark);
    font-weight: 600;
    position: relative;
    margin: 0;
}

/* เส้นขีดสีทองใต้หัวข้อ */
.header-title h2::after {
    content: '';
    position: absolute;
    bottom: -17px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--mu-gold);
    border-radius: 2px;
}

/* ลิงก์ "ดูทั้งหมด" ฝั่งขวา */
.view-all-link {
    font-size: 15px;
    font-weight: 600;
    color: var(--mu-blue);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    padding-bottom: 5px;
}

.view-all-link:hover {
    color: var(--mu-gold-dark);
}

.view-all-link .arrow {
    font-size: 1.2em;
    transition: transform 0.3s ease;
}

.view-all-link:hover .arrow {
    transform: translateX(5px);
}

/* จัดกล่องข่าวสารเรียงหน้ากระดาน 4 คอลัมน์แนวนอน */
.modern-news-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); 
    gap: 24px;
}
@keyframes fadeUpEffect {
    0% { opacity: 0; transform: translateY(40px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Apply animation to all inner pages automatically */
.content-area > *:not(.hero-slider):not(.news-section) {
    animation: fadeUpEffect 1.2s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.content-area > *:not(.hero-slider):not(.news-section):nth-child(1) { animation-delay: 0.1s; }
.content-area > *:not(.hero-slider):not(.news-section):nth-child(2) { animation-delay: 0.25s; }
.content-area > *:not(.hero-slider):not(.news-section):nth-child(3) { animation-delay: 0.4s; }
.content-area > *:not(.hero-slider):not(.news-section):nth-child(4) { animation-delay: 0.55s; }
.content-area > *:not(.hero-slider):not(.news-section):nth-child(5) { animation-delay: 0.7s; }

.news-item {
    display: flex;
    flex-direction: column;
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    animation: fadeUpEffect 1.2s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.news-item:nth-child(1) { animation-delay: 0.2s; }
.news-item:nth-child(2) { animation-delay: 0.4s; }
.news-item:nth-child(3) { animation-delay: 0.6s; }
.news-item:nth-child(4) { animation-delay: 0.8s; }
.news-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--mu-blue-pale);
}
.news-img-link {
    width: 100%;
    aspect-ratio: 16 / 11;
    overflow: hidden;
    display: block;
}
.news-img-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}
.news-item:hover .news-img-link img {
    transform: scale(1.06);
}
.news-text {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
}
.news-date {
    font-size: 13px;
    color: var(--mu-gold-dark);
    font-weight: 500;
}
.news-title {
    font-size: 14.5px;
    color: var(--gray-800);
    line-height: 1.5;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color var(--transition-fast);
}
.news-title:hover {
    color: var(--mu-blue);
}

/* =========================================
   6. SITE FOOTER
   ========================================= */
.site-footer { background: linear-gradient(135deg, var(--mu-blue-dark) 0%, var(--mu-blue) 100%); padding: 40px 24px; position: relative; overflow: hidden; }
.site-footer::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--mu-gold), var(--mu-gold-light), var(--mu-gold)); }
.footer-inner { max-width: var(--container-max); margin: 0 auto; display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: start; }
.footer-info h3 { font-size: 16px; font-weight: 700; color: white; margin-bottom: 8px; }
.footer-info p { font-size: 13px; color: rgba(255,255,255,0.6); line-height: 1.6; margin-bottom: 4px; }
.footer-info a { color: var(--mu-gold-light); }
.footer-info a:hover { color: var(--mu-gold); }
.footer-copy { font-size: 12px; color: rgba(255,255,255,0.4); margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.1); }


/* =========================================
   RESPONSIVE LAYOUT BREAKPOINTS
   ========================================= */
@media (max-width: 1024px) {
    .modern-news-grid {
        grid-template-columns: repeat(2, 1fr); /* หน้าจอขนาดกลาง/แท็บเล็ต แบ่ง 2 คอลัมน์ */
        gap: 20px;
    }
}

@media (max-width: 960px) {
  .nav-menu { display: none; }
  .hamburger { display: flex; }
  .navbar-brand { color: white; font-size: 16px; font-weight: 600; display: block; }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 768px) {
  .topbar { display: none; }
  .site-header { padding: 16px; flex-direction: column; text-align: center; gap: 12px; }
  .header-logo { width: 100%; height: 60px; justify-content: center; }
  .header-dept-name { font-size: 16px; }
  .header-faculty-name { font-size: 12px; }
  .content-area { padding: 20px 16px; }
  .hero-slider { height: 250px; }
}

@media (max-width: 540px) {
    .news-header-inline {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .header-title h2::after {
        width: 60px; /* ย่อเส้นสีทองให้สั้นลงบนจอมือถือ */
    }
    .modern-news-grid {
        grid-template-columns: 1fr; /* หน้าจอมือถือเล็ก ปรับเป็นแถวเดี่ยวแนวตั้งยาวลงไป */
    }
}
/* --- Legacy Content Beautification --- */
.legacy-content {
    font-size: 16.5px;
    color: var(--gray-700);
    line-height: 1.8;
}


.legacy-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}


.legacy-content ul, .legacy-content ol {
    margin-bottom: 25px;
    padding-left: 25px;
}
.legacy-content li {
    margin-bottom: 10px;
}
.legacy-content .txt_blue, .legacy-content .txt_blue_reg {
    color: var(--mu-blue);
    font-weight: 600;
}
.legacy-content .txt_name_bold {
    font-size: 18px;
    font-weight: 600;
    color: var(--mu-blue-dark);
    display: block;
    margin-bottom: 8px;
}

.legacy-content p.bg_grey, .legacy-content p.bg_blue, 
.legacy-content span.bg_grey, .legacy-content span.bg_blue,
.legacy-content div.bg_grey, .legacy-content div.bg_blue {
    background: var(--mu-blue-pale);
    color: var(--mu-blue-dark);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    margin-top: 30px;
    margin-bottom: 15px;
    display: inline-block;
}
.legacy-content p.bg_blue, .legacy-content span.bg_blue, .legacy-content div.bg_blue {
    background: var(--mu-blue);
    color: var(--white);
}

.legacy-content table {
    width: 100% !important;
    border-collapse: collapse;
    margin-bottom: 30px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}
.legacy-content td {
    padding: 15px 20px;
    vertical-align: middle;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.legacy-content tr.bg_blue td, .legacy-content tr.bg_grey td {
    background: var(--mu-blue);
    color: var(--white);
    font-weight: 600;
    padding: 15px 20px;
    border-bottom: none;
}
.legacy-content tr.bg_grey td {
    background: var(--mu-blue-pale);
    color: var(--mu-blue-dark);
}
.legacy-content .txt_white {
    color: var(--white) !important;
}
/* --- Legacy Orange Buttons --- */
.legacy-content td[bgcolor="#EF6B0A"] {
    background: var(--mu-gold) !important;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.legacy-content td[bgcolor="#EF6B0A"]:hover {
    filter: brightness(0.95);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.legacy-content td[bgcolor="#EF6B0A"] span, 
.legacy-content td[bgcolor="#EF6B0A"] a {
    color: var(--white) !important;
    text-decoration: none !important;
    display: block;
    font-weight: 600;
}



