/* ========== สีหลักของระบบ ========== */
:root {
    --primary-color: #990099;
    --primary-dark: #660066;
    --primary-light: #cc00cc;
    --secondary-color: #6c757d;
    --light-bg: #f8f9fa;
    --dark-text: #333;
    --border-color: #dee2e6;
}

/* ========== Global Styles ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', 'Kanit', Arial, sans-serif;
    background-color: #f5f5f5;
    color: var(--dark-text);
    line-height: 1.6;
}

.container {
    max-width: 1400px; /* หน้าจอปกติ กว้าง 1400px */
}

@media (min-width: 1600px) {
    .container {
        max-width: 90%; /* หน้าจอใหญ่มาก ใช้ 90% */
    }
}

/* ========== Header Styles ========== */
.site-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 20px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-img {
    height: 70px;
    width: auto;
    border-radius: 8px;
    background: white;
    padding: 5px;
}

.site-title {
    margin: 0;
    font-size: 28px;
    font-weight: bold;
}

.site-subtitle {
    margin: 0;
    font-size: 16px;
    opacity: 0.9;
}

.admin-link {
    background: rgba(255,255,255,0.2);
    padding: 10px 20px;
    border-radius: 5px;
    color: white;
    text-decoration: none;
    transition: all 0.3s;
}

.admin-link:hover {
    background: rgba(255,255,255,0.3);
    color: white;
    transform: translateY(-2px);
}

/* ========== Banner Styles ========== */
.banner-section {
    margin: 30px 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.carousel-item img {
    width: 100%;
    height: 400px;
    object-fit: cover;
}

/* ========== Search Section ========== */
.search-section {
    background: white;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin: 7px 0;
}

.search-box {
    max-width: 600px;
    margin: 0 auto;
}

.search-input {
    border: 2px solid var(--primary-color);
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 16px;
}

.search-input:focus {
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 0.2rem rgba(153, 0, 153, 0.25);
}

.btn-search {
    background: var(--primary-color);
    border: none;
    border-radius: 25px;
    padding: 12px 30px;
    color: white;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-search:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* ========== Albums Grid ========== */
.albums-section {
    margin: 40px 0;
}

.albums-section .row {
    display: flex;
    justify-content: center; /* จัดให้อยู่กึ่งกลางเมื่อมีน้อยกว่า 3 อัลบั๊ม */
    flex-wrap: wrap;
}

.albums-section .col-lg-4 {
    flex: 0 0 320px; /* กำหนดความกว้างแน่นอน 320px */
    max-width: 320px;
    margin: 0 10px; /* เว้นระยะห่างซ้าย-ขวา */
}

.section-title {
    color: var(--primary-color);
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 30px;
    text-align: center;
    position: relative;
    padding-bottom: 15px;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 2px;
}

.album-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 15px rgba(0,0,0,0.1);
    transition: all 0.3s;
    margin-bottom: 30px;
    height: 100%;
}

.album-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 25px rgba(153, 0, 153, 0.3);
}

.album-cover {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
}

.album-body {
    padding: 20px;
}

