/* --- CSS STYLES: MODERN REDESIGN --- */

/* Define Variables */
:root {
    /* NEW COLORS from uploaded file */
    --primary-color: #3b82f6; /* Blue 500 */
    --primary-hover: #2563eb; /* Blue 600 */
    --secondary-color: #6b7280; /* Gray 500 */
    --bg-light: #f3f4f6; /* Gray 100 */

    /* Theme Variables (Light Mode Default) */
    --bg-default: var(--bg-light);
    --bg-paper: #ffffff;
    --text-default: #1f2937; /* Gray 800 */
    --text-secondary: var(--secondary-color);
    
    /* NEW SHADOWS from uploaded file (mapped to old names) */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); /* shadow-md */
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1); /* shadow-lg */
    
    /* Keeping existing structural variables, adjusted to new palette colors */
    --border-color: #dee2e6;
    --border-radius: 8px;
    --input-bg: var(--bg-paper);
}

/* --- Dark Mode Variables --- */
html.dark:root {
    /* NEW DARK COLORS */
    --bg-default: #111827; /* Gray 900 */
    --bg-paper: #1f2937; /* Gray 800 */
    --bg-light-dark: #374151; /* Custom Gray 700 for lighter dark elements */
    --text-default: #f3f4f6; /* Gray 100 */
    --text-secondary: #9ca3af; /* Gray 400 */
    --border-color: #374151;

    /* NEW DARK SHADOWS */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    
    --input-bg: var(--bg-paper);
}

/* Global Styles */
body {
    font-family: 'Inter', sans-serif; /* UPDATED: Changed font */
    background-color: var(--bg-default);
    color: var(--text-default);
    margin: 0;
    padding: 20px; 
    transition: background-color 0.4s, color 0.4s;
    line-height: 1.6;
    overflow-x: hidden; 
}

.container {
    max-width: 1300px;
    margin: 0 auto;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    margin-top: 0px;
    color: var(--primary-color); /* Uses the new primary blue: #3b82f6 */
}

/* --- Header and Controls --- */
.header {
    margin-bottom: 30px; 
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px; 
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

/* Theme Toggle Button */
.icon-button {
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Font size removed since it's now using SVGs */
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.icon-button:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.3); /* Uses new primary color */
}

.controls {
    display: flex;
    gap: 20px;
}

.input-group {
    flex-grow: 1;
}

.input-control {
    width: 100%;
    padding: 12px 18px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--input-bg);
    color: var(--text-default);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box; 
}

.input-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25); /* Uses new primary color */
}

/* Select Control: Updated to use new text colors for SVG */
.select-control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Updated Fill color to NEW text-default #1f2937 */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23${encodeURIComponent('1f2937')}" class="bi bi-caret-down-fill" viewBox="0 0 16 16"><path d="M7.247 11.14 2.451 5.658C1.885 5.019 2.345 4 3.204 4h9.592c.859 0 1.319 1.019.753 1.658l-4.796 5.482a1 1 0 0 1-1.506 0z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 18px center;
    background-size: 12px;
    padding-right: 40px; 
}
html.dark .select-control {
    /* Updated Fill color to NEW text-default #f3f4f6 for dark mode */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23${encodeURIComponent('f3f4f6')}" class="bi bi-caret-down-fill" viewBox="0 0 16 16"><path d="M7.247 11.14 2.451 5.658C1.885 5.019 2.345 4 3.204 4h9.592c.859 0 1.319 1.019.753 1.658l-4.796 5.482a1 1 0 0 1-1.506 0z"/></svg>');
}


/* Post Grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px; 
}

/* Post Card */
.post-card {
    background-color: var(--bg-paper);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid var(--border-color);
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

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

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease-in-out;
}

.post-card-content {
    padding: 20px;
}

.post-card-content h2 {
    font-size: 1.5rem;
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--primary-color); 
    display: block; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.post-card-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 15px;
    overflow: hidden; 
    max-height: 4.5em; 
    line-height: 1.5; 
}

.post-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.post-card-author {
    font-weight: bold;
    color: var(--text-default);
}

/* --- Post Detail Full Page View --- */

#post-detail-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-default);
    z-index: 2000;
    overflow-y: auto;
    
    /* SLIDE-IN EFFECT */
    transform: translateX(100%); 
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    padding: 0;
    display: none; 
}

#post-detail-page.active {
    transform: translateX(0);
    display: block;
}

.detail-header {
    background-color: var(--bg-paper);
    padding: 15px 30px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

/* Back Button Styling */
.back-btn {
    background: none;
    border: none;
    color: var(--text-default);
    font-size: 1.2em; 
    cursor: pointer;
    padding: 8px 15px;
    margin: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--border-radius);
    transition: background-color 0.2s, color 0.2s;
    font-weight: 500;
}

.back-btn:hover {
    background-color: rgba(59, 130, 246, 0.1); /* Uses new primary color */
    color: var(--primary-color);
}

.back-btn .icon {
    font-size: 20px; 
    line-height: 1;
    font-weight: 900;
}

.detail-content-wrapper {
    max-width: 1000px;
    margin: 9px auto; 
    padding: 30px; 
    border: 1px solid var(--border-color);
    border-radius: 0px;
    background-color: var(--bg-paper);
    box-shadow: var(--shadow-hover);
}

