/*
 * File: layout.css
 * Chứa các style cho bố cục chính: header, footer, sidebar, menu, grid...
 */

/* --- Header, Footer & Navigation --- */
.desktop-main-menu {
    display: flex;
    gap: 1.75rem; /* Tương đương space-x-7 */
    list-style: none;
    padding: 0;
    margin: 0;
}
.main-menu-item {
    font-family: 'Roboto Condensed', sans-serif;
    font-weight: 400; /* Regular */
    font-size: 16px;
    color: #4B5563; /* text-gray-600 */
    transition: color 0.2s;
    text-transform: uppercase;
}
.main-menu-item:hover {
    color: #FF6F61; /* text-primary */
}
.mobile-menu-panel {
    position: fixed; top: 0; right: -100%; width: 280px; height: 100%;
    background-color: white; box-shadow: -2px 0 8px rgba(0,0,0,0.15);
    z-index: 100; transition: right 0.3s ease-in-out; padding-top: 60px;
}
body.mobile-menu-open .mobile-menu-panel { right: 0; }
body.mobile-menu-open::after {
    content: ''; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5); z-index: 99; cursor: pointer;
}
body.mobile-menu-open #mobile-menu-toggle i::before { content: "\ea38"; }
.mobile-main-menu ul {
    display: flex;
    flex-direction: column;
    list-style: none;
    padding: 0 1rem;
    margin: 1rem 0 0 0;
}
.mobile-main-menu li {
    width: 100%;
}
.mobile-menu-item {
    display: block;
    padding: 0.7rem 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 1.125rem;
    font-weight: 600;
    color: #374151;
    transition: color 0.2s;
}
.mobile-menu-item:hover { color: #FF6F61; }
.mobile-main-menu li:last-child .mobile-menu-item { border-bottom: none; }

/* --- Page & Content Structure --- */
.page-header .page-title {
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}
.widget-area .widget {
    margin-bottom: 1.5rem;
}
.section-title {
    font-size: 20px;
    font-weight: 700;
    padding-bottom: 8px;
    border-bottom: 2px solid #FF6F61; /* primary */
    margin-bottom: 16px;
}
.no-results {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.chapter-list {
    padding: 0;
    margin: 0;
    list-style: none;
}
.listen-audio-container, 
.story-chapters-container, 
.similar-stories-container, 
.story-header-container,
.story-comments-container {
    background-color: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* --- Homepage Layout --- */
.homepage-layout-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem; /* 24px */
}
.homepage-sidebar {
    grid-column: span 1 / span 1;
}
.homepage-main {
    grid-column: span 2 / span 2;
}

/* --- Reader Page Layout --- */
.reader-header-wrapper {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-bottom: 1px solid #e5e7eb;
}
.reader-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 16px;
}
#chapter-content {
    font-size: 18px;
    line-height: 1.8;
}
#story-synopsis-content {
    max-height: 120px;
    overflow: hidden;
    position: relative;
    transition: max-height 0.4s ease-in-out;
}
#story-synopsis-content.expanded {
    max-height: 2000px;
}

/* --- Responsive Layouts --- */
@media (min-width: 768px) {
    .chapter-list {
        column-count: 2;
        column-gap: 1rem;
    }
}
.chapter-list li {
    break-inside: avoid;
}
@media (max-width: 1023px) { /* lg breakpoint, áp dụng cho tablet trở xuống */
    .homepage-layout-container {
        display: flex;
        flex-direction: column;
    }
    /* Ẩn sidebar trái và phải trên trang chủ */
    .homepage-sidebar {
        display: none; 
    }
    /* Cho nội dung chính chiếm toàn bộ chiều rộng */
    .homepage-main {
        width: 100%; 
    }
}
@media (max-width: 767px) {
    #secondary { display: none; }
    #primary { width: 100%; }
    .section-title {
        font-size: 16px;
        white-space: nowrap;
        margin-right: 1rem;
    }
    .latest-update-row {
        flex-wrap: wrap; 
    }
    .latest-update-row .story-title {
        width: 100%;
        margin-bottom: 4px;
        margin-right: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
    }
    .latest-update-row .chapter-details-group {
        width: 100%;
        justify-content: space-between; 
        gap: 1rem;
        margin-top: 4px;
    }
    .latest-update-row .chapter-title {
        max-width: none;
    }
    .latest-update-row .time-ago {
        width: auto;
    }
    .nav-btn {
        padding: 8px 12px;
        font-size: 14px;
    }
    .chapter-nav {
        gap: 0.5rem;
    }
}

/* --- Reader Page Layout --- */
.reader-header-wrapper {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-bottom: 1px solid #e5e7eb;
}
.reader-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 16px;
}
#chapter-content {
    font-size: 18px;
    line-height: 1.8;
}
/* ===================================================================
 * PHIÊN BẢN 17.4: SỬA LỖI KHOẢNG CÁCH WIDGET
 * =================================================================== */
.widget-area .widget,
.homepage-sidebar .widget,
.homepage-main .widget,
.homepage-fullwidth-bottom-container .widget {
    margin-bottom: 1.5rem; /* Tạo khoảng cách 24px dưới mỗi widget */
}

.header-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 1.5rem; /* 24px - Tăng kích thước lên */
    color: #4b5563; /* gray-600 */
    border-radius: 9999px;
    transition: background-color 0.2s, color 0.2s;
}
/*
 * ===================================================================
 * PHIÊN BẢN 3.0: BỔ SUNG CSS CHO LAYOUT 8 CỘT
 * Giúp widget "Truyện Ngẫu Nhiên" hoạt động với cài đặt 8 cột.
 * ===================================================================
 */
@media (min-width: 1024px) {
    .lg\:grid-cols-8 {
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }
}

/* Tùy chọn: Bạn có thể thêm các kích thước khác nếu muốn */
@media (min-width: 1024px) {
    .lg\:grid-cols-7 {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }
    .lg\:grid-cols-9 {
        grid-template-columns: repeat(9, minmax(0, 1fr));
    }
    .lg\:grid-cols-11 {
        grid-template-columns: repeat(11, minmax(0, 1fr));
    }
    .lg\:grid-cols-12 {
        grid-template-columns: repeat(12, minmax(0, 1fr));
    }
}