/**
 * Geely VOC Video Library Styles
 * TikTok / Reels / Xiaohongshu Feed UI
 * Mobile Optimized: Perfect spacing, smooth horizontal tabs, no text overlapping
 */

:root {
    --geely-voc-primary: #0a1e3f;
    --geely-voc-accent: #0076fe;
    --geely-voc-text-title: #111827;
    --geely-voc-text-sub: #4b5563;
    --geely-voc-text-time: #9ca3af;
    --geely-voc-radius: 10px;
}

.geely-voc-wrapper {
    display: block !important;
    position: relative !important;
    z-index: 1 !important;
    isolation: isolate !important;
    clear: both !important;
    width: 100% !important;
    max-width: 1680px;
    margin: 0 auto;
    padding: 20px 12px 30px 12px;
    box-sizing: border-box;
    min-height: min-content !important;
    overflow: visible !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.geely-voc-wrapper::after {
    content: "";
    display: table;
    clear: both;
}

/* Elementor container safety rules to prevent height collapse */
.elementor-widget-shortcode:has(.geely-voc-wrapper),
.elementor-widget-container:has(.geely-voc-wrapper),
.elementor-shortcode:has(.geely-voc-wrapper) {
    height: auto !important;
    min-height: min-content !important;
    overflow: visible !important;
    display: block !important;
    width: 100% !important;
}

/* =========================================
   1. Filter Tabs (Bộ lọc chủ đề)
   ========================================= */
.geely-voc-filter-wrap {
    margin-bottom: 24px;
    position: relative;
    width: 100%;
}

.geely-voc-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
}

.geely-voc-tab-btn {
    appearance: none;
    -webkit-appearance: none;
    background: #f3f4f6;
    border: 1px solid transparent;
    color: #4b5563;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    outline: none;
    flex-shrink: 0;
}

.geely-voc-tab-btn:hover {
    background: #e5e7eb;
    color: #111827;
}

.geely-voc-tab-btn.is-active {
    background: #111827;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Visibility toggles for Desktop vs Tablet/Mobile */
.geely-voc-desktop-only {
    display: flex !important;
}
.geely-voc-mobile-only {
    display: none !important;
}

/* Dropdown Container for Tablet & Mobile */
.geely-voc-dropdown-wrap {
    width: 100%;
    display: flex;
    align-items: center;
}

.geely-voc-select-custom {
    position: relative;
    width: 100%;
    max-width: 360px;
}

.geely-voc-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 100%;
    background: #ffffff;
    border: 1.5px solid #d1d5db;
    border-radius: 24px;
    padding: 10px 42px 10px 18px;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    cursor: pointer;
    outline: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.geely-voc-select:hover {
    border-color: #9ca3af;
}

.geely-voc-select:focus {
    border-color: var(--geely-voc-accent);
    box-shadow: 0 0 0 3px rgba(0, 118, 254, 0.15);
}

.geely-voc-select-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #6b7280;
    display: flex;
    align-items: center;
}

.geely-voc-select-arrow svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* =========================================
   2. Grid Layout (6 columns on Desktop)
   ========================================= */
.geely-voc-grid {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr);
    gap: 18px 12px;
    width: 100% !important;
    box-sizing: border-box !important;
    min-height: min-content !important;
    clear: both !important;
    margin-bottom: 24px !important;
    transition: opacity 0.2s ease;
}

.geely-voc-grid.is-loading {
    opacity: 0.5;
    pointer-events: none;
}

/* =========================================
   3. Card Item (Reels / TikTok Style)
   ========================================= */
.geely-voc-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    background: transparent;
    transition: transform 0.2s ease;
    min-width: 0; /* Cho phép co giãn flex an toàn */
    position: relative;
    isolation: isolate; /* Cách ly z-index bên trong card */
}

.geely-voc-card:hover {
    transform: translateY(-4px);
}

/* 3.1 Thumbnail Container - 100% Coverage */
.geely-voc-thumb-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: var(--geely-voc-radius);
    overflow: hidden;
    background: #111827;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* Bắt buộc ảnh lấp đầy 100% diện tích khung card, ghi đè toàn bộ CSS của theme */
.geely-voc-thumb-wrap img.geely-voc-thumb-img,
.geely-voc-thumb-wrap img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center center !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    transition: transform 0.35s ease !important;
}

.geely-voc-card:hover .geely-voc-thumb-wrap img.geely-voc-thumb-img,
.geely-voc-card:hover .geely-voc-thumb-wrap img {
    transform: scale(1.04) !important;
}

/* Gradient overlay ở đáy thumbnail để làm nổi bật số Like và Icon tim */
.geely-voc-thumb-gradient {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 40%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0.15) 60%, rgba(0, 0, 0, 0) 100%);
    pointer-events: none;
    z-index: 2;
}

/* Views Count Overlay (Góc dưới trái thumbnail - Đếm lượt click xem thực tế) */
.geely-voc-views,
.geely-voc-likes {
    position: absolute;
    bottom: 8px;
    left: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4.5px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
    z-index: 3;
    pointer-events: none;
    line-height: 1;
}

.geely-voc-views svg,
.geely-voc-likes svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: #ffffff;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: block;
}

