@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600&family=Outfit:wght@400;500;700;800&display=swap');

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #06b6d4;
    --dark: #0f172a;
    --light: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --white: #ffffff;
    --nav-height: 80px;
    
    /* Glass Effect */
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --shadow-soft: 0 10px 30px -10px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Sarabun', sans-serif; }
body { background-color: var(--white); color: var(--dark); overflow-x: hidden; }

/* ================= NAVBAR ================= */
.navbar {
    position: fixed; top: 0; left: 0; width: 100%; height: var(--nav-height);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
}
.nav-container {
    width: 92%; max-width: 1280px;
    display: flex; align-items: center; justify-content: space-between;
}
.navbar.navbar-solid {
    background: var(--glass-bg);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: var(--glass-border); height: 70px;
    box-shadow: var(--shadow-soft);
}

/* Logo */
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; color: white; transition: 0.3s; }
.logo-icon { 
    width: 40px; height: 40px; background: linear-gradient(135deg, var(--primary), var(--accent)); 
    color: white; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.logo-text { display: flex; flex-direction: column; line-height: 1.1; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.logo-text span { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 1.1rem; }
.logo-text small { font-size: 0.85rem; opacity: 0.9; }

/* Navbar Solid Colors */
.navbar.navbar-solid .logo { color: var(--text-main); }
.navbar.navbar-solid .logo-text { text-shadow: none; }
.navbar.navbar-solid .nav-links a { color: var(--text-main); text-shadow: none; }
.navbar.navbar-solid .nav-links a:hover { color: var(--primary); }
.navbar.navbar-solid .mobile-menu-btn { color: var(--text-main); }

/* Menu Links */
.nav-links { display: flex; gap: 30px; align-items: center; margin-left: 40px; }
.nav-links a { text-decoration: none; color: rgba(255,255,255,0.9); font-weight: 500; font-size: 1rem; position: relative; padding: 8px 0; text-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: 0.3s; }
.nav-links a:hover { color: white; }

/* ================= SOCIAL ICONS & LOGIN ================= */
.nav-actions { display: flex; align-items: center; gap: 20px; }
.header-socials, .footer-socials { display: flex; align-items: center; gap: 12px; }

.social-icon-link {
    width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    text-decoration: none; color: white !important; font-size: 1.1rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); border: 2px solid rgba(255,255,255,0.2) !important;
}
.social-icon-link:hover { transform: translateY(-4px) scale(1.05); box-shadow: 0 8px 20px rgba(0,0,0,0.15); border-color: rgba(255,255,255,0.8) !important; }

/* Footer Socials */
.footer-socials .social-icon-link { width: 32px; height: 32px; font-size: 0.9rem; box-shadow: none; border-color: transparent !important; }

.btn-login {
    background: var(--dark); color: white; padding: 10px 24px; border-radius: 50px; 
    text-decoration: none; font-weight: 600; font-size: 0.9rem; transition: 0.3s; 
    display: flex; align-items: center; gap: 8px; border: 1px solid rgba(255,255,255,0.2);
}
.btn-login:hover { background: var(--primary); border-color: transparent; transform: translateY(-2px); }

/* ================= HERO SECTION ================= */
.hero {
    position: relative; height: 100vh; min-height: 600px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex; align-items: center; justify-content: center; text-align: center; color: white;
    padding-top: var(--nav-height);
}
.hero-overlay { position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, rgba(37, 99, 235, 0.2) 0%, rgba(15, 23, 42, 0.8) 100%); }
.hero-content { position: relative; z-index: 10; max-width: 800px; padding: 20px; animation: fadeInUp 0.8s; }
.badge-hero { display: inline-block; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.1); padding: 8px 20px; border-radius: 50px; font-size: 0.8rem; margin-bottom: 25px; font-family: 'Outfit'; letter-spacing: 2px; text-transform: uppercase; }
.hero h1 { font-family: 'Outfit'; font-size: 4rem; font-weight: 800; line-height: 1.1; margin-bottom: 20px; }
.hero h1 span { background: linear-gradient(to right, #60a5fa, #c084fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.btn-explore { display: inline-block; background: var(--primary); color: white; padding: 12px 35px; border-radius: 50px; text-decoration: none; font-weight: 600; transition: 0.3s; margin-top: 20px; box-shadow: 0 10px 20px rgba(37, 99, 235, 0.3); }
.btn-explore:hover { transform: translateY(-3px); background: var(--primary-dark); }

/* ================= COMMON LAYOUT ================= */
.container { max-width: 1200px; margin: 0 auto; padding: 80px 24px; }
.section-header { text-align: center; margin-bottom: 60px; }
.section-header h2 { font-family: 'Outfit'; font-size: 2.2rem; color: var(--text-main); margin-bottom: 10px; font-weight: 700; }
.section-header p { color: var(--text-muted); font-size: 1.1rem; }

/* ================= NEWS SECTION ================= */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 30px;
}


/* ================= MODERN NEWS CARD (App Style) ================= */

/* Grid Layout */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

/* Card Container */
.news-card {
    background: var(--white);
    border-radius: 24px; /* มุมโค้งมนมาก (App Standard) */
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.04); /* ขอบจางๆ */
    box-shadow: 0 10px 20px -5px rgba(0,0,0,0.06); /* เงานุ่ม */
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    isolation: isolate; /* แก้ปัญหา Border Radius ใน Safari */
}