.album-title {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.album-description {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.album-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #999;
    font-size: 13px;
    border-top: 1px solid #eee;
    padding-top: 15px;
    margin-top: 15px;
}

.album-meta i {
    margin-right: 5px;
    color: var(--primary-color);
}

.btn-view-album {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 5px;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s;
    font-weight: bold;
}

.btn-view-album:hover {
    background: var(--primary-dark);
    color: white;
    text-decoration: none;
}

/* ========== Media Gallery ========== */
.media-gallery {
    margin: 30px 0;
}

.view-options {
    text-align: right;
    margin-bottom: 20px;
}

.view-toggle {
    background: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 8px 15px;
    border-radius: 5px;
    margin-left: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.view-toggle.active,
.view-toggle:hover {
    background: var(--primary-color);
    color: white;
}

/* Grid View - แบบตาราง */
.grid-view {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

.grid-view .media-item {
    flex: 0 0 280px;
    max-width: 280px;
    margin: 0 10px 20px 10px;
}

/* List View - แบบรายการ */
.list-view {
    display: block;
}

.list-view .media-item {
    width: 100%;
    max-width: 900px;
    margin: 0 auto 20px auto;
}

.list-view .media-card {
    display: flex;
    flex-direction: row;
}

.list-view .media-thumbnail {
    width: 250px;
    height: 200px;
    object-fit: cover;
    flex-shrink: 0;
}

.list-view .media-info {
    flex: 1;
    padding: 20px;
    display: flex;
    align-items: center;
}

/* Masonry View - แบบกำแพง */
.masonry-view {
    column-count: 6;
    column-gap: 15px;
}

.masonry-view .media-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 15px;
    break-inside: avoid;
}

.masonry-view .media-card {
    margin-bottom: 0;
}

.media-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s;
    height: 100%;
}

.media-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 20px rgba(153, 0, 153, 0.2);
}

.media-thumbnail {
    width: 100%;
    height: 200px;
    object-fit: cover;
    cursor: pointer;
}

.media-info {
    padding: 15px;
}

.media-caption {
    font-size: 14px;
    color: #666;
}

/* Responsive สำหรับมุมมอง */
@media (max-width: 1200px) {
    .masonry-view {
        column-count: 4; /* เพิ่มจาก 3 เป็น 4 */
    }
}

@media (max-width: 992px) {
    .masonry-view {
        column-count: 3; /* เพิ่มจาก 2 เป็น 3 */
    }
    
    .grid-view .media-item {
        flex: 0 0 45%;
        max-width: 45%;
    }
}

@media (max-width: 768px) {
    .masonry-view {
        column-count: 1;
    }
    
    .grid-view .media-item {
        flex: 0 0 100%;
        max-width: 100%;
        margin: 0 0 20px 0;
    }
    
    .list-view .media-card {
        flex-direction: column;
    }
    
    .list-view .media-thumbnail {
        width: 100%;
        height: 200px;
    }
}

/* ========== Footer Styles ========== */
.site-footer {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    color: white;
    padding: 40px 0 20px;
    margin-top: 50px;
}

.footer-stats {
    background: rgba(255,255,255,0.1);
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.stats-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
}

.stat-item {
    text-align: center;
    padding: 15px;
}

