@import url('https://fonts.googleapis.com/css2?family=Kanit&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Kanit', sans-serif;
    min-height: 100vh;
}

.main-container {
    max-width: 1600px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
    position: relative;
}

.main-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, #2e7d32, #c0a040);
}

/* ==== Main Content Area ==== */
.content-area {
    padding: 40px;

    /* เพิ่ม flex column เพื่อจัด controls กับ stats-panel ตามรูป */
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #2e7d32, #c0a040);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}

.header p {
    color: #64748b;
    font-size: 1.1rem;
    font-weight: 400;
}

/* ==== Search and Controls ==== */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-container {
    flex: 1 1 auto;
    min-width: 250px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 16px 20px 16px 50px;
    border-radius: 50px;
    border: 2px solid rgba(46, 125, 50, 0.2);
    font-size: 1rem;
    font-family: 'Kanit', sans-serif;
    outline: none;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.search-input:focus {
    border-color: #2e7d32;
    box-shadow: 0 8px 30px rgba(46, 125, 50, 0.2);
    transform: translateY(-2px);
}


.view-controls {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    padding: 8px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.view-btn {
    background: transparent;
    border: none;
    padding: 12px 16px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 1.1rem;
    color: #64748b;
    transition: all 0.3s ease;
}

.view-btn:hover {
    background: rgba(46, 125, 50, 0.1);
    color: #2e7d32;
    transform: translateY(-2px);
}

.view-btn.active {
    background: linear-gradient(135deg, #2e7d32, #c0a040);
    color: white;
    box-shadow: 0 4px 15px rgba(46, 125, 50, 0.3);
}

/* ==== Statistics Panel ==== */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 0;
}

.stat-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(15px);
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #2e7d32, #c0a040);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 5px;
}

.stat-label {
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ==== News Grid ==== */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    transition: all 0.3s ease;
}

.news-grid.list-view {
    grid-template-columns: 1fr;
}

.news-grid.masonry-view {
    columns: 3;
    column-gap: 25px;
}

.news-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.4s ease;
    cursor: pointer;
    position: relative;
}

.news-card.hidden {
    display: none;
}

.news-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

.news-card.list-view {
    display: flex;
    align-items: center;
    gap: 20px;
}

.news-card.list-view .news-image {
    width: 200px;
    height: 150px;
    flex-shrink: 0;
}

.news-card.masonry-view {
    break-inside: avoid;
    margin-bottom: 25px;
}

.news-image {
    position: relative;
    height: 220px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.news-image .icon {
    font-size: 4rem;
    background: linear-gradient(135deg, #2e7d32, #c0a040);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: transform 0.4s ease;
}

.news-card:hover .news-image .icon {
    transform: scale(1.1) rotate(5deg);
}

.news-image {
  position: relative;
  width: 100%;
  height: 220px;
  overflow: hidden;
  border-radius: 20px 20px 0 0;
}

.news-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


.category-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(46, 125, 50, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.fav-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    padding: 10px;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    color: #64748b;
}

.fav-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 1);
}

.fav-btn.active {
    color: #c0a040;
    background: rgba(192, 160, 64, 0.1);
}

.news-content {
    padding: 25px;
}

.news-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: #1e293b;
    line-height: 1.4;
}

.news-excerpt {
    color: #64748b;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 15px;
}

.news-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 0.85rem;
    color: #94a3b8;
}

.news-author {
    display: flex;
    align-items: center;
    gap: 8px;
}

.news-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}
.sdg-link {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  line-height: 1;
  font-size: 0;
  text-indent: 0;
  color: initial;
}


.sdg-link img {
  max-width: 24px;
  height: auto;
  display: block;
  margin: 0;
  padding: 0;
  vertical-align: middle;
}

.sdg-count {
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: auto;
  color: #64748b;
}

.tag {
  background: transparent !important;
  padding: 0 !important;
  display: inline-block;
  border-radius: 0 !important;
}

