/* File: assets/css/lelib-components.css */

/* =========================================
   SHARED COMPONENTS (Card Base)
   ========================================= */
.tv-item,
.tv-card {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #fff;
    padding: 0;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.tv-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.12);
    border-color: #d1d5db;
    z-index: 2;
}

.tv-card-thumb {
    display: block;
    aspect-ratio: 16/9;
    overflow: hidden;
    position: relative;
}

.tv-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.tv-card:hover .tv-card-thumb img {
    transform: scale(1.08);
}

.tv-card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.tv-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.4;
    margin: 0;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s;
}

.tv-card-title:hover {
    color: var(--tv-accent);
}

.tv-meta-rows {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tv-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.tv-img.is-portrait {
    object-fit: contain !important;
    background: #f9fafb;
}

.tv-img--placeholder {
    background: #f3f4f6;
    width: 100%;
    height: 100%;
    display: block;
}

.tv-select {
    appearance: none;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 32px 6px 12px;
    font-size: 0.9rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    cursor: pointer;
}

.tv-select:focus {
    border-color: var(--tv-accent);
    outline: 2px solid rgba(139, 174, 102, 0.2);
}

.tv-select--sm {
    padding: 4px 28px 4px 8px;
    font-size: 0.85rem;
    height: 32px;
}

/* =========================================
   POPUP GLOBAL STYLE (New Layout)
   ========================================= */
.tv-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.tv-popup.is-open {
    opacity: 1;
    visibility: visible;
}

.tv-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

/* Nút Đóng Popup (SVG Style) */
.tv-popup-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 20;
    width: 36px;
    height: 36px;
    padding: 0;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.tv-popup-close svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
    transition: transform 0.3s ease;
}

.tv-popup-close:hover {
    background: #fef2f2;
    border-color: #fee2e2;
    color: #ef4444;
    transform: rotate(90deg);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.15);
}

/* Wrapper 2 Cột */
.tv-popup-wrapper {
    width: 85vw;
    height: 85vh;
    max-width: 1100px;
    max-height: 90vh;
    background: #fff;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    z-index: 10;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.tv-popup.is-open .tv-popup-wrapper {
    transform: translateY(0);
}

.tv-popup-layout {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* --- CỘT TRÁI (Ảnh + Tên) --- */
.tv-col-left {
    width: 40%;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 30px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.tv-author-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    height: 100%;
    justify-content: space-between;
}

.tv-author-portrait {
    display: block;
    flex: 1;
    /* Chiếm hết chiều cao có thể */
    width: auto;
    max-width: 100%;
    min-height: 0;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.tv-author-portrait--placeholder {
    flex: 1;
    width: 100%;
    min-height: 0;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    font-weight: 800;
    color: #9ca3af;
    border-radius: 12px;
    margin-bottom: 20px;
}

.tv-author-meta {
    flex-shrink: 0;
    width: 100%;
}

.tv-author-name {
    margin: 0;
    font-size: 1.6rem;
    color: #111827;
    font-weight: 800;
    line-height: 1.2;
}

/* --- CỘT PHẢI (Mô tả) --- */
.tv-col-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    position: relative;
}

.tv-author-desc {
    flex: 1;
    overflow-y: auto;
    padding: 10px 30px;
    margin-top: 0;
    font-size: 1.1rem;
    line-height: 1.8;
    color: #374151;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.tv-author-desc::-webkit-scrollbar {
    width: 6px;
}

.tv-author-desc::-webkit-scrollbar-track {
    background: transparent;
}

.tv-author-desc::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 4px;
}

.tv-author-desc p {
    margin-bottom: 1.5em;
}

.tv-author-desc h1,
.tv-author-desc h2,
.tv-author-desc h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    color: #111827;
}

/* Responsive Mobile Popup */
@media (max-width: 768px) {
    .tv-popup-wrapper {
        width: 90vw;
        height: auto;
        max-height: 85vh;
        border-radius: 24px;
    }

    .tv-popup-layout {
        flex-direction: column;
        overflow-y: auto;
        height: auto;
        max-height: 85vh;
    }

    .tv-col-left {
        width: 100%;
        height: auto;
        padding: 24px 20px 16px;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        flex-shrink: 0;
    }

    .tv-author-portrait {
        flex: none;
        height: auto;
        max-height: 200px;
        width: auto;
        max-width: 100%;
        border-radius: 16px;
        margin-bottom: 16px;
    }

    .tv-author-name {
        font-size: 1.4rem;
        margin-bottom: 8px;
    }

    .tv-col-right {
        overflow: visible;
    }

    .tv-author-desc {
        padding: 16px 20px 24px;
        overflow: visible;
        font-size: 1rem;
    }
}

/* =========================================
   SINGLE DOCUMENT META BOX
   ========================================= */
