/* Enhanced Whitepapers Styling - Brand-Aligned Design */
.whitepaper-item {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    background: #ffffff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    height: 620px;
    border: 1px solid #e9ecef;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transform: translateZ(0);
    will-change: transform, box-shadow;
}

/* Only apply hover effects on devices that support hover (desktop/laptop) */
@media (hover: hover) and (pointer: fine) {
    .whitepaper-item:hover {
        transform: translateY(-8px);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        height: 620px;
        border-color: rgba(222, 52, 127, 0.2);
    }
}

/* Make the entire whitepaper item clickable */
.grid-item a.whitepaper-full-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.whitepaper-image {
    position: relative;
    overflow: hidden;
    height: 260px;
    /* Fixed height for image area */
}

.whitepaper-image img {
    width: 100%;
    height: 260px;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), filter 0.3s ease;
    filter: brightness(0.98);
}

@media (hover: hover) and (pointer: fine) {
    .whitepaper-item:hover .whitepaper-image img {
        transform: scale(1.05);
        filter: brightness(1.02);
    }
}

.whitepaper-category {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    color: #1d1d1f;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    z-index: 3;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
}

/* Template Type Badges */
.whitepaper-template-type {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 3;
}

.template-type-badge {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    color: #1d1d1f;
    padding: 5px 11px;
    border-radius: 16px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.4px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.template-type-badge i {
    font-size: 10px;
}

/* Template type specific colors - Brand palette */
.template-type-badge.research {
    background: rgba(222, 52, 127, 0.1);
    color: #de347f;
    border: 1px solid rgba(222, 52, 127, 0.2);
}

.template-type-badge.industry {
    background: rgba(255, 93, 116, 0.1);
    color: #ff5d74;
    border: 1px solid rgba(255, 93, 116, 0.2);
}

.template-type-badge.technical {
    background: #f8f9fa;
    color: #424245;
    border: 1px solid #e9ecef;
}

.template-type-badge.solution {
    background: linear-gradient(135deg, #f8f9ff, #fff5f8);
    color: #de347f;
    border: 1px solid #e3e8ff;
}

.whitepaper-content {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2;
    background: #ffffff;
}

.whitepaper-author {
    font-size: 11px;
    font-weight: 700;
    color: #de347f;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    line-height: 1.2;
}

.whitepaper-title {
    font-size: 20px;
    font-weight: 600;
    color: #1d1d1f;
    line-height: 1.35;
    margin-bottom: 12px;
    text-decoration: none;
    display: block;
    position: relative;
    z-index: 2;
    transition: color 0.3s ease;
    letter-spacing: -0.5px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.whitepaper-title:hover {
    color: #de347f;
    text-decoration: none;
}

.whitepaper-subtitle {
    font-size: 14px;
    color: #6c757d;
    line-height: 1.6;
    margin-bottom: 16px;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.whitepaper-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 20px;
    padding-top: 14px;
    border-top: 1px solid #e9ecef;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #6c757d;
    font-weight: 500;
}

.meta-item i {
    font-size: 12px;
    color: #de347f;
}

.read-whitepaper-btn {
    background: linear-gradient(135deg, #de347f, #ff5d74);
    color: #ffffff;
    padding: 12px 26px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    z-index: 2;
    border: none;
    cursor: pointer;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-top: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

@media (hover: hover) and (pointer: fine) {
    .read-whitepaper-btn:hover {
        background: linear-gradient(135deg, #c92d6f, #de347f);
        transform: translateY(-2px);
        box-shadow: 0 6px 24px rgba(222, 52, 127, 0.3);
        color: #ffffff;
        text-decoration: none;
    }
}

/* Whitepapers header styling */
.whitepapers-header {
    background: linear-gradient(135deg, #190B26 0%, #2D1B69 50%, #8B5CF6 100%);
    position: relative;
    overflow: hidden;
}

/* Filter styling for whitepapers */
.portfolio-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding: 0;
    margin: 0;
}

.portfolio-filter li {
    list-style: none;
    margin: 0;
}

.portfolio-filter li a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid #e9ecef;
    color: #6c757d;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.portfolio-filter li a i {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.portfolio-filter li a .filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 12px;
    background: rgba(222, 52, 127, 0.1);
    color: #de347f;
    font-size: 12px;
    font-weight: 700;
    margin-left: 4px;
}

/* Increased specificity to ensure override of mobile styles */
.portfolio-filter.nav-tabs li.active a,
.portfolio-filter.nav-tabs li a:hover {
    color: #ffffff;
    background: linear-gradient(135deg, #de347f, #ff5d74);
    border-color: #de347f;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.portfolio-filter.nav-tabs li.active a .filter-count,
.portfolio-filter.nav-tabs li a:hover .filter-count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.portfolio-filter.nav-tabs li.active a i,
.portfolio-filter.nav-tabs li a:hover i {
    transform: scale(1.1);
}

/* Mobile filter adjustments */
/* Mobile filter adjustments - Horizontal Scroll */
@media (max-width: 991px) {
    .portfolio-filter.nav-tabs {
        display: flex;
        flex-wrap: nowrap !important;
        /* Force single line */
        overflow-x: auto;
        justify-content: flex-start !important;
        /* Force start alignment */
        gap: 12px;
        -webkit-overflow-scrolling: touch;

        /* Safer edge-to-edge for mobile (avoids 100vw scrollbar bug) */
        width: auto;
        margin-left: -15px;
        margin-right: -15px;
        padding: 5px 15px 20px 15px;
        /* Inner padding keeps content off edge */

        /* Hide scrollbars */
        scrollbar-width: none;
        -ms-overflow-style: none;

        border-bottom: 0;
        /* Remove default nav-tabs border */
    }

    .portfolio-filter.nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .portfolio-filter.nav-tabs li {
        flex: 0 0 auto;
        /* Don't shrink */
        width: auto;
    }

    .portfolio-filter.nav-tabs li a {
        padding: 10px 18px;
        font-size: 14px;
        white-space: nowrap;
        background: #f8f9fa;
        border-radius: 20px;
        border: 1px solid #e9ecef;
        margin-right: 0;
        /* Bootstrap override */
    }

    .portfolio-filter li a i {
        font-size: 14px;
    }

    .portfolio-filter li.active a {
        box-shadow: 0 4px 12px rgba(222, 52, 127, 0.2);
    }

    /* Active count style updates for mobile */
    .portfolio-filter li a .filter-count {
        min-width: 20px;
        height: 20px;
        font-size: 11px;
        padding: 0 6px;
    }
}

@media (max-width: 575px) {
    .portfolio-filter {
        gap: 6px;
    }

    .portfolio-filter li a {
        padding: 6px 12px;
        font-size: 12px;
    }

    .portfolio-filter li a i {
        font-size: 12px;
    }
}

/* Responsive adjustments */
@media (max-width: 1199px) {
    .whitepaper-item {
        height: auto;
        min-height: 550px;
    }
}

@media (max-width: 991px) {
    .whitepaper-item {
        height: auto;
        min-height: 520px;
    }

    .whitepaper-image {
        height: 240px;
    }

    .whitepaper-image img {
        height: 240px;
    }

    .whitepaper-content {
        padding: 20px;
    }

    .whitepaper-title {
        font-size: 19px;
    }
}

@media (max-width: 767px) {

    /* Force 1 column grid on mobile */
    .portfolio-wrapper.grid-3col,
    .portfolio-wrapper.xxl-grid-3col,
    .portfolio-wrapper.xl-grid-3col,
    .portfolio-wrapper.lg-grid-3col,
    .portfolio-wrapper.md-grid-2col,
    .portfolio-wrapper.sm-grid-2col {
        display: block !important;
    }

    .portfolio-wrapper .grid-item {
        width: 100% !important;
        margin-bottom: 20px;
    }

    /* Disable all hover effects on mobile */
    .whitepaper-item {
        height: auto !important;
        min-height: 480px;
        transform: none !important;
    }

    .whitepaper-item:hover {
        transform: none !important;
        height: auto !important;
    }

    .whitepaper-image {
        height: 220px;
    }

    .whitepaper-image img {
        height: 220px;
        transform: none !important;
    }

    .whitepaper-content {
        padding: 18px;
        background: #ffffff;
        /* Ensure solid background on mobile */
    }

    .whitepaper-author {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .whitepaper-title {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .whitepaper-subtitle {
        font-size: 13px;
        margin-bottom: 14px;
    }

    .whitepaper-meta {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 16px;
    }

    .meta-item {
        font-size: 12px;
    }

    .read-whitepaper-btn {
        font-size: 12px;
        padding: 10px 20px;
    }
}

@media (max-width: 575px) {
    .whitepaper-item {
        min-height: 450px;
        border-radius: 16px;
    }

    .whitepaper-image {
        height: 200px;
    }

    .whitepaper-image img {
        height: 200px;
    }

    .whitepaper-content {
        padding: 16px;
    }

    .whitepaper-category {
        font-size: 10px;
        padding: 5px 12px;
    }

    .template-type-badge {
        font-size: 9px;
        padding: 3px 8px;
    }
}

/* Loading states */
.whitepaper-item.loading {
    opacity: 0.7;
    pointer-events: none;
}

.whitepaper-item.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #8B5CF6;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Grid adjustments for whitepapers */
.portfolio-wrapper .grid-item {
    margin-bottom: 40px;
}

/* Ensure proper grid spacing on all devices */
@media (max-width: 1399px) {
    .portfolio-wrapper .grid-item {
        margin-bottom: 35px;
    }
}

@media (max-width: 991px) {
    .portfolio-wrapper .grid-item {
        margin-bottom: 30px;
    }
}

@media (max-width: 767px) {
    .portfolio-wrapper .grid-item {
        margin-bottom: 25px;
    }
}

@media (max-width: 575px) {
    .portfolio-wrapper .grid-item {
        margin-bottom: 20px;
    }
}

/* Professional gradient container for whitepapers header */
.whitepapers-header .professional-gradient-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}