/* General Body & Reset */
body {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
    scroll-behavior: smooth;
}

/* Base elements styling */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    color: #2c3e50;
    margin-top: 1.5em;
    margin-bottom: 0.8em;
}

a {
    text-decoration: none;
    color: #007bff;
    transition: color 0.3s ease;
}

a:hover {
    color: #0056b3;
}

/* Header Section */
header {
    background: linear-gradient(to right, #6a11cb 0%, #2575fc 100%);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo img {
    max-width: 100%;
    height: auto;
    display: block;
    width: 250px; /* ขนาดเริ่มต้นสำหรับ desktop */
}

/* Media Query for smaller screens (header logo) */
@media (max-width: 768px) {
    .logo img {
        width: 100px; /* ลดขนาดโลโก้สำหรับจอมือถือ */
    }
    /* ไม่จำเป็นต้องมี header .logo { text-align: right; } ถ้าใช้ flexbox ใน header อยู่แล้ว */
}

nav a {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.8);
    margin: 0 20px;
    font-weight: 600;
    padding-bottom: 8px;
    position: relative;
    transition: color 0.3s ease;
}

nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 3px;
    background-color: #ffcc00;
    transition: width 0.3s ease;
}

nav a.active::after,
nav a:hover::after {
    width: 100%;
}

nav a.active {
    color: #fff;
}

.post-btn {
    background-color: #ffcc00;
    color: #2c3e50;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.post-btn:hover {
    transform: translateY(-3px);
    background-color: #e6b800;
}

/* Main Content Area */
main {
    padding: 30px 20px;
    max-width: 1200px;
    margin: 30px auto;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

/* Index Page Specific Styles */
.index-page h2 {
    text-align: center;
    color: #2575fc;
    margin-bottom: 40px;
    font-size: 2.2em;
    font-weight: 700;
}

.art-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    padding: 20px 0;
}

.art-item {
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.art-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.art-item a {
    display: block;
    color: inherit;
}

.art-item img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid #eee;
}

.art-item p {
    padding: 15px;
    margin: 0;
    font-weight: 600;
    color: #555;
    text-align: center;
    font-size: 1.1em;
    white-space: nowrap; /* ป้องกันไม่ให้ข้อความขึ้นบรรทัดใหม่ */
    overflow: hidden; /* ซ่อนข้อความที่เกิน */
    text-overflow: ellipsis; /* แสดง ... เมื่อข้อความถูกซ่อน */
    max-width: 100%; /* สำคัญสำหรับ text-overflow: ellipsis */
    display: block; /* หรือ inline-block */
}

.load-more {
    display: block;
    width: fit-content;
    margin: 40px auto 0;
    padding: 12px 25px;
    background-color: #2575fc;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 17px;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.load-more:hover {
    background-color: #1a5acb;
    transform: translateY(-2px);
}

/* Details Page Specific Styles */
/* ใช้ class .post-media และ .post-gallery เพื่อควบคุม responsive image */
.post-media img,
.post-media video {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.details-page h2 { /* ย้าย h2 จาก .index-page มาใช้ที่นี่ด้วยถ้าต้องการ */
    text-align: center;
    color: #2c3e50; /* สีเดียวกันกับ h1,h2,h3 ทั่วไป */
    margin-bottom: 20px; /* ลด margin-bottom */
    font-size: 2.2em;
    font-weight: 700;
}

.details-page h3 { /* สำหรับ "รูปภาพเพิ่มเติม" */
    color: #6a11cb;
    font-size: 1.8em; /* ปรับขนาดให้เหมาะสมกับ h2 */
    margin-top: 30px; /* เพิ่มระยะห่างด้านบน */
    margin-bottom: 15px;
    text-align: center;
}

.post-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 20px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.post-gallery img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    object-fit: cover;
    aspect-ratio: 1 / 1; /* ทำให้เป็นสี่เหลี่ยมจัตุรัส */
}

.post-content { /* เพิ่ม container สำหรับเนื้อหาโพสต์ใน details page */
    padding: 20px 0;
}

.post-description {
    line-height: 1.8;
    color: #555;
    text-align: justify;
    margin-top: 20px; /* เพิ่ม margin top */
    margin-bottom: 20px;
    font-size: 1.05em;
}

.author-info {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    font-size: 1.1em;
    margin-top: 20px; /* เพิ่ม margin top */
    border-top: 1px dashed #eee; /* เพิ่มเส้นแบ่ง */
    padding-top: 20px;
}

.avatar-placeholder { /* เปลี่ยนชื่อจาก .details-page .avatar ให้เป็นกลางมากขึ้น */
    width: 50px;
    height: 50px;
    background-color: #ddd;
    border-radius: 50%;
    margin-right: 15px;
    border: 3px solid #ffcc00;
    flex-shrink: 0;
}

/* Post Page Specific Styles */
.post-page h2 {
    text-align: center;
    color: #2575fc;
    margin-bottom: 40px;
    font-size: 2.2em;
    font-weight: 700;
}

.post-page .form-section {
    max-width: 700px;
    margin: 0 auto;
    padding: 30px;
    background-color: #fcfcfc;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.post-page .member-login-placeholder {
    background-color: #eef5ff;
    border: 1px dashed #a8d6ff;
    padding: 25px;
    text-align: center;
    margin-bottom: 30px;
    border-radius: 10px;
    color: #5d9cec;
    font-size: 1.1em;
    font-weight: 500;
}

.post-page .form-group {
    margin-bottom: 25px;
}

.post-page label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: #444;
    font-size: 1.1em;
}