/* Badge Nền tảng (Góc trên phải thumbnail) */
.geely-voc-platform-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    z-index: 3;
}

.geely-voc-platform-icon svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

/* 3.2 Card Content Below Thumbnail */
.geely-voc-info {
    padding: 8px 2px 2px 2px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

/* Video Title / Caption: Tối đa đúng 2 dòng, dài hơn thì ... */
.geely-voc-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--geely-voc-text-title);
    line-height: 1.35;
    margin: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    max-height: calc(1.35em * 2);
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    overflow-wrap: break-word;
    transition: color 0.2s ease;
}

.geely-voc-card:hover .geely-voc-title {
    color: var(--geely-voc-accent);
}

/* Short Quote / Mô tả ngắn: Tối đa 2 dòng, thừa thì ... (Text thẳng bình thường) */
.geely-voc-quote {
    font-size: 12px;
    line-height: 1.35;
    color: #64748b;
    margin: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    max-height: calc(1.35em * 2);
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: normal;
}

/* Author Row (Avatar + Name + Time) */
.geely-voc-author-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    gap: 4px;
    min-width: 0;
}

.geely-voc-author {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
    min-width: 0; /* Rất quan trọng để ellipsis hoạt động không đẩy vỡ layout */
}

.geely-voc-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e2e8f0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9.5px;
    font-weight: 700;
    color: #475569;
    overflow: hidden;
}

.geely-voc-author-name {
    color: var(--geely-voc-text-sub);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    font-size: 11.5px;
}

.geely-voc-time {
    color: var(--geely-voc-text-time);
    font-size: 11px;
    flex-shrink: 0;
    white-space: nowrap;
}

/* =========================================
   4. Actions (Xem thêm / Load More)
   ========================================= */
.geely-voc-actions {
    text-align: center;
    margin-top: 35px;
}

.geely-voc-loadmore-btn {
    appearance: none;
    -webkit-appearance: none;
    background: #ffffff;
    border: 1px solid #d1d5db;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
    padding: 9px 28px;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    outline: none;
}

.geely-voc-loadmore-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #111827;
}

.geely-voc-loadmore-btn.is-loading {
    opacity: 0.65;
    cursor: not-allowed;
}

.geely-voc-spinner {
    width: 15px;
    height: 15px;
    border: 2px solid #6b7280;
    border-top-color: transparent;
    border-radius: 50%;
    animation: geely-voc-spin 0.7s linear infinite;
    display: none;
}

.geely-voc-loadmore-btn.is-loading .geely-voc-spinner {
    display: inline-block;
}

@keyframes geely-voc-spin {
    to { transform: rotate(360deg); }
}

.geely-voc-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
    font-size: 15px;
}

/* =========================================
   5. Responsive Breakpoints (Mobile / Tablet)
   ========================================= */
@media (max-width: 1024px) {
    /* Chuyển Tabs thành Dropdown trên Tablet & Mobile */
    .geely-voc-desktop-only {
        display: none !important;
    }
    .geely-voc-mobile-only {
        display: flex !important;
    }

    .geely-voc-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px 12px;
    }
}

@media (max-width: 768px) {
    .geely-voc-wrapper {
        padding: 16px 10px 48px 10px !important;
        margin-bottom: 40px !important;
        min-height: min-content !important;
        clear: both !important;
    }

    .geely-voc-filter-wrap {
        margin-bottom: 18px;
    }

    /* Dropdown chiếm trọn 100% chiều rộng trên Mobile để dễ bấm */
    .geely-voc-select-custom {
        max-width: 100%;
    }
    
    .geely-voc-select {
        padding: 9px 38px 9px 16px;
        font-size: 13.5px;
    }

    .geely-voc-filter-wrap::after {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 36px;
        background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
        pointer-events: none;
        z-index: 2;
    }

    .geely-voc-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 8px;
        padding-right: 40px; /* Khoảng trống để tab cuối không bị cụt */
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .geely-voc-filters::-webkit-scrollbar {
        display: none;
    }

    .geely-voc-tab-btn {
        padding: 6px 13px;
        font-size: 12.5px;
    }

    /* Grid 2 cột tinh chỉnh khoảng cách để tránh bị widget bên phải che */
    .geely-voc-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px 8px !important;
        padding-right: 2px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        min-height: min-content !important;
        clear: both !important;
        margin-bottom: 24px !important;
    }

    .geely-voc-title {
        font-size: 12.5px;
        line-height: 1.3;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        max-height: calc(1.3em * 2);
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .geely-voc-quote {
        font-size: 11px;
        line-height: 1.35;
    }

    .geely-voc-author-row {
        font-size: 10.5px;
    }

    .geely-voc-author-name {
        font-size: 10.5px;
        max-width: 75px; /* Giới hạn để luôn chừa chỗ cho thời gian hiển thị đầy đủ */
    }

    .geely-voc-time {
        font-size: 10px;
    }

    .geely-voc-views,
    .geely-voc-likes {
        font-size: 11px;
        bottom: 6px;
        left: 6px;
        gap: 3.5px;
    }

    .geely-voc-views svg,
    .geely-voc-likes svg {
        width: 12px;
        height: 12px;
    }

    .geely-voc-platform-icon {
        width: 20px;
        height: 20px;
        top: 6px;
        right: 6px;
    }
}