.detail-content-wrapper h1 {
    color: var(--text-default);
    font-size: 3rem;
    margin-bottom: 10px;
    line-height: 1.2;
}

/* Meta Data Styling */
.meta-container {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
}

.meta-container img {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--primary-color);
    flex-shrink: 0; 
}

.meta-info h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.3em;
    font-weight: 600;
}

.meta-info p {
    margin: 0;
    font-size: 0.95em;
    color: var(--text-secondary);
}

/* Post Content Styling - Ensure text wrapping */
.post-body {
    padding: 30px 0;
    margin-top: 30px; 
    line-height: 1.8;
    font-size: 1.1rem;
    border-top: 1px solid var(--border-color);
    word-wrap: break-word; 
    overflow-wrap: break-word; 
}

.thumbnail-image {
    width: 100%;
    height: 400px; 
    object-fit: cover;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    cursor: pointer;
    overflow: hidden; 
}

.thumbnail-image img, .thumbnail-image video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* --- Media Gallery (Carousel) Section --- */
.post-media-gallery {
    margin-top: 40px; 
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
    position: relative;
}

.post-media-gallery h3 {
    color: var(--text-default);
    margin-bottom: 20px;
}

.media-viewer {
    position: relative;
    width: 100%;
    height: 500px; 
    overflow: hidden;
    background-color: #000;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-hover);
}

.media-item {
    display: none;
    width: 100%;
    height: 100%;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s;
}

.media-item img, .media-item video {
    width: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; 
    display: block;
}

.media-item.active {
    display: flex; 
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    padding: 20px;
    cursor: pointer;
    z-index: 50;
    font-size: 28px;
    line-height: 1;
    transition: background-color 0.2s;
    border-radius: 50%;
    opacity: 0.8;
}

.gallery-nav:hover {
    background-color: rgba(0, 0, 0, 0.9);
    opacity: 1;
}

#prev-media { left: 15px; }
#next-media { right: 15px; }

/* --- Lightbox Modal (Full View) --- */
#lightbox-modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.95);
    display: flex; 
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#lightbox-content {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 95%;
    max-width: 1400px;
    height: 95vh;
}

#lightbox-content img, #lightbox-content video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; 
    margin: 0;
    display: block;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: #f8f9fa;
    font-size: 50px;
    font-weight: bold;
    cursor: pointer;
    z-index: 3001;
    transition: color 0.2s;
}

.lightbox-close:hover {
    color: var(--primary-color);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    color: #f8f9fa;
    padding: 25px;
    font-size: 60px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transform: translateY(-50%);
    transition: opacity 0.2s;
}

#lightbox-prev { left: 10px; }
#lightbox-next { right: 10px; }


/* =================================================== */
/* --- MEDIA QUERIES FOR MOBILE RESPONSIVENESS --- */
/* =================================================== */

@media (max-width: 768px) {

    body {
        padding: 15px; 
    }

    h1 {
        font-size: 2rem; 
    }
    
    .header-top {
        margin-bottom: 10px;
    }

    /* Controls Stacking */
    .controls {
        flex-direction: column; 
        gap: 15px;
    }

    .icon-button {
        width: 40px;
        height: 40px;
        /* Size adjusted to fit SVGs */
    }

    .input-control {
        padding: 10px 15px;
        font-size: 0.95rem;
    }
    
    .select-control {
        background-position: right 15px center;
    }

    /* Post Grid Adjustment */
    .posts-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 25px; 
    }

    .post-card-content h2 {
        font-size: 1.3rem; 
    }

    .card-image-wrapper {
        height: 180px; 
    }

    .post-card-content p {
         max-height: 4.8em; 
    }

    /* Post Detail View Optimization */
    .detail-header {
        padding: 10px 15px; 
    }

    .back-btn .text {
        display: none; 
    }
    .back-btn {
        padding: 8px 10px;
    }

    .detail-content-wrapper {

        padding: 10px; 
        margin: 4px auto;
    }
    .detail-content-wrapper h1 {
        font-size: 2rem; 
        margin-top: 0;
    }

    /* Meta Data Layout */
    .meta-container {
        flex-direction: row; 
        align-items: center;
        padding: 15px 0; 
        gap: 15px;
        text-align: left; 
    }
    .meta-container img {
        width: 50px; 
        height: 50px;
    }
    .meta-info {
        flex-grow: 1;
    }
    
    .meta-info h3 {
        font-size: 1.1em;
    }

    .post-body {
        font-size: 1rem; 
        line-height: 1.7;
        padding-top: 15px;
    }

    .thumbnail-image {
        height: 250px; 
        margin-bottom: 20px;
    }

    /* Media Gallery Adjustments */
    .post-media-gallery {
        margin-top: 30px;
        padding-top: 20px;
    }

    .media-viewer {
        height: 300px; 
    }

    .gallery-nav {
        padding: 15px;
        font-size: 20px;
    }

    #prev-media { left: 5px; }
    #next-media { right: 5px; }
}

@media (max-width: 480px) {

    .detail-content-wrapper {
        border: none;
        box-shadow: none;
        padding: 0 10px;
        margin: 4px auto;
    }

    /* Lightbox Navigation */
    .lightbox-close {
        font-size: 40px;
        top: 10px;
        right: 20px;
    }

    .lightbox-nav {
        font-size: 40px;
        padding: 15px;
    }
}
