/**
 * Itsourcecode Popular Widgets - Frontend Styles
 * Brand colors: #1F3A5F (deep blue), #C9A961 (gold), #2D6A4F (green)
 */

/* ========================================
   POPULAR POSTS LIST
   ======================================== */
.itsc-pw-popular-list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: pw-counter;
}

.itsc-pw-popular-item {
    margin: 0 0 12px;
    padding: 0;
    border: none;
    list-style: none;
}

.itsc-pw-popular-item:last-child {
    margin-bottom: 0;
}

.itsc-pw-item-inner {
    display: flex;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    background: transparent;
    transition: background 0.2s ease, transform 0.2s ease;
    align-items: flex-start;
    position: relative;
}

.itsc-pw-item-inner:hover {
    background: rgba(31, 58, 95, 0.04);
    transform: translateX(2px);
}

/* Rank Number */
.itsc-pw-rank {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    background: #C9A961;
    color: #1F3A5F;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 2;
}

.itsc-pw-popular-item:nth-child(1) .itsc-pw-rank {
    background: #FFD700;
    color: #1F3A5F;
}

.itsc-pw-popular-item:nth-child(2) .itsc-pw-rank {
    background: #C0C0C0;
    color: #1F3A5F;
}

.itsc-pw-popular-item:nth-child(3) .itsc-pw-rank {
    background: #CD7F32;
    color: white;
}

/* Thumbnails */
.itsc-pw-thumb-link {
    flex-shrink: 0;
    display: block;
    width: 70px;
    height: 70px;
    overflow: hidden;
    border-radius: 6px;
    background: #f0f0f0;
    position: relative;
}

.itsc-pw-thumb {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    transition: transform 0.3s ease;
    border-radius: 6px;
    box-shadow: none !important;
}

.itsc-pw-thumb-link:hover .itsc-pw-thumb {
    transform: scale(1.08);
}

.itsc-pw-no-thumb {
    background: linear-gradient(135deg, #1F3A5F 0%, #2D6A4F 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
}

.itsc-pw-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Item Content */
.itsc-pw-item-content {
    flex: 1;
    min-width: 0;
    padding-left: 8px;
}

.itsc-pw-popular-list.no-thumbnails .itsc-pw-item-content {
    padding-left: 18px;
}

.itsc-pw-item-title {
    margin: 0 0 4px;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    color: #1F3A5F;
}

.itsc-pw-item-title a {
    color: inherit;
    text-decoration: none;
    display: block;
    transition: color 0.2s ease;

    /* Limit to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.itsc-pw-item-title a:hover,
.itsc-pw-item-title a:focus {
    color: #2D6A4F;
}

.itsc-pw-item-excerpt {
    font-size: 12px;
    line-height: 1.5;
    color: #666;
    margin: 4px 0 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Item Meta */
.itsc-pw-item-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    font-size: 11px;
    color: #888;
    margin-top: 4px;
}

.itsc-pw-views,
.itsc-pw-date {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.itsc-pw-views svg,
.itsc-pw-date svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.itsc-pw-views {
    color: #C9A961;
    font-weight: 600;
}

/* ========================================
   POPULAR CATEGORIES - LIST STYLE
   ======================================== */
.itsc-pw-categories-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.itsc-pw-category-item {
    margin: 0 0 6px;
    padding: 0;
    border: none;
    list-style: none;
}

.itsc-pw-category-item:last-child {
    margin-bottom: 0;
}

.itsc-pw-category-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    background: transparent;
    color: #1F3A5F;
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.itsc-pw-category-link:hover,
.itsc-pw-category-link:focus {
    background: rgba(201, 169, 97, 0.08);
    border-left-color: #C9A961;
    padding-left: 14px;
    color: #2D6A4F;
}

.itsc-pw-category-icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.itsc-pw-category-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.itsc-pw-category-count {
    background: #1F3A5F;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
    transition: background 0.2s ease;
}

.itsc-pw-category-link:hover .itsc-pw-category-count {
    background: #2D6A4F;
}

/* ========================================
   POPULAR CATEGORIES - GRID STYLE
   ======================================== */
.itsc-pw-categories-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.itsc-pw-category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 8px;
    border-radius: 8px;
    background: #fafafa;
    text-decoration: none;
    color: #1F3A5F;
    transition: all 0.2s ease;
    border: 1px solid #e0e0e0;
}

.itsc-pw-category-card:hover,
.itsc-pw-category-card:focus {
    background: #fff;
    border-color: #C9A961;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    color: #2D6A4F;
}

.itsc-pw-category-card-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.itsc-pw-category-card-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 2px;
}

.itsc-pw-category-card-count {
    font-size: 10px;
    color: #888;
}

/* ========================================
   POPULAR CATEGORIES - CLOUD STYLE
   ======================================== */
.itsc-pw-categories-cloud {
    line-height: 2;
}

.itsc-pw-cloud-item {
    display: inline-block;
    padding: 4px 10px;
    margin: 2px;
    border-radius: 14px;
    background: #fafafa;
    color: #1F3A5F;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid #e0e0e0;
}

.itsc-pw-cloud-item:hover,
.itsc-pw-cloud-item:focus {
    background: #1F3A5F;
    color: white;
    border-color: #1F3A5F;
    transform: scale(1.05);
}

.itsc-pw-cloud-item sup {
    font-size: 0.7em;
    opacity: 0.7;
    margin-left: 2px;
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

.itsc-pw-popular-list a:focus-visible,
.itsc-pw-categories-list a:focus-visible,
.itsc-pw-category-card:focus-visible,
.itsc-pw-cloud-item:focus-visible {
    outline: 3px solid #C9A961;
    outline-offset: 2px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .itsc-pw-thumb-link {
        width: 60px;
        height: 60px;
    }

    .itsc-pw-item-title {
        font-size: 13px;
    }

    .itsc-pw-categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .itsc-pw-category-card-icon {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .itsc-pw-categories-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   REDUCED MOTION
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .itsc-pw-item-inner,
    .itsc-pw-thumb,
    .itsc-pw-category-link,
    .itsc-pw-category-card,
    .itsc-pw-cloud-item {
        transition: none;
    }

    .itsc-pw-thumb-link:hover .itsc-pw-thumb,
    .itsc-pw-category-card:hover,
    .itsc-pw-cloud-item:hover {
        transform: none;
    }
}