.stat-number {
    font-size: 32px;
    font-weight: bold;
    display: block;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 5px;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    .site-title {
        font-size: 20px;
    }
    
    .site-subtitle {
        font-size: 14px;
    }
    
    .carousel-item img {
        height: 250px;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .admin-link {
        margin-top: 15px;
    }
    
    /* เพิ่มส่วนนี้ */
    .albums-section .col-lg-4 {
        flex: 0 0 100%;
        max-width: 100%;
        margin: 0 0 20px 0;
    }
}

/* เพิ่ม Media Query สำหรับ Tablet */
@media (min-width: 769px) and (max-width: 991px) {
    .albums-section .col-lg-4 {
        flex: 0 0 45%;
        max-width: 45%;
    }
}

/* ========== Admin Styles ========== */
.admin-body {
    background: var(--light-bg);
    min-height: 100vh;
}

.admin-sidebar {
    background: white;
    min-height: 100vh;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
}

.sidebar-menu {
    list-style: none;
    padding: 20px 0;
}

.sidebar-menu li {
    margin: 5px 0;
}

.sidebar-menu a {
    display: block;
    padding: 15px 20px;
    color: var(--dark-text);
    text-decoration: none;
    transition: all 0.3s;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: var(--primary-color);
    color: white;
    padding-left: 30px;
}

.admin-content {
    padding: 30px;
}

.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.card-header {
    background: var(--primary-color);
    color: white;
    font-weight: bold;
    border-radius: 10px 10px 0 0 !important;
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* ========== Loading Animation ========== */
.loading {
    text-align: center;
    padding: 50px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== Alert Messages ========== */
.alert {
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

/* Profile Image */
.admin-sidebar img.rounded-circle {
    transition: all 0.3s ease;
}

.admin-sidebar img.rounded-circle:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(153, 0, 153, 0.5);
}

/* ให้โลโก้คลิกได้ */
.logo-section {
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.logo-section:hover {
    opacity: 0.9;
}

.logo-section:hover .logo-img {
    transform: scale(1.05);
    transition: transform 0.3s ease;
}

/* ========== Hamburger Menu (☰) ========== */

/* ซ่อนปุ่ม Hamburger ใน Desktop */
.hamburger-menu {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
    transition: all 0.3s ease;
}

.hamburger-menu span {
    width: 28px;
    height: 3px;
    background: white;
    border-radius: 3px;
    transition: all 0.3s ease;
}

/* แอนิเมชั่นเปลี่ยน ☰ เป็น ✕ */
.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* เมนู Navigation */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-item {
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 5px;
    background: rgba(255,255,255,0.2);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.3);
    color: white;
    transform: translateY(-2px);
    text-decoration: none;
}

/* Overlay สำหรับปิดเมนู */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.menu-overlay.active {
    display: block;
    opacity: 1;
}

/* ========== 📱 Responsive: iPad & Mobile ========== */

@media (max-width: 1024px) {
    /* แสดงปุ่ม Hamburger */
    .hamburger-menu {
        display: flex;
    }
    
    /* ซ่อนเมนูตอนแรก - เลื่อนออกไปทางขวา */
    .nav-menu {
        position: fixed;
        top: 0;
        right: -300px;
        width: 280px;
        height: 100vh;
        background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
        flex-direction: column;
        align-items: stretch;
        padding: 80px 20px 20px;
        gap: 10px;
        box-shadow: -5px 0 15px rgba(0,0,0,0.3);
        transition: right 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
        z-index: 1000;
        overflow-y: auto;
    }
    
    /* แสดงเมนูเมื่อกดปุ่ม - เลื่อนเข้ามา */
    .nav-menu.active {
        right: 0;
    }
    
    /* ปรับรูปแบบรายการเมนู */
    .nav-item {
        width: 100%;
        padding: 15px 20px;
        font-size: 16px;
        border-radius: 8px;
        justify-content: flex-start;
    }
    
    .nav-item i {
        font-size: 18px;
        width: 25px;
    }
    
    .nav-item:hover {
        transform: translateX(-5px);
        background: rgba(255,255,255,0.4);
    }
    
    /* ปรับ Header */
    .header-content {
        position: relative;
        justify-content: space-between;
    }
    
    .logo-section {
        flex: 1;
        max-width: calc(100% - 60px);
    }
}

/* 📱 สำหรับมือถือเล็ก (ต่ำกว่า 768px) */
@media (max-width: 768px) {
    .header-content {
        flex-direction: row;
        align-items: center;
    }
    
    .logo-section {
        flex-direction: row;
        gap: 10px;
    }
    
    .site-title {
        font-size: 18px;
        line-height: 1.2;
    }
    
    .site-subtitle {
        font-size: 13px;
        display: none; /* ซ่อนคำบรรยายในมือถือเล็ก */
    }
    
    .logo-img {
        height: 50px;
    }
    
    .nav-menu {
        width: 260px;
        right: -260px;
        padding: 70px 15px 20px;
    }
    
    .nav-item {
        padding: 12px 15px;
        font-size: 15px;
    }
    
    .hamburger-menu span {
        width: 25px;
        height: 2.5px;
    }
}

/* 📱 สำหรับมือถือจิ๋ว (ต่ำกว่า 375px) */
@media (max-width: 374px) {
    .site-title {
        font-size: 16px;
    }
    
    .logo-img {
        height: 45px;
    }
    
    .nav-menu {
        width: 240px;
        right: -240px;
    }
}