@import url('https://fonts.googleapis.com/css2?family=Chenla&family=Kantumruy+Pro:ital,wght@0,100..700;1,100..700&family=Moul&family=Moulpali&family=Siemreap&display=swap');
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Khmer OS Battambang', 'MoolBoran', Arial, sans-serif;
}

body {
    background-image: url(/image/kbach-40.png);
    background-size: contain;
    background-size: 200px 200px;
    background-color: #003366;
    line-height: 1.6;
    overflow-x: hidden; /* ការពារការរមូរផ្ដេក */
    width: 100%;
}

/* Header Styles */
header, .site-header {
    background: linear-gradient(135deg, #3302c4, #001a33);
    color: white;
    padding: 15px 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    width: 100%;
}

.site-logo {
    min-width: 80px;
    min-height: 80px;
    border-radius: 50%;
    margin-bottom: 8px;
    border: 3px solid #2d02c9;
    object-fit: cover;
}

.site-title {
    font-family: "moul";
    font-size: 1.8rem;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* Navigation - Mobile First Approach */
nav ul, .nav-list {
    list-style: none;
    margin: 10px 0 0 0;
    padding: 0 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    font-family: "siemreap", sans-serif;
}

nav ul li, .nav-list li {
    margin: 0;
    flex: 0 1 auto;
}

nav ul li a, .nav-link {
    color: white;
    text-decoration: none;
    font-weight: bold;
    padding: 8px 16px;
    border-radius: 25px;
    transition: all 0.3s ease;
    display: inline-block;
    white-space: nowrap;
    background: rgba(243, 61, 1, 0.3);
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 0.95rem;
    font-family: "siemreap", sans-serif;
}

/* Main Container */
.container, .main-container {
    display: flex;
    max-width: 1200px;
    margin: 20px auto;
    gap: 20px;
    padding: 0 15px;
    width: 100%;
}

.news-feed {
    flex: 2.5;
    width: 100%;
}

.section-title {
    color: #ffffff;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid #f6f7f8;
    font-size: 1.6rem;
    position: relative;
    font-family: "moulpali", serif;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 60px;
    height: 3px;
    background: #f89704;
}

/* News Card */
.news-card {
    background: rgb(197, 197, 198,0.5);
    margin-bottom: 25px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
}

.card-image {
    width: 100%;
    height: 250px;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

/* Image Gallery */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr)​​ !important;;
    gap: 8px;
    padding: 12px;
    background: #f8f8f8;
}

.image-gallery img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Card Content */
.card-content {
    padding: 18px;
}

.card-title {
    color: #003366;
    margin-bottom: 10px;
    font-size: 1.3rem;
    line-height: 1.4;
    font-family: "siemreap", sans-serif;
    font-weight: bolder;
    text-decoration: underline;
}

.card-description {
    color: #555;
    margin-bottom: 15px;
    line-height: 1.6;
    font-size: 0.95rem;
    font-family: "siemreap", sans-serif;
}

/* Like Button */
.like-button {
    background: #f0f0f0;
    border: 1px solid #ddd;
    padding: 10px 20px;
    border-radius: 30px;
    color: #333;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    width: auto;
}

/* Sidebar */
.sidebar {
    flex: 1;
    background: white;
    padding: 18px;
    border-radius: 12px;
    height: fit-content;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    position: sticky;
    top: 20px;
    width: 100%;
}

.sidebar-widget {
    margin-bottom: 25px;
}

.sidebar-title {
    color: #3a01f5;
    margin-bottom: 15px;
    font-weight: bolder;
    padding-bottom: 8px;
    border-bottom: 2px solid #ff9900;
    font-size: 1.3rem;
    font-family: "siemreap", sans-serif;
}

.news-badge {
    background: #ff4444;
    color: white;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: bold;
    font-family: "siemreap", sans-serif;
    text-transform: uppercase;
}

.news-item, .popular-item {
    padding: 10px 0;
    border-bottom: 1px solid #070707;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    font-family: "siemreap", sans-serif;
}

.popular-link {
    text-decoration: none;
    color: #333;
    transition: color 0.3s ease;
    display: block;
    width: 100%;
    font-family: "siemreap", sans-serif;
}

.popular-link:hover {
    color: #ff9900;
    padding-left: 5px;
}


/* Footer */
footer, .site-footer {
    background: #001a33;
    color: white;
    text-align: center;
    padding: 25px 15px;
    margin-top: 30px;
    width: 100%;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    
}

.footer-content p {
    font-family: "siemreap", sans-serif;
}

.footer-contact {
    margin-top: 8px;
    color: #ccc;
    font-size: 0.85rem;
}

/* Overlay for mobile */
#overlay {
    position: fixed;
    display: none;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    justify-content: center;
    align-items: center;
    z-index: 9999;
    cursor: pointer;
}

#overlay img {
    max-width: 95%;
    max-height: 80%;
    border: 3px solid white;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

#overlay .close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    color: white;
    font-size: 35px;
    cursor: pointer;
    transition: transform 0.3s ease;
    z-index: 10000;
}

/* ========== RESPONSIVE FOR MOBILE ========== */