.post-page input[type="text"],
.post-page textarea,
.post-page select { /* เพิ่ม select box ด้วย */
    width: calc(100% - 24px);
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.post-page input[type="text"]:focus,
.post-page textarea:focus,
.post-page select:focus {
    border-color: #2575fc;
    box-shadow: 0 0 0 3px rgba(37, 117, 252, 0.2);
    outline: none;
}

.post-page textarea {
    resize: vertical;
    min-height: 120px;
}

.post-page .drop-zone {
    border: 2px dashed #6a11cb;
    border-radius: 15px;
    padding: 50px;
    text-align: center;
    cursor: pointer;
    background-color: #f7faff;
    color: #6a11cb;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    font-size: 1.1em;
    font-weight: 500;
}

.post-page .drop-zone:hover,
.post-page .drop-zone.highlight {
    background-color: #eef5ff;
    border-color: #2575fc;
}

.post-page .browse-btn {
    color: #ffcc00;
    font-weight: bold;
    text-decoration: underline;
    cursor: pointer;
}

.post-page .image-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 25px;
    justify-content: center;
    border-top: 1px dashed #eee;
    padding-top: 20px;
}

.post-page .image-preview-item {
    position: relative;
    width: 110px;
    height: 110px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.post-page .image-preview-item:hover {
    transform: scale(1.05);
}

.post-page .image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.post-page .remove-preview {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    font-size: 16px;
    line-height: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease;
}

.post-page .remove-preview:hover {
    background-color: #cc0000;
}

.post-page .upload-btn {
    display: block;
    width: 100%;
    padding: 18px;
    background-color: #2575fc;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 40px;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.post-page .upload-btn:hover {
    background-color: #1a5acb;
    transform: translateY(-3px);
}

/* Footer Section */
footer {
    text-align: center;
    padding: 25px;
    margin-top: 50px;
    background-color: #2c3e50;
    color: #e0e0e0;
    font-size: 0.95em;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.2);
}

/* Responsive Adjustments */
/* @media (max-width: 992px) */
@media (max-width: 992px) {
    header {
        flex-direction: column;
        padding: 10px 15px;
    }
    nav {
        margin-top: 10px;
        margin-bottom: 15px;
        width: 100%;
        display: flex;
        justify-content: center;
        gap: 10px;
        flex-wrap: wrap; /* ให้เมนูขึ้นบรรทัดใหม่เมื่อจอเล็ก */
    }
    nav a {
        margin: 5px 10px; /* ลด margin สำหรับจอมือถือ */
        font-size: 0.9em;
    }
    .post-btn {
        margin-top: 10px;
    }
    main {
        padding: 20px 15px;
        margin: 20px auto;
    }
    .art-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 20px;
    }
    .art-item img {
        height: 200px;
    }
    
    /* details-page specific adjustments */
    .details-page .main-pic { /* ลบออกไปแล้ว ใช้ .post-media img แทน */
        max-width: 100%;
    }
    .details-page h2 {
        font-size: 2em;
    }
    .details-page h3 {
        font-size: 1.6em; /* ปรับลดลงเล็กน้อยสำหรับ responsive */
    }

    .post-page .form-section {
        padding: 20px;
    }
    .post-page label {
        font-size: 1em; /* ลดขนาดฟอนต์ label */
    }
    .post-page input[type="text"],
    .post-page textarea,
    .post-page select {
        padding: 10px; /* ลด padding input/textarea */
        font-size: 15px;
    }
}

/* @media (max-width: 768px) */
@media (max-width: 768px) {
    .logo img { /* ใช้ .logo img โดยตรงแทน .logo */
        width: 80px; /* ลดขนาดโลโก้ลงสำหรับมือถือ */
    }
    /* ไม่ต้องมี nav flex-wrap: wrap; ซ้ำ เพราะอยู่ใน 992px แล้ว */
    nav a {
        margin: 5px 8px; /* ปรับลด margin */
        padding: 6px 10px; /* ปรับ padding */
        font-size: 0.85em; /* ลดขนาดฟอนต์ */
    }
    .post-btn {
        width: 40px; /* ลดขนาดปุ่ม */
        height: 40px;
        font-size: 24px;
    }
    h2 {
        font-size: 1.8em; /* ลดขนาดหัวข้อ */
    }
    .art-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 คอลัมน์สำหรับมือถือ */
        gap: 15px;
    }
    .art-item img {
        height: 150px; /* บังคับความสูงรูปภาพให้เล็กลงเมื่อมี 2 คอลัมน์ */
    }
    .art-item p {
        font-size: 0.9em;
        padding: 10px;
        /* คุณสมบัติ text-overflow อยู่ที่ด้านบนแล้ว */
    }
    
    /* details-page specific adjustments */
    .post-description {
        font-size: 0.95em; /* ลดขนาดฟอนต์ */
    }
    .author-info {
        font-size: 1em; /* ลดขนาดฟอนต์ */
    }
    .post-gallery {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); /* ลดขนาดรูปใน gallery */
        gap: 8px;
    }
    
    /* post-page specific adjustments */
    .post-page .form-section {
        padding: 15px; /* ลด padding */
    }
    .post-page .drop-zone {
        padding: 25px; /* ลด padding */
        font-size: 0.9em;
    }
    .post-page .image-previews {
        gap: 8px;
    }
    .post-page .image-preview-item {
        width: 80px;
        height: 80px;
    }
    .post-page .remove-preview {
        width: 20px;
        height: 20px;
        font-size: 14px;
    }
    .post-page .upload-btn {
        padding: 12px;
        font-size: 16px;
    }

    footer {
        padding: 20px 15px; /* ลด padding */
        font-size: 0.85em;
    }
}

/* Optional: Google Fonts Import (add this to your HTML <head> or use @import in CSS) */
/*
If you want to use Google Fonts, add these lines to the <head> section of your HTML files:
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Montserrat:wght@500;700;800&display=swap" rel="stylesheet">
*/