/**
 * Public styles for Resources Manager plugin
 */

/* Resources Listing Container */
.resources-listing-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Filters Section */
.resources-filters {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: end;
    margin-bottom: 15px;
}

.filters-row:last-child {
    margin-bottom: 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 150px;
    flex: 1;
}

.filter-group label {
    font-weight: 600;
    margin-bottom: 5px;
    color: #495057;
    font-size: 14px;
}

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: #007cba;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 124, 186, 0.25);
}


/* Layout Toggle */
.layout-toggle {
    display: flex;
    gap: 5px;
}

.layout-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px;
    border: 1px solid #ced4da;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    font-size: 14px;
    color: #acabab;
}

.layout-btn:hover {
    background: #6A953F;
    border-color: #6A953F;
}

.layout-btn.active {
    background: #6A953F;
    border-color: #6A953F;
    color: #fff;
}

.layout-btn .dashicons {
    font-size: 24px;
    line-height: 1;
    width: 24px;
    height: 24px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    margin: 2px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: all 0.15s ease-in-out;
}

.btn-primary {
    color: #fff;
    background-color: #6A953F;
    border-color: #6A953F;
}

.btn-primary:hover {
    color: #fff;
    background-color: #AAAD00;
    border-color: #AAAD00;
    text-decoration: none;
}

.btn-secondary {
    color: #495057;
    background-color: #6c757d;
    border-color: #6c757d;
}

.btn-secondary:hover {
    color: #fff;
    background-color: #545b62;
    border-color: #4e555b;
    text-decoration: none;
}

/* Resources Container */
.resources-results {
    margin-top: 20px;
    position: relative;
}

.resources-container {
    margin-bottom: 30px;
}

/* Grid Layout */
.resources-container.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.resource-item.grid-layout {
    display: flex;
    flex-direction: column;
}

.resource-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.resource-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.resource-thumbnail {
    position: relative;
    overflow: hidden;
}

.resource-thumbnail img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.placeholder-image {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.resource-card:hover .resource-thumbnail img {
    transform: scale(1.05);
}

.featured-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #fff;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
}

.resource-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.resource-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 12px;
    color: #6c757d;
}

