/* Resource Library Addon Styles */

.resource-library-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #333;
    line-height: 1.6;
}

.resource-library-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.resource-library-description {
    font-size: 1.1rem;
    color: #666;
    text-align: center;
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Filters */
.resource-library-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.resource-search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.resource-search-wrapper input {
    width: 100%;
    padding: 12px 48px 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 50px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.resource-search-wrapper input:focus {
    border-color: #007cba;
    box-shadow: 0 4px 20px rgba(0, 124, 186, 0.2);
}

.resource-search-wrapper .search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #007cba;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.resource-search-wrapper .search-btn:hover {
    background: #005a87;
    transform: translateY(-50%) scale(1.1);
}

.resource-category-wrapper select {
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    min-width: 200px;
}

.resource-category-wrapper select:focus {
    border-color: #007cba;
    box-shadow: 0 4px 20px rgba(0, 124, 186, 0.2);
}

/* Grid Layout */
.resource-library-grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.resource-library-grid.columns-1 {
    grid-template-columns: 1fr;
}

.resource-library-grid.columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.resource-library-grid.columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.resource-library-grid.columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Resource Cards */
.resource-card {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.resource-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: scaleX(0);
    transition: transform 0.3s ease;
    z-index: 1;
}

.resource-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.2);
    border-color: #007cba;
}

.resource-card:hover::before {
    transform: scaleX(1);
}

/* A4 Ratio Cover */
.resource-cover {
    width: 100%;
    aspect-ratio: 210/297; /* A4 ratio */
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-bottom: 1px solid #e1e5e9;
    overflow: hidden;
}

.resource-cover .pdf-preview {
    width: 80%;
    height: 80%;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
}

.resource-cover .pdf-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--icon-color, #dc3545);
}

/* PDF Cover Image */
.resource-cover .pdf-cover-image {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    /* Force high-quality rendering */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.resource-cover .pdf-cover-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    /* Optimize image quality and prevent blurriness */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: optimizeQuality;
    image-rendering: high-quality;
    -ms-interpolation-mode: bicubic;
    /* Prevent compression artifacts */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Additional quality improvements */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    /* Prevent pixelation on scaling */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Force hardware acceleration for better rendering */
    will-change: transform;
    /* Disable browser image optimization that causes blur */
    -webkit-optimize-contrast: auto;
    /* Maximum quality settings */
    max-width: none;
    max-height: none;
    /* Prevent any automatic resizing */
    min-width: 100%;
    min-height: 100%;
}

/* Card Size Variations */
.resource-cards-small .resource-cover {
    aspect-ratio: 210/250; /* Reduced height for small */
}

.resource-cards-small .resource-content {
    padding: 0.75rem;
}

.resource-cards-small .resource-title {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.resource-cards-small .resource-description {
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.resource-cards-small .resource-meta {
    gap: 0.25rem;
}

.resource-cards-small .resource-meta span {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
}

.resource-cards-medium .resource-cover {
    aspect-ratio: 210/297; /* Standard A4 */
}

.resource-cards-large .resource-cover {
    aspect-ratio: 210/350; /* Taller for large */
}

.resource-cards-large .resource-content {
    padding: 1.5rem;
}

.resource-cards-large .resource-title {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
}

.resource-cards-large .resource-description {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* Responsive adjustments for card sizes */
@media (max-width: 768px) {
    .resource-cards-small .resource-cover {
        aspect-ratio: 210/280;
    }
    
    .resource-cards-medium .resource-cover {
        aspect-ratio: 210/320;
    }
    
    .resource-cards-large .resource-cover {
        aspect-ratio: 210/360;
    }
}

/* Content visibility adjustments */
.resource-content:empty {
    display: none;
}

.resource-meta:empty {
    display: none;
}

/* When no title or description, adjust card layout */
.resource-card:has(.resource-content:empty) {
    .resource-cover {
        border-radius: 8px 8px 8px 8px;
    }
}

/* Compact layout when minimal content */
.resource-cards-small .resource-card:not(:has(.resource-description)) .resource-content {
    padding: 0.5rem 0.75rem;
}

.resource-cover .pdf-icon {
    margin-bottom: 0.5rem;
}

.resource-cover .pdf-title {
    text-align: center;
    color: #666;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.2;
}

.resource-cover .featured-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #333;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 2;
}

.resource-cover .download-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 124, 186, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.resource-card:hover .download-overlay {
    opacity: 1;
}

.resource-cover .download-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.resource-content {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.resource-icon {
    display: none; /* Hide since we now have the cover */
}

.resource-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    line-height: 1.4;
}

.resource-description {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.resource-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.resource-size,
.resource-category {
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 500;
}

.resource-size {
    background: #e3f2fd;
    color: #1976d2;
}

.resource-category {
    background: #f3e5f5;
    color: #7b1fa2;
}

.resource-actions {
    display: none; /* Remove download button section */
}

.resource-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #007cba;
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    width: 100%;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.3);
}

.resource-download-btn:hover {
    background: #005a87;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 124, 186, 0.4);
    color: white;
    text-decoration: none;
}

.resource-download-btn svg {
    transition: transform 0.3s ease;
}

.resource-download-btn:hover svg {
    transform: translateY(2px);
}

/* Loading State */
.resource-loading {
    text-align: center;
    padding: 3rem 1rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* No Resources State */
.no-resources {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
    font-size: 1.1rem;
    grid-column: 1 / -1;
}

.no-resources::before {
    content: '📂';
    display: block;
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .resource-library-grid.columns-3,
    .resource-library-grid.columns-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .resource-library-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .resource-search-wrapper,
    .resource-category-wrapper select {
        max-width: none;
        width: 100%;
    }

    .resource-library-title {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .resource-library-grid.columns-2,
    .resource-library-grid.columns-3,
    .resource-library-grid.columns-4 {
        grid-template-columns: 1fr;
    }

    .resource-card {
        padding: 1rem;
    }

    .resource-library-title {
        font-size: 1.75rem;
    }

    .resource-meta {
        justify-content: center;
    }
}

/* Animation for cards appearing */
.resource-card {
    animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for multiple cards */
.resource-card:nth-child(1) { animation-delay: 0.1s; }
.resource-card:nth-child(2) { animation-delay: 0.2s; }
.resource-card:nth-child(3) { animation-delay: 0.3s; }
.resource-card:nth-child(4) { animation-delay: 0.4s; }
.resource-card:nth-child(5) { animation-delay: 0.5s; }
.resource-card:nth-child(6) { animation-delay: 0.6s; }

/* Focus styles for accessibility */
.resource-search-wrapper input:focus,
.resource-category-wrapper select:focus,
.resource-download-btn:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .resource-card {
        border-color: #000;
        border-width: 2px;
    }
    
    .resource-download-btn {
        border: 2px solid #fff;
    }
}