.tv-doc-meta {
    background-color: #f9fafb;
    /* Nền xám nhạt */
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tv-meta-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

/* Nhãn: Icon + Text */
.tv-meta-label {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 110px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #6b7280;
    padding-top: 5px;
    /* Căn chỉnh */
}

.tv-meta-label svg {
    color: #9ca3af;
    width: 16px;
    height: 16px;
}

/* Values Area */
.tv-meta-values {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

/* --- CHIP BASE STYLE (Dùng chung) --- */
.tv-meta-chip {
    display: inline-flex;
    align-items: center;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
    line-height: 1.4;
    transition: all 0.2s ease;
}

/* --- CASE 1: SIMPLE LINK CHIP (Chuyên mục, Thể loại) --- */
a.tv-meta-chip--link {
    text-decoration: none;
    padding: 3px 12px;
    /* Padding đều */
}

a.tv-meta-chip--link:hover {
    border-color: var(--tv-accent, #2563eb);
    background-color: var(--tv-accent-bg, #eff6ff);
    color: var(--tv-accent-hover, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* --- CASE 2: GROUP CHIP (Tác giả - Có nút Info) --- */
span.tv-meta-chip--group {
    padding: 0;
    /* Padding do con bên trong lo */
    overflow: hidden;
    /* Để bo góc cho children */
    gap: 0;
    /* Các phần tử dính liền nhau */
}

span.tv-meta-chip--group:hover {
    border-color: #9ca3af;
    /* Hover vào cả cụm thì viền đậm lên chút */
}

/* Phần Tên (Link Filter) */
.tv-chip-link {
    display: inline-block;
    padding: 3px 8px 3px 12px;
    /* Trái rộng, phải hẹp */
    color: #374151;
    text-decoration: none;
    font-weight: 600;
    /* Tên tác giả đậm hơn chút */
    transition: background 0.2s, color 0.2s;
    border-right: 1px solid transparent;
    /* Chuẩn bị cho vạch ngăn */
}

.tv-chip-link:hover {
    background-color: var(--tv-accent-bg);
    color: var(--tv-accent-hover);
}

/* Checkbox riêng biệt */
.tv-chip-cb-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px 3px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.tv-chip-cb-wrap:hover {
}

.tv-chip-cb-wrap .tv-meta-cb {
    margin: 0; /* Override any previous margins */
    cursor: pointer;
    transform: scale(1.1);
}

/* Vạch ngăn cách mờ (Separator) */
.tv-chip-sep {
    width: 1px;
    height: 14px;
    background-color: #e5e7eb;
}

/* Nút Info (Icon i) */
.tv-chip-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 3px 8px 3px 6px;
    /* Trái hẹp, phải rộng */
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s;
    height: 100%;
    /* Full chiều cao chip */
}

.tv-chip-info:hover {
    color: var(--tv-accent);
    background-color: #f3f4f6;
}

.tv-chip-info svg {
    width: 15px;
    height: 15px;
}

/* Responsive Mobile Meta Box */
@media (max-width: 600px) {
    .tv-doc-meta {
        padding: 12px 16px;
        gap: 16px;
    }

    .tv-meta-row {
        flex-direction: column;
        gap: 6px;
    }

    .tv-meta-label {
        min-width: auto;
        font-size: 0.75rem;
        padding-top: 0;
    }

    /* Tăng vùng bấm trên mobile cho dễ */
    .tv-chip-link {
        padding: 5px 10px 5px 14px;
    }

    .tv-chip-info {
        padding: 5px 12px 5px 8px;
    }
}

/* =========================================
   AUTO-INSERTED FEATURED IMAGE (UPDATED)
   ========================================= */

/* Style chung cho cả 3 chế độ */
img.cpt-thumb-right,
img.cpt-thumb-left,
img.cpt-thumb-center {
    /* Kích thước */
    max-height: 300px;
    max-width: 25%;
    width: auto;
    height: auto;
    object-fit: contain;

    /* Giao diện khung viền đẹp */
    border-radius: 16px;
    border: 4px solid #ffffff;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    background-color: #fff;

    /* Hiệu ứng */
    transition: transform 0.3s ease, box-shadow 0.3s ease;

    /* Fix layout flow */
    position: relative;
    z-index: 10;
}

/* Hover Effect chung */
:is(img.cpt-thumb-right, img.cpt-thumb-left, img.cpt-thumb-center):hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* 1. CĂN PHẢI (Default) */
img.cpt-thumb-right {
    float: right;
    margin: 6px 0 20px 24px;
    /* Cách chữ bên trái */
    clear: right;
}

/* 2. CĂN TRÁI */
img.cpt-thumb-left {
    float: left;
    margin: 6px 24px 20px 0;
    /* Cách chữ bên phải */
    clear: left;
}

/* 3. CĂN GIỮA */
img.cpt-thumb-center {
    float: none;
    display: block;
    margin: 20px auto;
    /* Căn giữa block */
    max-width: 40%;
    /* Cho phép rộng hơn chút khi ở giữa */
}

/* Responsive cho Tablet/Mobile (Reset về căn giữa hết) */
@media (max-width: 768px) {

    img.cpt-thumb-right,
    img.cpt-thumb-left,
    img.cpt-thumb-center {
        float: none;
        display: block;
        margin: 0 auto 24px auto;
        max-width: 100%;
        /* Full width trên mobile */
        max-height: 400px;
    }
}