/* Import Google Fonts for Thai & English typography */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Brand Colors (University of Phayao - Purple & Gold) */
    --up-purple: #581c87;        /* Primary Deep Purple */
    --up-purple-medium: #7e22ce; /* Medium Purple */
    --up-purple-light: #faf5ff;  /* Light Lavender for backgrounds */
    --up-purple-hover: #4c1d95;  /* Darker Purple */
    
    --up-gold: #d97706;          /* Muted Accent Gold */
    --up-gold-light: #fef3c7;    /* Light Gold for badges */
    --up-gold-hover: #b45309;    /* Darker Gold */
    
    /* Neutral Palette */
    --bg-primary: #f8fafc;       /* Slate 50 */
    --bg-secondary: #ffffff;
    --text-primary: #1e293b;     /* Slate 800 */
    --text-secondary: #64748b;   /* Slate 500 */
    --border-color: #e2e8f0;     /* Slate 200 */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.02);
    --shadow-lg: 0 10px 15px -3px rgba(88, 28, 135, 0.08), 0 4px 6px -2px rgba(88, 28, 135, 0.03);
    
    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Layout Sizes */
    --max-width: 1280px;
    --border-radius: 12px;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-radius;
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .font-heading {
    font-family: 'Kanit', sans-serif;
    font-weight: 500;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition-smooth);
}

/* Header & Navigation */
.site-header {
    background-color: var(--bg-secondary);
    border-bottom: 2px solid var(--up-purple);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-top {
    background-color: var(--up-purple-hover);
    color: var(--bg-secondary);
    padding: 8px 0;
    font-size: 0.85rem;
}

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

.header-top-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-top-links a {
    margin-left: 20px;
    opacity: 0.85;
}

.header-top-links a:hover {
    opacity: 1;
    color: var(--up-gold);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-img {
    height: 55px;
    width: auto;
}

.logo-text h1 {
    font-size: 1.3rem;
    color: var(--up-purple);
    line-height: 1.2;
}

.logo-text p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 25px;
}

.nav-item a {
    font-family: 'Kanit', sans-serif;
    font-size: 1.05rem;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
}

.nav-item a:hover, .nav-item.active a {
    color: var(--up-purple);
    background-color: var(--up-purple-light);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-admin {
    background-color: var(--up-purple);
    color: var(--bg-secondary) !important;
    font-family: 'Kanit', sans-serif;
    padding: 8px 20px !important;
    border-radius: 20px !important;
    border: 1px solid var(--up-purple);
}

.btn-admin:hover {
    background-color: var(--bg-secondary) !important;
    color: var(--up-purple) !important;
}

/* Breaking News Ticker */
.ticker-wrap {
    background: var(--up-purple-light);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    overflow: hidden;
    height: 40px;
}

.ticker-title {
    background: var(--up-gold);
    color: white;
    font-family: 'Kanit', sans-serif;
    font-weight: 500;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    white-space: nowrap;
    z-index: 2;
    box-shadow: 3px 0 6px rgba(0,0,0,0.1);
    font-size: 0.9rem;
}

.ticker {
    display: flex;
    white-space: nowrap;
    animation: ticker 30s linear infinite;
    padding-left: 20px;
}

.ticker-item {
    display: inline-block;
    padding: 0 30px;
    font-size: 0.9rem;
    color: var(--up-purple-hover);
}

.ticker-item::after {
    content: "•";
    margin-left: 30px;
    color: var(--up-gold);
}

@keyframes ticker {
    0% { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-100%, 0, 0); }
}

/* Main Layout */
.main-content {
    padding: 40px 0;
}

/* Hero Section (Thairath Style Grid) */
.hero-section {
    margin-bottom: 40px;
}

.hero-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.hero-card {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    height: 480px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
}

.hero-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
}

.hero-card:hover .hero-card-img {
    transform: scale(1.05);
}

.hero-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, rgba(0,0,0,0) 100%);
    padding: 30px;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 60%;
}

.hero-right-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.hero-sub-card {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    height: 230px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
}

.hero-sub-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
}

.hero-sub-card:hover .hero-sub-card-img {
    transform: scale(1.05);
}

.hero-sub-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.3) 70%, rgba(0,0,0,0) 100%);
    padding: 15px;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 70%;
}

