/**
 * Public Styles - List Layout
 *
 * @package    Advanced_Post_Viewer
 * @author     Diệp Lai
 */

/* Color Variables - Scoped to plugin only */
.apv-container,
.apv-single-container {
    --apv-primary-color: #18423a;
    --apv-secondary-color: #92c200;
    --apv-primary-hover: #b4e717;
    --apv-button-radius: 20px;
}

/* Reset & Base - Only style plugin classes, never use * selector */
.apv-container {
    box-sizing: border-box;
    display: block;
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: Arial, sans-serif;
    font-size: 13px;
    color: #333;
    line-height: 1.5;
    text-align: left;
    direction: ltr;
}

/* Breadcrumb */
.apv-breadcrumb {
    color: #999;
    margin-bottom: 10px;
    font-size: 12px;
}

.apv-breadcrumb a {
    color: #999;
    text-decoration: none;
}

.apv-breadcrumb a:hover {
    color: #666;
}

.apv-breadcrumb i {
    font-size: 13px;
}

/* Page Title */
.apv-container h1 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #333;
    font-weight: bold;
}

/* Search Box */
.apv-search-box {
    margin-bottom: 20px;
}

.apv-search-input-wrapper {
    margin-bottom: 0;
}

.apv-search-input-wrapper form {
    display: flex;
    gap: 10px;
}

.apv-search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
}

.apv-search-input:focus {
    outline: none;
    border-color: var(--apv-primary-color);
}

.apv-btn-search {
    background-color: var(--apv-primary-color);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: var(--apv-button-radius);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.apv-btn-search:hover {
    background-color: var(--apv-primary-hover);
    color: #1c4b42;
}

.apv-btn-search i {
    margin-right: 5px;
}

/* Tabs Navigation */
.apv-tabs-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 0;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0;
}

.apv-tab {
    padding: 10px 24px;
    background-color: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.apv-tab a {
    color: #666;
    text-decoration: none;
    display: block;
}

.apv-tab.active {
    background-color: transparent;
    border-bottom-color: var(--apv-primary-color);
}

.apv-tab.active a {
    color: var(--apv-primary-color);
}

.apv-tab:hover a {
    color: #333;
}

.apv-tab.active:hover a {
    color: var(--apv-primary-hover);
}

.apv-tab.active:hover {
    border-bottom-color: var(--apv-primary-hover);
}

/* Content Wrapper */
.apv-content-wrapper {
    display: flex;
    gap: 20px;
}

/* Main Content */
.apv-main-content {
    flex: 1;
    background-color: #fff;
    padding: 20px;
    box-shadow: 0 1px 8px 0 rgba(0,0,0,.16);
    border-radius: 4px;
}

/* Results Info */
.apv-results-info {
    padding: 15px 0;
    margin-bottom: 15px;
    font-size: 14px;
    color: #666;
    border-bottom: 1px solid #e0e0e0;
}

.apv-results-info strong {
    color: var(--apv-primary-color);
    font-weight: 600;
}

/* Result Item */
.apv-result-item {
    border-bottom: 1px solid #e0e0e0;
    padding: 15px 0;
}

.apv-result-item:last-child {
    border-bottom: none;
}

.apv-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 8px;
}

.apv-result-title-wrapper {
    flex: 1;
    display: flex;
    gap: 10px;
}

.apv-result-number {
    font-weight: bold;
    color: #666;
    min-width: 30px;
    flex-shrink: 0;
}

.apv-result-title {
    flex: 1;
    color: var(--apv-primary-color);
    text-decoration: none;
    font-weight: bold;
    line-height: 1.5;
}

.apv-result-title:hover {
    text-decoration: underline;
}

.apv-result-dates {
    flex-shrink: 0;
    text-align: right;
    font-size: 12px;
    min-width: 150px;
}

.apv-date-item {
    margin-bottom: 3px;
}

.apv-date-item:last-child {
    margin-bottom: 0;
}

.apv-result-meta {
    margin-left: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    color: #666;
    font-size: 12px;
}

.apv-result-meta a,
.apv-result-meta span {
    color: #666;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.3s ease;
}

.apv-result-meta a:hover {
    color: var(--apv-primary-color);
    text-decoration: underline;
}

.apv-result-meta i {
    margin-right: 4px;
    font-size: 12px;
}

.apv-info-label {
    color: #666;
}

.apv-info-value {
    color: #333;
}

.apv-info-value.apv-date {
    color: var(--apv-primary-color);
    font-weight: 500;
}