.sdg-icons img {
  background: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.sdg-link {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

.sdg-link img {
  max-width: 28px;
  height: auto;
  display: inline-block;
}


.read-more {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #2e7d32;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.read-more:hover {
    color: #c0a040;
    transform: translateX(5px);
}

/* ==== Sidebar ==== */
.sidebar {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(15px);
    padding: 30px;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.sidebar-section {
    margin-bottom: 35px;
}

.sidebar-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(135deg, #2e7d32, #c0a040);
    border-radius: 2px;
}

.category-list, .sdg-list {
    list-style: none;
    padding-left: 0;
}

.category-link, .sdg-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 12px;
    text-decoration: none;
    color: #64748b;
    font-weight: 500;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.category-link:hover, .sdg-link:hover {
    background: rgba(46, 125, 50, 0.1);
    color: #2e7d32;
    transform: translateX(5px);
}

.category-link.active, .sdg-link.active {
    background: linear-gradient(135deg, #2e7d32, #c0a040);
    color: white;
    box-shadow: 0 4px 15px rgba(46, 125, 50, 0.3);
}

.category-count,
.sdg-count {
    color: #c0a040;
    background: transparent !important;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}
.pagination {
  text-align: center;
  margin: 20px 0;
  font-family: 'Kanit', sans-serif;
}

.pagination a {
  display: inline-block;
  padding: 6px 12px;
  margin: 0 4px;
  border-radius: 12px;
  text-decoration: none;
  color: #2e7d32;
  border: 1.5px solid #2e7d32;
  font-weight: 600;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.pagination a:hover {
  background-color: #2e7d32;
  color: #fff;
}

.pagination a.active {
  background-color: #2e7d32;
  color: #fff;
  cursor: default;
  pointer-events: none;
}


.pagination a.prev,
.pagination a.next {
  font-weight: 900;
  font-size: 1.1rem;
}



.active .category-count, .active .sdg-count {
    background: rgba(255, 255, 255, 0.2);
}

.sdg-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    margin-right: 10px;
    font-weight: 600;
}

/* ==== Loading & No Results ==== */
.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(46, 125, 50, 0.1);
    border-top: 4px solid #2e7d32;
    border-radius: 50%;
    margin: 40px auto;
    animation: spin 1s linear infinite;
    display: none;
}

.loading-spinner.show {
    display: block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    border: 2px dashed rgba(46, 125, 50, 0.3);
    display: none;
}

.no-results.show {
    display: block;
}

.no-results::before {
    content: '📰';
    font-size: 4rem;
    display: block;
    margin-bottom: 20px;
}

/* ==== Responsive ==== */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .sidebar {
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.3);
    }

    .news-grid.masonry-view {
        columns: 2;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .content-area {
        padding: 20px;
        gap: 15px;
    }

    .header h1 {
        font-size: 2.2rem;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .search-container {
        min-width: auto;
    }

    .stats-panel {
        grid-template-columns: repeat(2, 1fr);
    }

    .news-grid {
        grid-template-columns: 1fr;
    }

    .news-grid.masonry-view {
        columns: 1;
    }

    .news-card.list-view {
        flex-direction: column;
    }

    .news-card.list-view .news-image {
        width: 100%;
        height: 200px;
    }

    .sidebar {
        padding: 20px;
    }
}
/* Dark Mode */
body.dark-mode {
    background: #121212; /* เทาเข้ม */
    color: #e0e0e0;
}

body.dark-mode .main-container {
    background: rgba(18, 18, 18, 0.95);
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .main-container::before {
    background: linear-gradient(90deg, #2e7d32, #c0a040);
}

body.dark-mode .header h1 {
    background: linear-gradient(135deg, #2e7d32, #c0a040);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.dark-mode .header p,
body.dark-mode .stat-label,
body.dark-mode .news-excerpt,
body.dark-mode .news-meta,
body.dark-mode .sidebar-title,
body.dark-mode .category-link,
body.dark-mode .sdg-link {
    color: #b0b0b0;
}

body.dark-mode .stat-card,
body.dark-mode .news-card,
body.dark-mode .sidebar {
    background: #1e1e1e;
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .view-btn {
    color: #ccc;
}

body.dark-mode .view-btn:hover {
    background: rgba(192, 160, 64, 0.1);
    color: #c0a040;
}

body.dark-mode .view-btn.active {
    background: linear-gradient(135deg, #2e7d32, #c0a040);
    color: white;
}

body.dark-mode .stat-number,
body.dark-mode .news-image .icon {
    background: linear-gradient(135deg, #2e7d32, #c0a040);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.dark-mode .category-link.active,
body.dark-mode .sdg-link.active {
    background: linear-gradient(135deg, #2e7d32, #c0a040);
    color: white;
}

body.dark-mode .fav-btn {
    background: #2a2a2a;
    color: #ccc;
}

body.dark-mode .fav-btn.active {
    color: #c0a040;
    background: rgba(192, 160, 64, 0.1);
}

body.dark-mode .read-more {
    color: #c0a040;
}

body.dark-mode .read-more:hover {
    color: #ffffff;
}

body.dark-mode .loading-spinner {
    border-color: rgba(192, 160, 64, 0.1);
    border-top-color: #c0a040;
}

body.dark-mode .no-results {
    background: #1e1e1e;
    border-color: rgba(192, 160, 64, 0.3);
}

body.dark-mode .pagination a {
    color: #c0a040;
    border-color: #c0a040;
}

body.dark-mode .pagination a:hover,
body.dark-mode .pagination a.active {
    background-color: #c0a040;
    color: #121212;
}
