/* File: assets/css/lelib-card.css */

/* =========================================
   CARD CORE LAYOUT
   ========================================= */
.tv-card { 
    position: relative;
    border: 1px solid #e5e7eb; 
    border-radius: 16px; 
    /* Popup hiển thị tràn ra ngoài card */
    overflow: visible; 
    display: flex; flex-direction: column; 
    transition: transform 0.3s; 
    background: #fff;
    height: 100%;
}

.tv-card:hover { 
    transform: translateY(-4px); 
    box-shadow: 0 12px 24px -6px rgba(0,0,0,0.12); 
    border-color: #d1d5db; 
    /* Tăng z-index khi hover để popup đè lên các card khác */
    z-index: 100; 
}

.tv-thumb-wrapper { 
    position: relative; 
    display: block; 
    aspect-ratio: 16/9; 
    overflow: hidden; 
    /* Bo góc ảnh thủ công vì Card đã bỏ overflow:hidden */
    border-radius: 15px 15px 0 0;
}

/* =========================================
   INFO TRIGGER (Icon "i" góc phải trên Card)
   ========================================= */
.tv-info-trigger {
    position: absolute;
    top: 10px; right: 10px;
    z-index: 50; 
    
    opacity: 0; visibility: hidden;
    transform: translateY(-5px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    padding-bottom: 10px; margin-bottom: -10px;
}

.tv-card:hover .tv-info-trigger {
    opacity: 1; visibility: visible; transform: translateY(0);
}

@media (hover: none) {
    .tv-info-trigger {
        opacity: 1 !important; 
        visibility: visible !important; 
        transform: translateY(0) !important;
    }
}

.tv-info-icon {
    width: 28px; height: 28px;
    background: rgba(0, 0, 0, 0.6); 
    backdrop-filter: blur(4px);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: help;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    transition: background 0.2s;
    position: relative; z-index: 2;
}
.tv-info-trigger:hover .tv-info-icon { background: var(--tv-accent, #2563eb); } 

/* =========================================
   INFO TOOLTIP (Popup Menu Card)
   ========================================= */
.tv-info-popup {
    position: absolute;
    top: 100%; right: 0; 
    margin-top: 2px;
    width: 240px; 
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 10px 30px -5px rgba(0,0,0,0.2), 0 5px 10px -5px rgba(0,0,0,0.1);
    
    opacity: 0; visibility: hidden;
    transform: translateY(5px);
    transition: all 0.2s ease;
    
    text-align: left; color: #374151; z-index: 100;
}
.tv-info-popup::after {
    content: ""; position: absolute; bottom: 100%; left: 0; width: 100%; height: 15px; background: transparent;
}
.tv-info-trigger:hover .tv-info-popup {
    opacity: 1; visibility: visible; transform: translateY(0); pointer-events: auto; 
}
.tv-info-group { margin-bottom: 10px; }
.tv-info-group:last-child { margin-bottom: 0; }
.tv-info-label {
    display: block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: #9ca3af; 
    margin-bottom: 4px; border-bottom: 1px solid #f3f4f6; padding-bottom: 2px;
}
.tv-info-list { margin: 0; padding: 0 0 0 16px; list-style-type: disc; font-size: 0.85rem; line-height: 1.5; }
.tv-info-list li { margin-bottom: 4px; }
.tv-info-list a {
    color: #374151; text-decoration: none; transition: color 0.2s; border-bottom: 1px solid transparent;
}
.tv-info-list a:hover {
    color: var(--tv-accent, #2563eb);
    border-bottom-color: var(--tv-accent, #2563eb);
}
.tv-info-popup::before {
    content: ""; position: absolute; bottom: 100%; right: 9px; 
    border-width: 5px; border-style: solid; border-color: transparent transparent #fff transparent; pointer-events: none;
}

/* =========================================
   AVATAR & TOOLTIP
   ========================================= */
.tv-avatars {
    position: absolute; bottom: 12px; left: 12px;
    display: flex; align-items: center; z-index: 5;
    pointer-events: none;
}
.tv-avatar-item {
    position: relative; margin-right: -8px;
    z-index: 1; pointer-events: auto;
    width: 32px; height: 32px; 
}
.tv-avatar-item:hover { z-index: 100; } 

a.tv-avatar-link {
    display: block; width: 100%; height: 100%;
    border-radius: 50%; text-decoration: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.tv-avatar-img {
    width: 100%; height: 100%;
    border-radius: 50%;
    border: 2px solid #fff; background-size: cover; background-position: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transition: transform 0.2s;
    background-color: #fff;
    display: block; 
}
.tv-avatar-item:hover .tv-avatar-img { transform: scale(1.1); }
.tv-avatar-item--more .tv-avatar-img {
    background: #e5e7eb; display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; color: #6b7280;
}

a.tv-avatar-tooltip, span.tv-avatar-tooltip {
    position: absolute; bottom: 100%; left: 0; 
    transform: none; margin-bottom: 8px; 
    display: flex; align-items: center; gap: 6px;
    background: rgba(255, 255, 255, 0.98); 
    backdrop-filter: blur(4px);
    color: var(--tv-accent, #2563eb); border: 1px solid var(--tv-accent, #2563eb);
    padding: 6px 10px; border-radius: 20px;
    font-size: 0.75rem; font-weight: 600;
    white-space: nowrap; text-decoration: none;
    width: max-content; max-width: 200px; height: auto; 
    opacity: 0; visibility: hidden; 
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    cursor: pointer;
}
a.tv-avatar-tooltip:hover { background: #ffffff; box-shadow: 0 6px 20px rgba(0,0,0,0.15); }
a.tv-avatar-tooltip::after, span.tv-avatar-tooltip::after {
    content: ""; position: absolute; top: 100%; left: 16px; margin-left: -5px; 
    border-width: 5px; border-style: solid;
    border-color: var(--tv-accent, #2563eb) transparent transparent transparent;
}
a.tv-avatar-tooltip::before, span.tv-avatar-tooltip::before {
    content: ""; position: absolute; top: 100%; left: 0; right: 0; height: 10px; background: transparent;
}
.tv-tooltip-icon { display: flex; align-items: center; justify-content: center; margin-right: 4px; opacity: 0.8; }
.tv-avatar-item:hover a.tv-avatar-tooltip,
.tv-avatar-item:active a.tv-avatar-tooltip,
.tv-avatar-item:focus-within a.tv-avatar-tooltip { 
    opacity: 1; visibility: visible; transform: translateY(-2px); 
}

/* =========================================
   BODY CONTENT
   ========================================= */
.tv-card-body { padding: 16px; display: flex; flex-direction: column; flex: 1; }
.tv-card-title {
    font-size: 1.05rem; font-weight: 700; color: #111827; 
    line-height: 1.4; margin: 0 0 12px 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, #2563eb); }
.tv-card-indicators {
    display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 8px; border-top: 1px solid #f9fafb;
}
.tv-ind-item {
    display: flex; align-items: center; justify-content: center; color: #9ca3af; cursor: help; transition: color 0.2s;
}
.tv-ind-item svg { width: 16px; height: 16px; }
.tv-ind-item:hover { color: var(--tv-accent, #2563eb); }

/* =========================================
   CUSTOM POPUP NAV (Button + Grid Tooltip)
   ========================================= */
.tv-custom-nav {
    position: relative;
    margin-left: auto; z-index: 20; 
}

.tv-nav-trigger {
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 99px;
    padding: 4px 28px 4px 12px;
    font-size: 13px; font-weight: 600; color: #64748b;
    line-height: 1.4; cursor: pointer; user-select: none;
    transition: all 0.2s ease; white-space: nowrap;
    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='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.6rem center;
    background-repeat: no-repeat;
    background-size: 1em 1em;
}

.tv-nav-trigger:hover, 
.tv-custom-nav:hover .tv-nav-trigger {
    border-color: var(--tv-accent, #2563eb);
    color: var(--tv-accent, #2563eb);
    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='%232563eb' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.tv-nav-popup {
    position: absolute;
    bottom: 100%; right: 0;
    margin-bottom: 8px;
    width: 200px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    opacity: 0; visibility: hidden; transform: translateY(5px);
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
    cursor: default;
    
    /* KHÔNG ĐẶT OVERFLOW Ở ĐÂY để giữ mũi tên */
}

.tv-nav-popup::after {
    content: ""; position: absolute; top: 100%; right: 0; width: 100%; height: 10px; background: transparent;
}
.tv-nav-popup::before {
    content: ""; position: absolute; top: 100%; right: 14px;
    border-width: 7px; border-style: solid;
    border-color: #e5e7eb transparent transparent transparent; z-index: -1;
}

.tv-custom-nav:hover .tv-nav-popup {
    opacity: 1; visibility: visible; transform: translateY(0);
}

.tv-nav-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    
    /* [CẬP NHẬT] Max-height 260px = khoảng 30 items (6 rows + intro) */
    max-height: 260px;
    overflow-y: auto;
    
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
    
    padding-right: 2px;
}

/* Scrollbar Webkit Styles */
.tv-nav-grid::-webkit-scrollbar { width: 6px; }
.tv-nav-grid::-webkit-scrollbar-track { background: #f1f5f9; }
.tv-nav-grid::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 3px; }

.tv-nav-item {
    display: flex; align-items: center; justify-content: center;
    aspect-ratio: 1/1; 
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 12px; font-weight: 600; color: #4b5563;
    text-decoration: none;
    transition: all 0.15s;
    background-color: #f8fafc;
}
.tv-nav-item:hover {
    border-color: var(--tv-accent, #2563eb);
    background-color: var(--tv-accent, #2563eb);
    color: #fff;
}
.tv-nav-item--wide {
    grid-column: 1 / -1; 
    aspect-ratio: auto;
    padding: 6px;
    margin-bottom: 4px;
    text-transform: uppercase;
    font-size: 11px;
}

.tv-card-excerpt {
    font-size: 0.85rem; color: #6b7280; line-height: 1.5; margin-bottom: 12px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis;
}

/* =========================================================
   SIDEBAR STYLES
   ========================================================= */
.tv-facet-item label.tv-facet-label { display: flex; align-items: center; justify-content: space-between; width: 100%; cursor: pointer; }
.tv-facet-left { display: flex; align-items: center; flex: 1; min-width: 0; padding-right: 8px; }
.tv-side-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-facet-right { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-shrink: 0; position: relative; min-width: 30px; }
.tv-facet-info {
    display: inline-flex; align-items: center; justify-content: center; color: #9ca3af; 
    cursor: pointer; transition: all 0.2s; opacity: 0; visibility: hidden; transform: translateX(-5px);
}
.tv-facet-info:hover { color: var(--tv-accent, #2563eb); transform: scale(1.1); }
@media (hover: hover) {
    .tv-facet-item:hover .tv-count { display: none; }
    .tv-facet-item:hover .tv-facet-info { opacity: 1; visibility: visible; transform: translateX(0); }
}
@media (hover: none) {
    .tv-facet-right { gap: 8px; }
    .tv-facet-info { opacity: 1 !important; visibility: visible !important; transform: none !important; padding: 4px; margin: -4px; }
}