/* No Documents */
.apv-no-documents {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

/* Sidebar */
.apv-sidebar {
    width: 300px;
    flex-shrink: 0;
}

.apv-sidebar-section {
    background-color: transparent;
    border: none;
    border-radius: 0;
    margin-bottom: 15px;
}

.apv-sidebar-header {
    background-color: #f0f0f0;
    padding: 10px 15px;
    font-weight: bold;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.apv-sidebar-section:first-child .apv-sidebar-header {
    background-color: transparent;
    border-left: none;
    padding: 10px 0 10px 15px;
    cursor: default;
    position: relative;
    font-size: 15px;
    color: var(--apv-primary-color);
}

.apv-sidebar-section:first-child .apv-sidebar-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 25px;
    background: var(--apv-secondary-color);
    border-radius: 2px;
}

.apv-sidebar-header a {
    color: var(--apv-primary-color);
    font-size: 11px;
    font-weight: normal;
    text-decoration: none;
}

.apv-sidebar-header .apv-toggle {
    font-size: 14px;
    color: #666;
    transition: transform 0.3s ease;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.apv-sidebar-header .apv-toggle i {
    transition: transform 0.3s ease;
}

/* Rotate icon when collapsed */
.apv-sidebar-section.collapsed .apv-toggle i {
    transform: rotate(-90deg);
}

/* Hide content when collapsed */
.apv-sidebar-section.collapsed .apv-sidebar-content {
    display: none;
}

.apv-sidebar-content {
    padding: 15px 0;
    background-color: transparent;
}

.apv-checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
}

.apv-checkbox-item br {
    display: none;
}

.apv-checkbox-item:last-child {
    margin-bottom: 0;
}

.apv-checkbox-item-child {
    padding-left: 20px;
}

.apv-checkbox-item-child label {
    font-size: 11px;
    color: #666;
}

.apv-checkbox-item input[type="checkbox"] {
    margin: 2px 0 0 0;
    flex-shrink: 0;
}

.apv-checkbox-item label {
    flex: 1;
    cursor: pointer;
}

.apv-checkbox-item label a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.apv-checkbox-item label a:hover {
    color: var(--apv-primary-color);
}

.apv-count {
    color: #999;
    font-size: 11px;
}

.apv-search-input-small {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
    margin-bottom: 10px;
}

/* Filter Summary */
.apv-filter-summary {
    min-height: auto;
}

.apv-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.apv-filter-tag {
    display: inline-block;
    padding: 4px 10px;
    background-color: #e8f5e9;
    color: var(--apv-primary-color);
    border: 1px solid #c8e6c9;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
}

.apv-no-filter {
    color: #999;
    font-size: 12px;
    margin: 0;
    font-style: italic;
}

.apv-clear-filter,
.apv-clear-all-filters {
    color: var(--apv-primary-color) !important;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.3s ease;
}

.apv-clear-filter:hover,
.apv-clear-all-filters:hover {
    color: var(--apv-secondary-color) !important;
    text-decoration: underline;
}

/* Filter Forms */
.apv-filter-form {
    margin: 0;
}

.apv-checkbox-item input[type="radio"] {
    margin: 2px 0 0 0;
    flex-shrink: 0;
    cursor: pointer;
}

.apv-checkbox-item input[type="checkbox"],
.apv-checkbox-item input[type="radio"] {
    cursor: pointer;
}

.apv-checkbox-item input[type="checkbox"]:checked,
.apv-checkbox-item input[type="radio"]:checked {
    accent-color: var(--apv-primary-color);
}

/* Pagination */
.apv-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

/* All pagination links */
.apv-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid #ddd;
    background-color: #fff;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    box-sizing: border-box;
}

/* Hover state - NOT for current page */
.apv-pagination .page-numbers:hover:not(.current) {
    background-color: #f5f5f5;
    border-color: #18423a;
    color: #18423a;
}

/* Current page - Active state (chỉ cho số trang, không cho arrow) */
.apv-pagination span.page-numbers.current {
    background-color: #18423a !important;
    color: #fff !important;
    border-color: #18423a !important;
    cursor: default;
    /* Giữ nguyên kích thước như các ô khác */
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    box-sizing: border-box;
}

/* Prev/Next links (a tag) - không có background active */
.apv-pagination a.page-numbers.prev,
.apv-pagination a.page-numbers.next {
    background-color: #fff;
    color: #333;
}

.apv-pagination a.page-numbers.prev:hover,
.apv-pagination a.page-numbers.next:hover {
    background-color: #f5f5f5;
    border-color: #18423a;
    color: #18423a;
}