.resource-type {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.resource-title {
    margin: 0 0 10px 0;
    font-size: 18px;
    line-height: 1.3;
}

.resource-title a {
    color: #212529;
    text-decoration: none;
    transition: color 0.15s ease-in-out;
}

.resource-title a:hover {
    color: #007cba;
}

.resource-excerpt {
    color: #6c757d;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 15px;
    flex: 1;
}

.resource-taxonomies {
    margin-bottom: 15px;
    font-size: 13px;
}

.resource-countries,
.resource-sectors {
    margin-bottom: 5px;
}

.resource-taxonomies strong {
    color: #495057;
    margin-right: 5px;
}

.tax-term {
    display: inline-block;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 2px 6px;
    margin: 2px;
    border-radius: 3px;
    font-size: 12px;
    color: #495057;
}

.resource-actions {
    margin-top: auto;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* List Layout */
.resources-container.list-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.resource-item.list-layout {
    display: block;
}

.resource-list-item {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    transition: box-shadow 0.2s ease-in-out;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.resource-list-item:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}


.resource-thumbnail-small {
    flex-shrink: 0;
    position: relative;
}

.resource-thumbnail-small img {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 4px;
}

.resource-thumbnail-small .placeholder-image {
    width: 120px;
    height: 90px;
    border-radius: 4px;
}

.resource-list-item .resource-content {
    flex: 1;
}

/* Featured Resources */
.resource-item.featured .resource-card,
.resource-item.featured .resource-list-item {
    border-color: #6A953F;
    border-width: 2px;
}

.resource-item.featured .featured-badge {
    background: #6A953F;
    color: #fff;
}

/* Load More */
.load-more-container {
    text-align: center;
    margin-top: 30px;
}

.load-more-btn {
    padding: 12px 30px;
    font-size: 16px;
    min-width: 200px;
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* No Results */
.no-more-resources {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .resources-listing-container {
        padding: 15px;
    }

    .resources-filters {
        padding: 15px;
    }

    .filters-row {
        flex-direction: column;
        gap: 15px;
    }

    .filters-row.mobile-stacked .filter-group {
        min-width: auto;
    }

    .layout-toggle {
        flex-direction: row;
        justify-content: center;
    }

    .resources-container.grid-layout {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .resource-list-item {
        flex-direction: column;
        gap: 15px;
    }

    .resource-thumbnail-small {
        align-self: center;
    }

    .resource-thumbnail-small img,
    .resource-thumbnail-small .placeholder-image {
        width: 100%;
        height: 150px;
        max-width: 300px;
    }

    .resource-actions {
        flex-direction: column;
    }

    .btn {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .resources-listing-container {
        padding: 10px;
    }

    .resource-card,
    .resource-list-item {
        margin: 0 -10px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .resource-content,
    .resource-list-item {
        padding: 15px;
    }

    .resource-thumbnail img {
        height: 150px;
    }
}

/* Loading States */
.resources-container.loading {
    opacity: 0.6;
    pointer-events: none;
}

.resources-loading-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 999;
    justify-content: center;
    align-items: center;
}

.resources-loading-overlay.active {
    display: flex;
}

.resources-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #6A953F;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: auto;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

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

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus States */
.btn:focus,
.layout-btn:focus,
input:focus,
select:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .resources-filters,
    .load-more-container {
        display: none;
    }

    .resource-card,
    .resource-list-item {
        break-inside: avoid;
        border: 1px solid #000;
        margin-bottom: 20px;
    }

    .resources-container.grid-layout {
        grid-template-columns: 1fr 1fr;
    }
}

/* Download Tracking Modal */
.resources-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.resources-modal-container {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    margin: auto;
    position: relative;
    top: 50%;
    transform: translateY(-50%);
}

.resources-modal-header {
    background: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.resources-modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.resources-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    transition: color 0.3s;
}

.resources-modal-close:hover {
    color: #333;
}

.resources-modal-body {
    padding: 30px 20px;
}

.resources-modal-body p {
    margin-bottom: 20px;
    color: #666;
}

/* Success/Error Messages */
.resources-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 5px;
    color: #fff;
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-width: 400px;
}

.resources-message.resources-success {
    background: #28a745;
}

.resources-message.resources-error {
    background: #dc3545;
}

/* Modal Responsive */
@media (max-width: 768px) {
    .resources-modal-container {
        width: 95%;
        max-height: 85vh;
    }

    .resources-modal-header {
        padding: 15px;
    }

    .resources-modal-body {
        padding: 20px 15px;
    }

    .resources-message {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spinner-rotate 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 5px;
}

@keyframes spinner-rotate {
    to { transform: rotate(360deg); }
}

.results-counter {
    text-align: center;
}

/* Algolia Autocomplete Customization */
.aa-Autocomplete {
    width: 100%;
}

.aa-Form {
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
}

.aa-Input {
    padding: 8px 12px !important;
    font-size: 14px !important;
}

.aa-Input:focus {
    border-color: #007cba !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 124, 186, 0.25) !important;
}

.aa-Panel {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    max-height: 500px;
    overflow-y: auto;
}

.aa-Item {
    padding: 10px !important;
    border-bottom: 1px solid #f0f0f0;
}

.aa-Item:last-child {
    border-bottom: none;
}

.aa-ItemLink {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #212529;
}

.aa-ItemContent {
    display: flex;
    align-items: flex-start;
    width: 100%;
    gap: 12px;
}

.aa-ItemIcon--picture {
    flex-shrink: 0;
}

.aa-ItemIcon--picture img {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
}

.aa-ItemContentBody {
    flex: 1;
}

.aa-ItemContentTitle {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.aa-ItemContentType {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
}

.aa-ItemContentFeatured {
    background: #6A953F;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.aa-ItemContentDescription {
    font-size: 13px;
    color: #6c757d;
    margin-top: 4px;
    line-height: 1.4;
}

/* Highlighted text in search results */
mark.aa-Mark {
    background-color: #fff3cd;
    color: #212529;
    font-weight: 600;
    padding: 0 2px;
}

.aa-Item[aria-selected="true"] {
    background-color: #f8f9fa;
}

.aa-Item[aria-selected="true"] .aa-ItemLink {
    color: #007cba;
}

/* No results message */
.aa-NoResultsQuery {
    font-weight: 600;
}

/* Loading state */
.aa-LoadingIndicator {
    color: #6A953F;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .aa-Panel {
        max-height: 400px;
    }

    .aa-ItemIcon--picture img {
        width: 50px;
        height: 38px;
    }

    .aa-ItemContentTitle {
        font-size: 14px;
    }

    .aa-ItemContentDescription {
        font-size: 12px;
    }
}