/* Hover Effect: ลอยขึ้น + เงาชัด + ขอบสี */
.news-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 30px -10px rgba(37, 99, 235, 0.15); 
    border-color: rgba(37, 99, 235, 0.3);
}

/* Image Section */
.news-image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 60%; /* Aspect Ratio 5:3 */
    background-color: #f1f5f9;
    overflow: hidden;
}

.news-image {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.news-card:hover .news-image {
    transform: scale(1.08); /* ซูมภาพนุ่มๆ */
}

/* Badge (ป้ายหมวดหมู่ลอย) */
.news-category {
    position: absolute;
    top: 15px; left: 15px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px); /* เบลอฉากหลัง */
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 2;
}

/* Content Section */
.news-content {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* 🔥 Date & Time (Pill Style) */
.news-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.meta-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
}

.meta-pill i {
    color: var(--primary); /* ไอคอนสีฟ้า */
    font-size: 0.9rem;
}

/* Title */
.news-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
    line-height: 1.4;
    
    /* ตัดคำ 2 บรรทัด */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Description */
.news-desc {
    font-size: 0.95rem;
    color: #94a3b8;
    line-height: 1.6;
    margin-bottom: 20px;
    
    /* ตัดคำ 2 บรรทัด */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Footer (Read More) */
.news-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.read-more {
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: gap 0.2s;
}

.news-card:hover .read-more {
    gap: 10px; /* ลูกศรขยับเมื่อชี้ */
}


.news-card:hover { transform: translateY(-5px); box-shadow: 0 15px 30px rgba(0,0,0,0.1); border-color: #e2e8f0; }

.news-image { width: 100%; height: 220px; object-fit: cover; background-color: #f1f5f9; }
.news-content { padding: 24px; display: flex; flex-direction: column; flex-grow: 1; }
.news-date { font-family: 'Sarabun'; font-size: 0.9rem; color: var(--primary); font-weight: 600; margin-bottom: 12px; }
.news-title { font-family: 'Sarabun'; font-size: 1.25rem; font-weight: 700; color: #1e293b; margin-bottom: 12px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.news-desc { font-family: 'Sarabun'; font-size: 1rem; color: #64748b; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }


/* ================= 1. DEPARTMENTS SECTION (App Grid Style) ================= */
.dept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* เล็กกว่าข่าว เน้นจำนวน */
    gap: 20px;
}

.dept-card {
    background: var(--white);
    border-radius: 24px;
    padding: 30px 20px;
    text-align: center; /* จัดกึ่งกลาง */
    text-decoration: none;
    color: var(--text-main);
    border: 1px solid #f1f5f9;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Hover Effect: เด้งขึ้น + เงา */
.dept-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px -5px rgba(0,0,0,0.08);
    border-color: var(--primary);
}

/* Icon (วงกลมใหญ่) */
.dept-icon {
    width: 70px; height: 70px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: white;
    margin-bottom: 15px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    transition: transform 0.4s ease;
}

.dept-card:hover .dept-icon {
    transform: scale(1.1) rotate(-5deg);
}

/* Gradient Backgrounds for Icons */
.dept-icon.academic { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.dept-icon.register { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.dept-icon.activity { background: linear-gradient(135deg, #f59e0b, #d97706); }
.dept-icon.finance  { background: linear-gradient(135deg, #ec4899, #db2777); }

.dept-card h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem; font-weight: 700;
    margin-bottom: 5px;
}

.dept-card p {
    font-size: 0.85rem; color: var(--text-muted);
    line-height: 1.4;
}

/* ลูกศรซ่อนไว้ แล้วโผล่มาตอน Hover */
.dept-arrow {
    position: absolute; bottom: 15px;
    opacity: 0; transform: translateY(10px);
    transition: all 0.3s ease;
    color: var(--primary);
}
.dept-card:hover .dept-arrow {
    opacity: 1; transform: translateY(0);
}


/* ================= 2. KNOWLEDGE BASE SECTION (Resource List Style) ================= */
.kb-grid {
    display: flex;
    flex-direction: column; /* เรียงลงแนวตั้ง */
    gap: 15px;
}

/* Responsive: ถ้าจอใหญ่แบ่งเป็น 2 คอลัมน์ */
@media (min-width: 768px) {
    .kb-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

.kb-card {
    background: var(--white);
    border-radius: 16px; /* มนน้อยกว่า Dept */
    padding: 15px 20px;
    border: 1px solid #f1f5f9;
    display: flex;
    align-items: center; /* จัดให้อยู่แนวนอน */
    gap: 20px;
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.2s ease;
    position: relative;
}

.kb-card:hover {
    background: #f8fafc;
    border-color: #e2e8f0;
    transform: translateX(5px); /* ขยับไปทางขวา */
}

/* Icon (สี่เหลี่ยมมน) */
.kb-icon-box {
    width: 55px; height: 55px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.kb-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Badge (Pill Style) */
.kb-category-badge {
    font-size: 0.7rem; font-weight: 600;
    color: var(--text-muted); background: #f1f5f9;
    padding: 2px 8px; border-radius: 4px;
    align-self: flex-start; margin-bottom: 4px;
}

.kb-card h3 {
    font-family: 'Sarabun', sans-serif;
    font-size: 1.05rem; font-weight: 600;
    margin-bottom: 2px;
}

.kb-card p {
    font-size: 0.85rem; color: #94a3b8;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px;
}

.kb-action {
    color: #cbd5e1;
    font-size: 0.9rem;
}
.kb-card:hover .kb-action {
    color: var(--primary);
}


/* ================= MOBILE MENU & RESPONSIVE ================= */
.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.5rem; color: white; cursor: pointer; }
.mobile-menu-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); z-index: 2000; opacity: 0; visibility: hidden; transition: 0.3s; backdrop-filter: blur(4px); }
.mobile-menu-overlay.active { opacity: 1; visibility: visible; }
.mobile-menu-content { position: absolute; top: 0; right: -100%; width: 80%; max-width: 300px; height: 100%; background: white; padding: 30px; transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1); box-shadow: -10px 0 30px rgba(0,0,0,0.1); display: flex; flex-direction: column; }
.mobile-menu-overlay.active .mobile-menu-content { right: 0; }
.mobile-menu-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; border-bottom: 1px solid #f1f5f9; padding-bottom: 20px; }
.mobile-nav-links { display: flex; flex-direction: column; gap: 15px; }
.mobile-nav-links a { font-size: 1.1rem; color: var(--text-main); text-decoration: none; padding: 10px 0; border-bottom: 1px solid #f8fafc; }
.close-menu-btn { background: #f1f5f9; border: none; width: 35px; height: 35px; border-radius: 50%; cursor: pointer; }

@media (max-width: 960px) {
    .nav-links, .header-socials { display: none; }
    .mobile-menu-btn { display: block; }
    .hero h1 { font-size: 3rem; }
    .kb-grid { grid-template-columns: 1fr; } /* Mobile: KB Card เต็มจอ */
}

/* Footer */
footer { background: white; border-top: 1px solid #e2e8f0; padding: 40px 0; margin-top: auto; }
.footer-content { max-width: 1200px; margin: 0 auto; padding: 0 20px; display: flex; justify-content: space-between; align-items: center; }
@media (max-width: 600px) { .footer-content { flex-direction: column; gap: 20px; text-align: center; } }

/* Animations */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }


/* ... (CSS ส่วนอื่นๆ คงเดิม) ... */

/* ================= KNOWLEDGE BASE SECTION ================= */
.kb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.kb-card {
    background: white; border-radius: 20px; padding: 20px;
    border: 1px solid rgba(0,0,0,0.03); 
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
    display: flex; align-items: flex-start; gap: 15px; /* เปลี่ยนเป็น flex-start ให้ไอคอนอยู่บนเสมอ */
    text-decoration: none; color: var(--text-main);
    transition: all 0.3s ease; position: relative;
    height: 100%;
}

.kb-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.08);
    border-color: var(--primary);
}

.kb-icon-box {
    width: 50px; height: 50px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
}

.kb-content { flex: 1; display: flex; flex-direction: column; }

/* 🔥 สไตล์ป้ายหมวดหมู่ (ใหม่) */
.kb-category-badge {
    display: inline-block;
    font-size: 0.75rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-weight: 600;
    align-self: flex-start; /* ชิดซ้าย */
}

.kb-content h3 { font-family: 'Sarabun'; font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; line-height: 1.3; }
.kb-content p { font-size: 0.85rem; color: var(--text-muted); margin: 0; line-height: 1.5; }

.kb-action {
    color: #cbd5e1; transition: 0.2s; font-size: 0.9rem; align-self: center;
}
.kb-card:hover .kb-action { color: var(--primary); transform: translateX(3px); }

/* ... (CSS เดิม) ... */

/* Filter Scroll Container */
.filter-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 15px; /* เผื่อพื้นที่ Scrollbar */
    margin-bottom: 10px;
    scrollbar-width: none; /* Firefox */
}
.filter-scroll::-webkit-scrollbar { display: none; /* Chrome/Safari */ }

/* Filter Chip Button */
.filter-chip {
    white-space: nowrap;
    padding: 8px 18px;
    border-radius: 50px;
    border: 1px solid #e2e8f0;
    background: var(--white);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Sarabun', sans-serif;
}

.filter-chip:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.filter-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}