/* Dots */
.apv-pagination .page-numbers.dots {
    border: none;
    background: transparent;
    cursor: default;
    padding: 0 4px;
}

.apv-pagination .page-numbers.dots:hover {
    background: transparent;
    border: none;
    color: #333;
}

/* Previous/Next arrows */
.apv-pagination .prev,
.apv-pagination .next {
    font-weight: 600;
}

.apv-nav-arrow {
    font-size: 18px;
}

/* ==================================
   SINGLE DOCUMENT PAGE STYLES
   ================================== */

/* Hide WordPress page title "Xem văn bản" only on single document page */
body.apv-single-document-page .entry-title,
body.apv-single-document-page .page-title,
body.apv-single-document-page article > header h1,
body.apv-single-document-page .entry-header .entry-title,
body.apv-single-document-page .page-header h1 {
    display: none !important;
}

.apv-single-container {
    width: 95%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Document Header - Full Width */
.apv-document-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

/* PDF + Sidebar Layout */
.apv-content-with-sidebar {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.apv-pdf-section {
    flex: 1;
    min-width: 0; /* Fix for flexbox overflow */
}

.apv-single-sidebar {
    width: 300px;
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 968px) {
    .apv-content-with-sidebar {
        flex-direction: column;
    }

    .apv-single-sidebar {
        width: 100%;
        order: -1; /* Show sidebar above content on mobile */
    }
}

.apv-document-title {
    font-size: 32px;
    line-height: 1.3;
    margin: 0 0 15px 0;
    color: #1a1a1a;
}

.apv-document-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    font-size: 14px;
    color: #666;
}

.apv-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.apv-meta-item strong {
    color: #333;
}

.apv-document-info-box {
    background: #f8f9fa;
    border-left: 4px solid var(--apv-primary-color);
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 4px;
}

.apv-document-info-box h3 {
    margin-top: 0;
    font-size: 18px;
    color: var(--apv-primary-color);
}

.apv-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.apv-info-item {
    font-size: 14px;
}

.apv-info-item strong {
    display: block;
    color: #333;
    margin-bottom: 5px;
}

/* PDF Viewer Container - Simple Google Docs Viewer */
.apv-pdf-viewer-container {
    position: relative;
    background: transparent;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: none;
    margin-bottom: 30px;
}

/* Align PDF section with sidebar */
.apv-content-with-sidebar .apv-pdf-section {
    margin-top: -12px; /* Align toolbar buttons with sidebar box title */
}

.apv-pdf-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    background: transparent;
    border-bottom: none;
    margin-bottom: 20px;
}

.apv-pdf-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.apv-pdf-actions {
    display: flex;
    gap: 10px;
}

.apv-pdf-btn {
    background: var(--apv-primary-color);
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: var(--apv-button-radius);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.apv-pdf-btn:hover {
    background: var(--apv-primary-hover);
    color: #1c4b42;
}

.apv-pdf-btn:active {
    transform: translateY(1px);
}

.apv-pdf-btn i {
    font-size: 14px;
}

.apv-pdf-viewer-wrapper {
    position: relative;
    width: 100%;
    height: 800px;
    background: #525659;
}

.apv-pdf-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* DOCX Download Notice (for localhost) */
.apv-docx-download-notice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #f9f9f9;
    padding: 40px;
    text-align: center;
}

.apv-docx-icon {
    margin-bottom: 20px;
}

.apv-docx-icon .dashicons {
    font-size: 80px;
    width: 80px;
    height: 80px;
    color: var(--apv-primary-color);
}

.apv-docx-download-notice h3 {
    font-size: 22px;
    color: #333;
    margin: 0 0 15px 0;
}

.apv-docx-download-notice p {
    font-size: 16px;
    color: #666;
    margin: 0 0 30px 0;
    max-width: 500px;
}

.apv-large-download {
    font-size: 16px !important;
    padding: 12px 30px !important;
}

/* Document Content */
.apv-document-content {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    line-height: 1.8;
    font-size: 16px;
}

.apv-document-content h2,
.apv-document-content h3 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: #1a1a1a;
}

.apv-document-content p {
    margin-bottom: 15px;
}

/* Taxonomies */
.apv-taxonomies {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 4px;
}

.apv-taxonomy-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.apv-taxonomy-item {
    display: inline-block;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
}

.apv-taxonomy-item:hover {
    background: var(--apv-primary-color);
    color: #fff;
    border-color: var(--apv-primary-color);
}

