/**
 * Shared Components CSS
 * Common styles for WDM shortcodes to reduce redundancy
 */

/* Common Layout */
.wdm-shared-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.wdm-shared-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.wdm-shared-data {
    padding: 20px;
}

/* Controls Section */
.wdm-shared-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    flex-wrap: wrap;
    gap: 15px;
}

.wdm-controls-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.wdm-controls-right {
    display: flex;
    gap: 10px;
}

/* Search Box */
.wdm-search-box {
    position: relative;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    min-width: 350px;
}

.wdm-search-box .dashicons {
    color: #666;
    margin-right: 8px;
}

.wdm-search-input {
    border: none;
    outline: none;
    background: transparent;
    width: -webkit-fill-available;
    font-size: 14px;
}

.wdm-search-input::placeholder {
    color: #999;
}

/* Per Page Selector */
.wdm-per-page-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wdm-per-page-label {
    font-size: 14px;
    color: #666;
}

.wdm-per-page-select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
}

/* Download Buttons */
.wdm-download-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.wdm-download-btn:hover {
    background: #005a87;
}

.wdm-download-btn .dashicons {
    font-size: 16px;
}

/* Grid Layout */
.wdm-shared-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Card Styling */
.wdm-shared-card {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    gap: 20px;
    transition: box-shadow 0.2s, transform 0.2s;
    min-height: 200px;
}

.wdm-shared-card:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.wdm-card-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wdm-card-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
    min-width: 120px;
}

/* Card Title */
.wdm-card-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

/* Description */
.wdm-description {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin: 0;
}

/* Links */
.wdm-link-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.wdm-link-item .dashicons {
    color: #0073aa;
    font-size: 16px;
}

.wdm-link-item a {
    color: #0073aa;
    text-decoration: none;
    word-break: break-all;
}

.wdm-link-item a:hover {
    text-decoration: underline;
}

/* Badges */
.wdm-badge {
    background: #0073aa;
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Contact Info */
.wdm-contact-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.wdm-contact-info .dashicons {
    color: #666;
    font-size: 16px;
}

.wdm-contact-info a {
    color: #0073aa;
    text-decoration: none;
    word-break: break-all;
}

.wdm-contact-info a:hover {
    text-decoration: underline;
}

/* Linked Items */
.wdm-linked-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wdm-items-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wdm-item-link {
    display: inline-block;
    background: #f0f7ff;
    color: #0073aa;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    text-decoration: none;
    transition: background-color 0.2s;
}

.wdm-item-link:hover {
    background: #e0f0ff;
    text-decoration: none;
}

/* No Results */
.wdm-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
    grid-column: 1 / -1;
}

/* Pagination */
.wdm-total-entries {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    flex-wrap: wrap;
    gap: 15px;
}

.wdm-entries-info {
    font-size: 14px;
    color: #666;
}

.wdm-pagination {
    display: flex;
    gap: 5px;
}

.wdm-pagination button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: #fff;
    color: #333;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

.wdm-pagination button:hover:not(:disabled) {
    background: #f0f0f0;
    border-color: #999;
}

.wdm-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wdm-pagination button.current-page {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

/* Admin Only Controls */
.wdm-admin-only {
    justify-content: flex-end;
}

/* Loading State */
.wdm-shared-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}

.wdm-shared-grid.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Fade In Animation */
.wdm-shared-card {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .wdm-shared-wrap {
        padding: 10px;
    }
    
    .wdm-shared-data {
        padding: 15px;
    }
    
    .wdm-shared-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .wdm-controls-left {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .wdm-search-box {
        min-width: auto;
    }
    
    .wdm-shared-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .wdm-shared-card {
        flex-direction: column;
        gap: 15px;
        min-height: auto;
    }
    
    .wdm-card-right {
        align-items: flex-start;
        min-width: auto;
    }
    
    .wdm-total-entries {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .wdm-pagination {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .wdm-shared-controls {
        padding: 15px;
    }
    
    .wdm-shared-data {
        padding: 10px;
    }
    
    .wdm-shared-card {
        padding: 15px;
    }
    
    .wdm-card-title {
        font-size: 16px;
    }
    
    .wdm-description {
        font-size: 13px;
    }
}