/* 1. Theme Variables & Base */
:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --card-bg: #f9f9f9;
    --border-color: #228B22;
    --accent-color: #228B22;
    --nav-height: 60px;
    --text-muted: #777777;
    --highlight-gold: #ffda44;
    --danger-red: #d9534f;
}

[data-theme="dark"] {
    --bg-color: #1a1a1b;
    --text-color: #d7dadc;
    --card-bg: #272729;
    --border-color: #2d5a27;
    --accent-color: #1b4d1b;
    --text-muted: #a0a0a0;
}

body { 
    background: var(--bg-color); 
    color: var(--text-color); 
    font-family: sans-serif; 
    margin: 0; 
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 2. Structural Layout */
.main-wrapper {
    display: flex;
    align-items: flex-start; 
    justify-content: flex-start;
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
    gap: 30px;
    flex: 1;
    width: 100%;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    padding-right: 20px;
    position: -webkit-sticky;
    position: sticky;
    top: 20px; 
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.content { 
    flex-grow: 1; 
    min-width: 0;
}

/* 3. Navigation Bar */
.main-nav {
    background: var(--accent-color);
    padding: 0.8rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-center {
    display: flex;
    gap: 25px;
    align-items: center;
}

.main-nav a { 
    color: white; 
    text-decoration: none; 
    font-weight: bold; 
}

.brand { 
    font-size: 1.4rem; 
    letter-spacing: -0.5px;
}

.admin-link {
    color: var(--highlight-gold) !important;
}

.btn-post {
    background: white;
    color: var(--accent-color) !important;
    padding: 6px 15px;
    border-radius: 4px;
}

.theme-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    cursor: pointer;
    border-radius: 4px;
    padding: 4px 10px;
}

/* 4. Sidebar Categories & Interactive States */
.category-list h3 {
    margin-top: 0;
    font-size: 1.2rem;
}

.cat-parent {
    margin-bottom: 5px;
}

.cat-toggle, .cat-direct-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 10px 8px;
    border-radius: 4px;
    color: var(--text-color);
    text-decoration: none;
    transition: background 0.2s;
}

.cat-toggle:hover, .cat-direct-link:hover {
    background: rgba(34, 139, 34, 0.1);
}

.cat-children {
    display: none; 
    list-style: none;
    padding: 5px 0 10px 20px;
    margin: 0;
}

/* NEW: Child Link Styling to match parents */
.cat-children a {
    display: block;
    padding: 8px 8px;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.2s;
    font-size: 0.95rem;
}

.cat-children a:hover {
    background: rgba(34, 139, 34, 0.1);
    color: var(--accent-color);
}

.view-all-link {
    font-weight: bold;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 5px;
}

.cat-parent.active .cat-children {
    display: block;
}

.chevron {
    transition: transform 0.3s ease;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.cat-parent.active .chevron {
    transform: rotate(90deg);
    color: var(--accent-color);
}

/* 5. Listing Rows (Thumbnails) */
.listing-row {
    border: 1px solid var(--border-color);
    padding: 15px;
    margin-bottom: 15px;
    background: var(--card-bg);
    display: flex;
    gap: 20px;
    border-radius: 8px;
}

.listing-thumb {
    width: 140px;
    height: 110px;
    background: #eee;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
}

.listing-thumb img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
}

/* 6. View Listing Detail & Gallery */
.main-image-viewport {
    width: 100%;
    height: 450px; 
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    margin-bottom: 15px;
}

.main-image-viewport img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.thumbnail-strip {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.thumb-item {
    width: 80px;
    height: 60px;
    object-fit: cover;
    cursor: pointer;
    border-radius: 4px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.thumb-item.active {
    border-color: var(--accent-color);
}

/* 7. Admin Dashboard Styles */
.stat-card {
    padding: 20px; 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    background: var(--card-bg); 
    text-align: center;
}

.stat-card.alert {
    border-color: var(--danger-red);
    background: rgba(217, 83, 79, 0.05);
}

.stat-number {
    font-size: 2rem; 
    font-weight: bold; 
    margin: 5px 0;
}

/* 8. Utility & Buttons */
.btn-report {
    display: block;
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    background: transparent;
    color: var(--danger-red);
    border: 1px solid var(--danger-red);
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
    transition: all 0.2s;
}

.btn-report:hover {
    background: var(--danger-red);
    color: white;
}

/* 9. Site Footer */
.site-footer {
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 40px 20px;
    margin-top: auto; 
    text-align: center;
    color: var(--text-muted);
}

.footer-links {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 15px;
    align-items: center;
}

.footer-links a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: bold;
}

/* 10. Responsiveness */
.mobile-filter-btn {
    display: none; 
    width: 100%;
    padding: 12px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 15px;
}

@media (max-width: 850px) {
    .nav-center { display: none; }
    .main-wrapper { flex-direction: column; }
    
    .mobile-filter-btn {
        display: block; 
    }

    .sidebar {
        display: none; 
        width: 100%;
        position: static;
        height: auto;
        border-right: none;
        padding-right: 0;
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 20px;
        max-height: none;
    }

    .sidebar.show-mobile {
        display: block;
        animation: slideDown 0.3s ease-out;
    }

    .footer-links {
        flex-direction: column;
        gap: 10px;
    }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}