/* Horizontal Divider */
.apv-divider {
    height: 2px;
    background: linear-gradient(to right, transparent, #ddd 20%, #ddd 80%, transparent);
    margin: 40px 0;
}

/* Sidebar Boxes */
.apv-sidebar-box {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.apv-sidebar-box-title {
    background: linear-gradient(135deg, var(--apv-primary-color) 0%, var(--apv-primary-hover) 100%);
    color: #fff;
    padding: 12px 15px;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.apv-sidebar-box-content {
    padding: 15px;
}

.apv-sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.apv-sidebar-item {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.apv-sidebar-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.apv-sidebar-item a {
    display: block;
    text-decoration: none;
    transition: all 0.3s ease;
}

.apv-sidebar-item a:hover {
    transform: translateX(5px);
}

.apv-sidebar-item-date {
    display: block;
    font-size: 11px;
    color: #999;
    margin-bottom: 5px;
}

.apv-sidebar-item-title {
    display: block;
    font-size: 13px;
    color: #333;
    line-height: 1.4;
    font-weight: 500;
}

.apv-sidebar-item a:hover .apv-sidebar-item-title {
    color: var(--apv-primary-color);
}

.apv-no-items {
    color: #999;
    font-size: 13px;
    font-style: italic;
    margin: 0;
}

/* Related Documents Section */
.apv-related-section {
    margin-top: 40px;
}

.apv-related-title {
    font-size: 24px;
    color: var(--apv-primary-color);
    margin-bottom: 25px;
    font-weight: 600;
    position: relative;
    padding-left: 15px;
}

.apv-related-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 30px;
    background: var(--apv-secondary-color);
    border-radius: 2px;
}

.apv-related-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.apv-related-card {
    background: transparent;
    border-bottom: 1px solid #e8e8e8;
    padding: 20px 0;
    transition: all 0.3s ease;
}

.apv-related-card:last-child {
    border-bottom: none;
}

.apv-related-card-title {
    margin: 0 0 10px 0;
    font-size: 17px;
    line-height: 1.6;
    font-weight: 500;
}

.apv-related-card-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
    display: block;
}

.apv-related-card-title a:hover {
    color: var(--apv-primary-color);
}

.apv-related-card-meta {
    margin-bottom: 0;
}

.apv-related-tags {
    display: inline-block;
    font-size: 13px;
    color: #92c200;
    font-style: italic;
}

.apv-no-related {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 40px 20px;
}

/* ==================================
   RESPONSIVE DESIGN
   ================================== */

@media (max-width: 992px) {
    .apv-content-wrapper {
        flex-direction: column;
    }

    .apv-sidebar {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .apv-container {
        padding: 15px;
    }

    .apv-result-header {
        flex-direction: column;
        gap: 8px;
    }

    .apv-result-dates {
        text-align: left;
        min-width: auto;
    }

    .apv-related-title {
        font-size: 20px;
    }

    .apv-result-number {
        min-width: auto;
    }

    .apv-result-meta {
        margin-left: 0;
    }

    .apv-document-title {
        font-size: 24px;
    }

    .apv-document-meta {
        flex-direction: column;
        gap: 10px;
    }

    .apv-pdf-toolbar {
        flex-wrap: wrap;
        gap: 5px;
        padding: 10px;
    }

    .apv-pdf-btn {
        padding: 6px 12px;
        font-size: 14px;
        min-width: 32px;
        height: 32px;
    }

    .apv-pdf-viewer-wrapper {
        min-height: 400px;
        padding: 10px;
    }

    .apv-document-content {
        padding: 20px;
    }

    .apv-info-grid {
        grid-template-columns: 1fr;
    }

    .apv-search-input-wrapper form {
        flex-direction: column;
    }

    .apv-btn-search {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .apv-tabs-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .apv-tab {
        padding: 8px 16px;
        font-size: 13px;
        white-space: nowrap;
    }

    .apv-results-info {
        font-size: 13px;
        padding: 12px 0;
    }

    .apv-pagination {
        gap: 4px;
    }

    .apv-pagination .page-numbers {
        min-width: 32px;
        height: 32px;
        padding: 0 8px;
        font-size: 13px;
    }
}

/* Print styles */
@media print {
    .apv-search-box,
    .apv-sidebar,
    .apv-pdf-toolbar,
    .apv-taxonomies,
    .apv-btn-add-doc {
        display: none;
    }

    .apv-content-wrapper {
        display: block;
    }

    .apv-main-content {
        width: 100%;
    }
}