.badge {
    align-self: flex-start;
    background-color: var(--up-gold);
    color: white;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'Kanit', sans-serif;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.badge.research { background-color: var(--up-purple-medium); }
.badge.academic { background-color: #0d9488; }
.badge.student { background-color: #2563eb; }
.badge.announcement { background-color: #e11d48; }

.hero-title {
    font-size: 1.6rem;
    line-height: 1.3;
    margin-bottom: 10px;
    font-weight: 500;
}

.hero-sub-title {
    font-size: 1.1rem;
    line-height: 1.3;
    margin-bottom: 8px;
    font-weight: 500;
}

.meta-info {
    display: flex;
    gap: 15px;
    font-size: 0.8rem;
    opacity: 0.8;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Category Tabs and Filters */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background-color: var(--bg-secondary);
    padding: 10px 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--up-purple);
}

.tabs-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
}

.tab-btn {
    background: none;
    border: none;
    padding: 8px 18px;
    font-family: 'Kanit', sans-serif;
    font-size: 0.95rem;
    color: var(--text-secondary);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.tab-btn:hover, .tab-btn.active {
    background-color: var(--up-purple);
    color: white;
}

.search-box {
    position: relative;
    width: 280px;
}

.search-input {
    width: 100%;
    padding: 8px 15px 8px 35px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    font-family: 'Sarabun', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-smooth);
}

.search-input:focus {
    border-color: var(--up-purple);
    box-shadow: 0 0 0 3px rgba(88, 28, 135, 0.15);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* Three Column Content Grid */
.content-layout {
    display: grid;
    grid-template-columns: 2.3fr 1fr;
    gap: 30px;
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
}

.news-card {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.news-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(88, 28, 135, 0.15);
}

.news-card-img-wrap {
    height: 200px;
    overflow: hidden;
    position: relative;
}

.news-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
}

.news-card:hover .news-card-img {
    transform: scale(1.05);
}

.news-card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.news-card-title {
    font-size: 1.15rem;
    color: var(--text-primary);
    margin-bottom: 10px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 3.2em;
}

.news-card-summary {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
    height: 4.8em;
}

.news-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: auto;
}

/* Sidebar Widgets */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.widget {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.widget-title {
    font-size: 1.2rem;
    color: var(--up-purple);
    border-bottom: 2px solid var(--up-purple);
    padding-bottom: 10px;
    margin-bottom: 20px;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.widget-title::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background-color: var(--up-gold);
}

/* Calendar Widget */
.event-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.event-item {
    display: flex;
    gap: 15px;
    align-items: center;
}

.event-date {
    background-color: var(--up-purple-light);
    color: var(--up-purple);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 8px;
    border: 1px solid rgba(88, 28, 135, 0.1);
    flex-shrink: 0;
}

.event-day {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    line-height: 1;
}

.event-month {
    font-size: 0.7rem;
    font-weight: 500;
}

.event-details h4 {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}

.event-details p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Hot / Pinned Widget */
.hot-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.hot-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.hot-number {
    font-family: 'Inter', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--up-purple-light);
    background-color: var(--up-purple);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.hot-item:nth-child(1) .hot-number { background-color: #7e22ce; }
.hot-item:nth-child(2) .hot-number { background-color: #9333ea; }
.hot-item:nth-child(3) .hot-number { background-color: #a855f7; }

.hot-content h4 {
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.3;
    cursor: pointer;
}

.hot-content h4:hover {
    color: var(--up-purple);
}

/* Embed Box Showcase Widget */
.embed-showcase {
    background: linear-gradient(135deg, var(--up-purple) 0%, #3b0764 100%);
    color: white;
    border: none;
}

.embed-showcase .widget-title {
    color: white;
    border-bottom-color: rgba(255,255,255,0.2);
}

.embed-showcase .widget-title::after {
    background-color: var(--up-gold);
}

.embed-showcase p {
    font-size: 0.85rem;
    margin-bottom: 20px;
    opacity: 0.9;
}

.embed-code-box {
    background-color: rgba(0,0,0,0.3);
    padding: 12px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.75rem;
    word-break: break-all;
    border: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 15px;
    color: var(--up-gold-light);
}

.btn-copy {
    background-color: var(--up-gold);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    font-family: 'Kanit', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    width: 100%;
    text-align: center;
}

.btn-copy:hover {
    background-color: var(--up-gold-hover);
}

/* Footer */
.site-footer {
    background-color: #1e1b4b; /* Deep indigo/purple */
    color: #e2e8f0;
    padding: 60px 0 30px 0;
    border-top: 4px solid var(--up-gold);
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

.footer-brand h2 {
    color: white;
    font-size: 1.4rem;
    margin-bottom: 15px;
}

.footer-brand p {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-bottom: 20px;
    max-width: 400px;
}

.footer-links h3 {
    color: white;
    font-size: 1.1rem;
    margin-bottom: 20px;
    position: relative;
    padding-bottom: 8px;
}

.footer-links h3::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 2px;
    background-color: var(--up-gold);
}

.footer-links ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-links a {
    font-size: 0.9rem;
    color: #94a3b8;
}

.footer-links a:hover {
    color: var(--up-gold);
    padding-left: 5px;
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #64748b;
}

/* Reader Modal (Detailed view) */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-window {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.15);
    border: 1px solid var(--border-color);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-backdrop.active .modal-window {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: rgba(0,0,0,0.5);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition-smooth);
    z-index: 10;
}

.modal-close:hover {
    background-color: var(--up-purple);
}

.modal-img-wrap {
    width: 100%;
    height: 380px;
    position: relative;
}

.modal-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-body {
    padding: 35px;
}

.modal-header-info {
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.7rem;
    color: var(--text-primary);
    margin-bottom: 15px;
    line-height: 1.3;
}

.modal-text {
    font-size: 1.05rem;
    color: #334155;
    line-height: 1.7;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .content-layout {
        grid-template-columns: 1fr;
    }
    
    .hero-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .hero-card {
        height: 350px;
    }
    
    .hero-right-column {
        flex-direction: row;
    }
    
    .hero-sub-card {
        flex: 1;
        height: 200px;
    }
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }
    
    .hero-right-column {
        flex-direction: column;
    }
    
    .news-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-bar {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .search-box {
        width: 100%;
    }
    
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .modal-img-wrap {
        height: 220px;
    }
    
    .modal-body {
        padding: 20px;
    }
}

/* Load More Button Styles */
.load-more-container {
    display: flex;
    justify-content: center;
    margin-top: 35px;
    margin-bottom: 25px;
}
.btn-load-more {
    background-color: var(--up-purple);
    color: white;
    border: 2px solid var(--up-purple);
    padding: 10px 35px;
    border-radius: 25px;
    font-family: 'Kanit', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-sm);
    outline: none;
}
.btn-load-more:hover {
    background-color: transparent;
    color: var(--up-purple);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.btn-load-more:active {
    transform: translateY(0);
}
