/* ============================================================
 * MODERN UI PACKAGE - Card Design & Components
 * Version: 1.0.0
 * Description: Modern card design với shadow, hover effects, badges
 * ============================================================ */

/* ====================
 * 1. MODERN CARD DESIGN
 * ==================== */

.img-wrap {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #fff;
    margin-bottom: 20px;
}

.img-wrap:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.img-wrap img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.img-wrap:hover img {
    transform: scale(1.08);
}

/* Gradient Overlay */
.img-wrap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 0%, transparent 50%, rgba(0, 0, 0, 0.7) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.img-wrap:hover::before {
    opacity: 1;
}

.img-wrap .caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.7) 70%, transparent 100%);
    color: #fff;
    z-index: 2;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.img-wrap .caption h6 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ====================
 * 2. BADGES & LABELS
 * ==================== */

.story-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.badge-item {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    display: inline-block;
    animation: badgeFadeIn 0.4s ease;
}

@keyframes badgeFadeIn {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.badge-new {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.badge-hot {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.badge-full {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: #fff;
}

.badge-updating {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: #fff;
}

/* Chapter Count Badge (Bottom Left) */
.chapter-count {
    position: absolute;
    bottom: 52px;
    left: 10px;
    z-index: 3;
    padding: 5px 12px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chapter-count i {
    font-size: 12px;
}

/* ====================
 * 3. SKELETON LOADING
 * ==================== */

.skeleton-card {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: #f0f0f0;
    margin-bottom: 20px;
}

.skeleton-img {
    width: 100%;
    height: 280px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-caption {
    padding: 15px 12px;
}

.skeleton-line {
    height: 14px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-line:last-child {
    width: 70%;
    margin-bottom: 0;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ====================
 * 4. EMPTY STATE
 * ==================== */

.empty-state {
    text-align: center;
    padding: 80px 20px;
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-radius: 16px;
    margin: 40px 0;
}

.empty-state-icon {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 16px;
    color: #666;
    margin-bottom: 20px;
}

.empty-state .btn {
    margin: 5px;
}

/* ====================
 * 5. VIEW MODES
 * ==================== */

/* Grid View (Default) */
.view-mode-grid .story-item {
    /* Default styles already defined above */
}

/* List View */
.view-mode-list .story-item {
    margin-bottom: 20px;
}

.view-mode-list .img-wrap {
    display: flex;
    border-radius: 8px;
    height: 150px;
    margin-bottom: 0;
}

.view-mode-list .img-wrap img {
    width: 110px;
    height: 150px;
    object-fit: cover;
    border-radius: 8px 0 0 8px;
}

.view-mode-list .img-wrap .caption {
    position: relative;
    flex: 1;
    background: #fff;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-radius: 0 8px 8px 0;
}

.view-mode-list .img-wrap .caption h6 {
    text-align: left;
    font-size: 16px;
    margin-bottom: 8px;
    color: #333;
    text-shadow: none;
}

.view-mode-list .story-meta {
    display: block;
    font-size: 13px;
    color: #666;
    margin-top: 5px;
}

.view-mode-list .story-meta span {
    margin-right: 15px;
}

/* Compact View */
.view-mode-compact .img-wrap {
    border-radius: 6px;
    margin-bottom: 15px;
}

.view-mode-compact .img-wrap img {
    height: 200px;
}

.view-mode-compact .caption h6 {
    font-size: 13px;
    padding: 10px 8px;
}

/* ====================
 * 6. RESPONSIVE DESIGN
 * ==================== */

/* Desktop Large (1200px+) */
@media (min-width: 1200px) {
    .story-grid .col-story {
        width: 16.666667%; /* 6 columns */
    }
}

/* Desktop (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .story-grid .col-story {
        width: 20%; /* 5 columns */
    }
}

/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .story-grid .col-story {
        width: 25%; /* 4 columns */
    }
    
    .img-wrap img {
        height: 240px;
    }
}

/* Mobile Large (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .story-grid .col-story {
        width: 33.333333%; /* 3 columns */
    }
    
    .img-wrap img {
        height: 220px;
    }
    
    .img-wrap .caption h6 {
        font-size: 13px;
    }
}

/* Mobile Small (< 576px) */
@media (max-width: 575px) {
    .story-grid .col-story {
        width: 50%; /* 2 columns */
    }
    
    .img-wrap {
        border-radius: 8px;
        margin-bottom: 15px;
    }
    
    .img-wrap img {
        height: 200px;
    }
    
    .img-wrap .caption {
        padding: 12px 10px;
    }
    
    .img-wrap .caption h6 {
        font-size: 12px;
    }
    
    .badge-item {
        font-size: 10px;
        padding: 3px 8px;
    }
    
    .chapter-count {
        font-size: 10px;
        padding: 4px 10px;
        bottom: 46px;
    }
}

/* ====================
 * 7. LAZY LOADING STYLES
 * ==================== */

.img-wrap img.lazy {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 280px;
}

.img-wrap img.lazy.loaded {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Blur placeholder effect */
.img-wrap img[data-original] {
    filter: blur(5px);
    transition: filter 0.3s ease;
}

.img-wrap img.loaded {
    filter: blur(0);
}

/* ====================
 * 8. PORTLET ENHANCEMENTS
 * ==================== */

.portlet.light.modern {
    border: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    overflow: hidden;
}

.portlet.light.modern .portlet-title {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px 25px;
    border-bottom: none;
}

.portlet.light.modern .portlet-title .caption {
    color: #fff;
}

.portlet.light.modern .portlet-title .caption i {
    color: #fff;
    font-size: 20px;
}

.portlet.light.modern .portlet-title .caption .caption-subject {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
}

.portlet.light.modern .portlet-body {
    padding: 30px 25px;
}

/* ====================
 * 9. SCROLL TO TOP BUTTON
 * ==================== */

.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

/* ====================
 * 10. PERFORMANCE OPTIMIZATIONS
 * ==================== */

/* GPU Acceleration */
.img-wrap,
.img-wrap img,
.badge-item,
.scroll-to-top {
    will-change: transform;
    transform: translateZ(0);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
