/* --- Wrapper --- */
.pdflist-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1f2937; /* gray-800 */
    margin-bottom: 2rem;
    box-sizing: border-box;
}
.pdflist-wrapper * {
    box-sizing: border-box;
}

/* --- Header --- */
.pdflist-header {
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}
.pdflist-title {
    font-size: 1.5rem; /* 2xl */
    font-weight: 700;
    color: #1f2937;
    margin: 0;
    letter-spacing: -0.025em;
}

/* --- Filter Bar (Horizontal) --- */
.pdflist-filters {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap; /* Wraps on mobile */
    gap: 1rem;
    align-items: center;
}

.pdflist-filter-group {
    flex: 1;
    min-width: 200px; /* Forces wrap on mobile */
}

.pdflist-search-group {
    flex-grow: 2; /* Search bar wider */
}

.pdflist-search-input,
.pdflist-filter-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: #fff;
    color: #374151;
    height: 40px; /* Uniform height */
}
.pdflist-search-input:focus,
.pdflist-filter-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

.pdflist-reset-btn {
    padding: 0.5rem 1rem;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    color: #374151;
    cursor: pointer;
    font-size: 0.875rem;
    height: 40px;
    font-weight: 500;
}
.pdflist-reset-btn:hover {
    color: #dc2626;
    background: #fef2f2;
    border-color: #fee2e2;
}

/* Loading Spinner */
.pdflist-loader {
    display: flex; justify-content: center; padding: 2rem;
}
.pdflist-spinner {
    width: 40px; height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* No Results */
.pdflist-no-results {
    text-align: center; padding: 3rem 1rem; color: #6b7280; font-style: italic;
    background: #fff; border: 1px dashed #d1d5db; border-radius: 0.75rem;
}
.pdflist-no-results-inner {
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.pdflist-icon-gray { color: #9ca3af; }

/* --- Layout Systems --- */
.pdflist-flex-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Grid Layout & Responsive Logic */
.pdflist-grid-layout {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr; /* Mobile: 1 Column */
}

@media (min-width: 640px) {
    .pdflist-grid-layout {
        grid-template-columns: repeat(2, 1fr); /* Tablet: 2 Columns */
    }
}

@media (min-width: 1024px) {
    .pdflist-grid-layout {
        /* Desktop: Uses CSS Var from PHP, defaults to 3 */
        grid-template-columns: repeat(var(--desktop-cols, 3), 1fr);
    }
}

/* --- Card Styles --- */
.pdflist-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem; /* rounded-xl */
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.pdflist-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: #bfdbfe; /* blue-200 */
    transform: translateY(-2px);
}

/* Card Inner Layout */
.pdflist-card-inner {
    padding: 1.25rem; /* p-5 */
    display: flex;
    flex-direction: column; /* Mobile: Stack */
    gap: 1.25rem;
    height: 100%;
}

/* Responsive Inner Layout (Specific for List View) */
.pdflist-vertical .pdflist-card-inner {
    flex-direction: column;
}
@media (min-width: 640px) {
    .pdflist-vertical .pdflist-card-inner {
        flex-direction: row; /* Tablet+ List View: Row */
        align-items: flex-start;
    }
}

/* --- Elements --- */
.pdflist-icon-box {
    width: 3.5rem; /* w-14 */
    height: 3.5rem; /* h-14 */
    flex-shrink: 0;
    background: #fef2f2; /* red-50 */
    color: #dc2626; /* red-600 */
    border-radius: 0.75rem;
    border: 1px solid #fee2e2;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pdflist-card:hover .pdflist-icon-box {
    background-color: #fee2e2; /* red-100 */
}

.pdflist-details {
    flex-grow: 1;
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.pdflist-file-title {
    font-size: 1.125rem; /* lg */
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.5rem 0;
    line-height: 1.375;
    word-break: break-word; /* Ensure wrapping */
}
.pdflist-card:hover .pdflist-file-title { color: #1d4ed8; }

.pdflist-info {
    font-size: 0.75rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.pdflist-badge-gray {
    background: #f3f4f6;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    color: #4b5563;
}

.pdflist-divider {
    margin: 0 0.5rem;
    color: #d1d5db;
}

.pdflist-downloads {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.3s;
}

/* Tags */
.pdflist-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.pdflist-badge {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px; /* Pill */
    border: 1px solid transparent;
}

.pdflist-cat {
    background: #eff6ff; /* blue-50 */
    color: #2563eb; /* blue-600 */
    border-color: #dbeafe;
}
.pdflist-tag {
    background: #f9fafb; /* gray-50 */
    color: #4b5563; /* gray-600 */
    border-color: #e5e7eb;
}

/* Actions */
.pdflist-actions {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
    width: 100%; /* Mobile: Full width */
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid #f3f4f6;
}

/* Responsive Actions logic matches Angular */
.pdflist-vertical .pdflist-actions {
    border-top: 1px solid #f3f4f6; /* Mobile stack gets border */
    padding-top: 1rem;
}
@media (min-width: 640px) {
    .pdflist-vertical .pdflist-actions {
        width: auto;
        flex-direction: column;
        border-top: none;
        padding-top: 0;
        margin-left: 1rem;
    }
}

.pdflist-btn {
    flex: 1; /* Mobile: equal width */
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
    transition: all 0.2s;
}

.pdflist-btn-preview {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #4b5563;
}
.pdflist-btn-preview:hover {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.pdflist-btn-download {
    background: #111827; /* gray-900 */
    border: 1px solid #111827;
    color: #fff;
}
.pdflist-btn-download:hover {
    background: #1f2937;
    color: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

@media (min-width: 640px) {
    .pdflist-btn { flex: none; }
}

/* Pagination */
.pdflist-pagination-controls {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
}

.pdflist-page-btn {
    padding: 0.5rem 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}
.pdflist-page-btn:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #2563eb;
}
.pdflist-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.pdflist-modal {
    position: fixed; inset: 0; z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.pdflist-modal-overlay {
    position: absolute; inset: 0;
    background: rgba(17, 24, 39, 0.6); /* gray-900 / 60% */
    backdrop-filter: blur(2px);
}
.pdflist-modal-container {
    background: #fff;
    width: 100%; max-width: 900px; height: 85vh;
    z-index: 100000;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.pdflist-modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f3f4f6;
    display: flex; justify-content: space-between; align-items: center;
    background: #fff;
}
.pdflist-modal-title-wrap {
    display: flex; align-items: center; gap: 0.75rem; overflow: hidden;
}
.pdflist-modal-icon {
    background: #fef2f2; color: #dc2626; padding: 0.5rem; border-radius: 0.5rem;
}
.pdflist-modal-title {
    margin: 0; font-size: 1.125rem; font-weight: 700; color: #1f2937;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pdflist-modal-close {
    background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #9ca3af;
}
.pdflist-modal-close:hover { color: #1f2937; }
.pdflist-modal-body {
    flex-grow: 1; background: #f9fafb; position: relative; padding: 1rem;
}
.pdflist-modal-body iframe { width: 100%; height: 100%; border: 1px solid #e5e7eb; border-radius: 0.5rem; background: #fff; }
