/* 1. Global Reset & Unified Layout */
* {
    box-sizing: border-box;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

/* UPDATED: Container width increased to match admin panel */
.container {
    max-width: 1250px !important;
    margin: 0 auto !important;
    padding: 0 20px;
}

/* 2. Header */
header {
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}
.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-size: 22px;
    font-weight: bold;
    text-decoration: none;
    color: #000;
}
nav a {
    margin-left: 20px;
    text-decoration: none;
    color: #666;
    font-size: 14px;
}

/* Search Form */
.search-form {
    display: flex;
    align-items: center;
}
.search-form select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23aaa' viewBox='0 0 16 16'%3E%3Cpath d='M7.002 11.001h1.996l3.683 2.698a1 1 0 0 0 1.405-1.405l-4.386-3.214a1 1 0 0 0-.595-.198V5.002a1 1 0 0 0-1.996 0v4.795a1 1 0 0 0 .595.198l4.386 3.214a1 1 0 0 0 1.405 1.405l-3.683-2.698H7.002a1 1 0 0 0 0 2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    width: 120px;
}
.search-form input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 220px;
    margin: 0 8px;
}
.search-form button {
    padding: 8px 16px;
    background: #505050;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}
.search-form button:hover {
    background: #333;
}

/* 3. Category Grid (Strict 4 Columns) */
.category-grid {
    display: grid !important;
    gap: 15px !important;
    grid-template-columns: repeat(4, 1fr) !important;
    margin-top: 20px;
}
@media (max-width: 768px) {
    .category-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
.cat-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    display: block;
    text-decoration: none;
}
.cat-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cat-info {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: #fff;
}
.cat-name {
    display: block;
    font-weight: bold;
    font-size: 14px;
}
.cat-count {
    font-size: 11px;
    opacity: 0.8;
}

/* 4. Wallpaper Grid (REVISED FOR 4-COLUMNS) */
.wallpaper-grid {
    display: grid !important;
    gap: 20px !important;
    grid-template-columns: repeat(4, 1fr) !important; /* Fixed 4 cols for web/tablet */
}
@media (max-width: 768px) {
    .wallpaper-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* Fixed 2 cols for mobile */
    }
}
.wp-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.wp-card img {
    width: 100%;
    display: block;
}
.wp-title {
    padding: 10px;
    text-align: center;
    font-size: 13px;
    color: #333;
}

/* 5. Item Detail Layout */
.item-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-top: 30px;
    justify-content: center;
}
.item-image-box {
    flex: 0 0 320px;
    max-width: 100%;
    text-align: center;
}
.item-info-box {
    flex: 1;
    min-width: 300px;
    max-width: 480px;
}
.img-wrapper {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    line-height: 0;
    display: inline-block;
}
.main-wallpaper-preview {
    width: 100%;
    height: auto;
    display: block;
}
.preview-note {
    display: block;
    text-align: center;
    color: #999;
    font-size: 10px !important;
    margin-top: 10px;
}
h1 {
    font-size: 24px;
    margin: 0 0 15px 0 !important;
    line-height: 1.2;
}
.info-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 14px;
}
.info-table td {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}
.info-table td:first-child {
    font-weight: bold;
    color: #888;
    width: 110px;
}

/* Links & Hashtags */
.category-link, .hashtag-link {
    color: #505050;
    font-weight: bold;
    text-decoration: none;
}
.hashtags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 25px;
}
.hashtag-link {
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    font-size: 12px;
}

/* Buttons */
.download-btn {
    display: block;
    text-align: center;
    background: #505050;
    color: white;
    padding: 10px 24px;
    text-decoration: none;
    border-radius: 6px;
    font-weight: bold;
    font-size: 14px;
    margin-top: 16px;
}
.download-btn:hover { background: #333; }

/* 6. Pagination & List All */
.section-header-link { text-decoration: none; color: inherit; }
.section-header-link:hover h2 { color: #1877f2; }

.list-all-btn-wrap { text-align: center; margin-top: 20px; }
.btn-list-all { 
    display: inline-block; 
    padding: 8px 25px; 
    background: #f0f2f5; 
    color: #555; 
    text-decoration: none; 
    border-radius: 20px; 
    font-size: 14px; 
    font-weight: 600;
    border: 1px solid #ddd;
}
.btn-list-all:hover { background: #e4e6eb; }

.pagination {
    display: flex;
    justify-content: center;
    margin-top: 40px;
    gap: 8px;
}
.page-link {
    padding: 8px 14px;
    background: #fff;
    color: #1877f2;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 6px;
}
.page-link.active {
    background: #1877f2;
    color: #fff;
    border-color: #1877f2;
}