/* laptop */
@media (min-width: 992px) {
    .container, .main-container {
        max-width: 100%;
        gap: 20px;
        padding: 0 15px;
    }
    
    .card-image {
        min-height: 550px;
    }

    .image-gallery {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
        padding: 10px;
    }

    .image-gallery img {
        min-height: 300px;
    }
    
    .site-title {
        font-size: 1.6rem;
    }
    
    .site-logo {
        width: 70px;
        height: 70px;
    }
}

/* Tablet (768px - 992px) */
@media (max-width: 992px) {
    .container, .main-container {
        max-width: 100%;
        gap: 20px;
        padding: 0 15px;
    }
    
    .card-image {
        min-height: 300px;
    }
    
    .image-gallery {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
        padding: 10px;
    }

    .image-gallery img {
        min-height: 190px;
    }
    
    .site-title {
        font-size: 1.6rem;
    }
    
    .site-logo {
        width: 70px;
        height: 70px;
    }
}

/* Mobile Landscape (576px - 768px) */
@media (max-width: 768px) {
    .container, .main-container {
        flex-direction: column;
        margin: 15px auto;
        padding: 0 12px;
    }
    
    .site-title {
        font-size: 1.5rem;
    }
    
    .site-logo {
        width: 60px;
        height: 60px;
        border-width: 2px;
    }
    
    /* Navigation */
    nav ul, .nav-list {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }
    
    nav ul li, .nav-list li {
        flex: 0 1 auto;
    }
    
    nav ul li a, .nav-link {
        padding: 7px 14px;
        font-size: 0.9rem;
        white-space: nowrap;
    }
    
    /* Image Gallery */
    .image-gallery {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
        padding: 10px;
    }
    
    .image-gallery img {
        height: 90px;
    }
    
    .card-image {
        height: 200px;
    }
    
    .card-title {
        font-size: 1.2rem;
    }
    
    .section-title {
        font-size: 1.4rem;
        margin-bottom: 15px;
    }
    
    .sidebar {
        position: static;
        margin-top: 10px;
    }
    
    .like-button {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
    }
    
    #overlay .close-btn {
        top: 10px;
        right: 15px;
        font-size: 40px;
    }
}

/* Mobile Portrait (480px and below) */
@media (max-width: 480px) {
    header, .site-header {
        padding: 12px 8px;
    }
    
    .site-title {
        font-size: 1.3rem;
    }
    
    .site-logo {
        width: 50px;
        height: 50px;
        margin-bottom: 5px;
    }
    
    /* Navigation */
    nav ul, .nav-list {
        gap: 5px;
    }
    
    nav ul li a, .nav-link {
        padding: 6px 12px;
        font-size: 0.85rem;
        border-radius: 20px;
    }
    
    /* Gallery */
    .image-gallery {
        grid-template-columns: repeat(2,1fr) !important;
        gap: 8px;
    }
    
    .image-gallery img {
        height: 80px;
        border-radius: 4px;
    }
    
    .card-image {
        height: 150px;
    }
    
    .card-content {
        padding: 15px;
    }
    
    .card-title {
        font-size: 1.1rem;
    }
    
    .card-description {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    
    .section-title {
        font-size: 1.2rem;
    }
    
    .section-title::after {
        width: 50px;
    }
    
    .sidebar-title {
        font-size: 1.1rem;
    }
    
    .news-item, .popular-item {
        font-size: 0.9rem;
        padding: 8px 0;
    }
    
    .news-badge {
        padding: 2px 6px;
        font-size: 0.7rem;
    }
    
    .like-button {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .footer-content {
        font-size: 0.9rem;
    }
    
    .footer-contact {
        font-size: 0.8rem;
    }
    
    /* Overlay for mobile */
    #overlay img {
        max-width: 98%;
        max-height: 75%;
    }
    
    #overlay .close-btn {
        top: 10px;
        right: 15px;
        font-size: 35px;
    }
}

/* Small Mobile (360px and below) */
@media (max-width: 360px) {
    nav ul li a, .nav-link {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    /* Gallery - នៅតែ 3 ជួរឈរ */
    .image-gallery {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 4px;
        padding: 6px;
    }
    .image-gallery img {
        height: 60px;
    }
    
    .card-image {
        height: 150px;
    }
    
    .site-title {
        font-size: 1.2rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* បង្កើនទំហំប៊ូតុងសម្រាប់ទូរស័ព្ទ */
    nav ul li a, .nav-link,
    .like-button,
    .popular-link {
        min-height: 44px; /* Apple recommendation */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* លុប hover effects សម្រាប់ទូរស័ព្ទ */
    .news-card:hover,
    .image-gallery img:hover,
    .card-image img:hover,
    nav ul li a:hover,
    .like-button:hover {
        transform: none;
    }
    
    /* Active states instead */
    nav ul li a:active,
    .like-button:active {
        background: rgba(255,255,255,0.3);
        transform: scale(0.98);
    }
}

/* Fix for Khmer text wrapping */
.card-title, 
.card-description,
.news-item,
.popular-link {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Loading Animation */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.loading {
    animation: pulse 1.5s infinite;
}

/* Utility Classes */
.text-center { text-align: center; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.hidden { display: none; }
.w-100 { width: 100%; }