/* ==========================================
   DNHS Document Library v3
   Modern Clean UI
========================================== */

.dnhs-dl-library-v2 {
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    color: #111827;
    padding: 0;
}

/* ---------- Header ---------- */

.dnhs-dl-header {
    margin-bottom: 28px;
}

.dnhs-dl-header h2 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
}

.dnhs-dl-header p {
    margin-top: 8px;
    color: #6b7280;
    font-size: 15px;
}

/* ---------- Search ---------- */

.dnhs-dl-search-minimal {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.dnhs-dl-search-wrapper {
    display: flex;
    gap: 12px;
    width: 100%;
}

.dnhs-dl-search-input-v2 {
    flex: 1;
    height: 50px;
    padding: 0 18px;
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    background: #fff;
    font-size: 15px;
    font-family: inherit;
    transition: 0.2s;
    -webkit-appearance: none;
}

.dnhs-dl-search-input-v2:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.dnhs-dl-search-input-v2::placeholder {
    color: #9ca3af;
}

.dnhs-dl-search-btn-v2 {
    height: 50px;
    padding: 0 24px;
    border: none;
    border-radius: 12px;
    background: #2563eb;
    color: white;
    font-weight: 600;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
    -webkit-font-smoothing: antialiased;
}

.dnhs-dl-search-btn-v2:hover {
    background: #1d4ed8;
}

.dnhs-dl-search-btn-v2:active {
    transform: scale(0.98);
}

/* ---------- Card & Table ---------- */

.dnhs-dl-table-container-v2 {
    background: #fff;
    border: 1px solid #edf2f7;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 24px;
}

.dnhs-dl-documents-table-v2 {
    width: 100%;
    border-collapse: collapse;
}

.dnhs-dl-documents-table-v2 thead {
    background: #f8fafc;
}

.dnhs-dl-documents-table-v2 th {
    text-align: left;
    padding: 18px 24px;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
}

.dnhs-dl-documents-table-v2 td {
    padding: 22px 24px;
    border-top: 1px solid #f1f5f9;
    vertical-align: middle;
    font-size: 15px;
    color: #111827;
}

.dnhs-dl-documents-table-v2 tbody tr {
    transition: 0.18s;
}

.dnhs-dl-documents-table-v2 tbody tr:hover {
    background: #f8fbff;
}

.dnhs-dl-documents-table-v2 tbody tr:nth-child(even) {
    background: #fcfcfd;
}

.dnhs-dl-documents-table-v2 tbody tr:last-child td {
    border-bottom: none;
}

/* ---------- Columns ---------- */

.col-id {
    color: #9ca3af;
    font-size: 13px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
}

.col-title {
    font-size: 15px;
    font-weight: 600;
    word-break: break-word;
}

.col-date {
    color: #6b7280;
    font-size: 14px;
}

.col-actions {
    text-align: right;
}

/* ---------- Loading ---------- */

.dnhs-dl-loading-row td {
    text-align: center;
    padding: 48px 24px;
    background: #f8fafc;
}

.dnhs-dl-spinner-v2 {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
    vertical-align: -4px;
}

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

/* ---------- Buttons ---------- */

.dnhs-dl-action-buttons {
    display: flex;
    gap: 10px;
}

.dnhs-dl-action-btn {
    padding: 9px 16px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: 0.2s;
    cursor: pointer;
    border: none;
    font-family: inherit;
    -webkit-font-smoothing: antialiased;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dnhs-dl-action-btn.view {
    border: 1px solid #dbe2ea;
    color: #374151;
    background: white;
}

.dnhs-dl-action-btn.view:hover {
    background: #f3f4f6;
}

.dnhs-dl-action-btn.download {
    background: #2563eb;
    color: white;
    border: none;
}

.dnhs-dl-action-btn.download:hover {
    background: #1d4ed8;
}

.dnhs-dl-action-btn:active {
    transform: scale(0.96);
}

/* ---------- Pagination ---------- */

.dnhs-dl-pagination-v2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-top: 1px solid #edf2f7;
    background: #fafafa;
    border-radius: 0 0 16px 16px;
    gap: 15px;
    flex-wrap: wrap;
}

.dnhs-dl-pagination-results {
    color: #6b7280;
    font-size: 14px;
}

.dnhs-dl-pagination-buttons {
    display: flex;
    gap: 8px;
}

.dnhs-dl-pagination-v2 a,
.dnhs-dl-pagination-v2 span {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    color: #374151;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s;
    background: white;
}

.dnhs-dl-pagination-v2 a:hover {
    background: #f3f4f6;
}

.dnhs-dl-pagination-v2 .current {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
    cursor: default;
}

.dnhs-dl-pagination-ellipsis {
    color: #9ca3af;
    cursor: default;
    padding: 0 4px;
}

/* ---------- Mobile ---------- */

@media (max-width: 768px) {
    .dnhs-dl-search-wrapper {
        flex-direction: column;
    }

    .dnhs-dl-search-btn-v2 {
        width: 100%;
    }

    .dnhs-dl-documents-table-v2 thead {
        display: none;
    }

    .dnhs-dl-documents-table-v2,
    .dnhs-dl-documents-table-v2 tbody,
    .dnhs-dl-documents-table-v2 tr,
    .dnhs-dl-documents-table-v2 td {
        display: block;
        width: 100%;
    }

    .dnhs-dl-documents-table-v2 tr {
        padding: 16px;
        margin-bottom: 12px;
        border: 1px solid #edf2f7;
        border-radius: 12px;
    }

    .dnhs-dl-documents-table-v2 td {
        border: none;
        padding: 6px 0;
    }

    .dnhs-dl-documents-table-v2 td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        display: block;
        margin-bottom: 4px;
    }

    .dnhs-dl-action-buttons {
        margin-top: 12px;
    }

    .dnhs-dl-pagination-v2 {
        flex-direction: column;
        border-radius: 0;
    }
}

@media (max-width: 480px) {
    .dnhs-dl-library-v2 {
        padding: 0;
    }

    .dnhs-dl-search-input-v2 {
        height: 48px;
        font-size: 16px;
        padding: 0 16px;
    }

    .dnhs-dl-search-btn-v2 {
        height: 48px;
    }

    .dnhs-dl-documents-table-v2 tr {
        padding: 12px;
    }

    .dnhs-dl-documents-table-v2 td {
        font-size: 14px;
        padding: 4px 0;
    }

    .col-id {
        font-size: 12px;
    }

    .dnhs-dl-action-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .dnhs-dl-pagination-v2 a,
    .dnhs-dl-pagination-v2 span {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }
}

/* ---------- Dark Mode ----------
   Scoped to an explicit .dnhs-dl-dark ancestor instead of a bare
   prefers-color-scheme query: a blind OS-level query fires even when
   the surrounding theme/page background stays light, leaving near-white
   text (#e8eaed) on a white card — invisible. Opt in per-site instead. */

.dnhs-dl-dark .dnhs-dl-library-v2 {
    color: #e8eaed;
}

.dnhs-dl-dark .dnhs-dl-search-input-v2 {
    background: #1f2937;
    border-color: #374151;
    color: #e8eaed;
}

.dnhs-dl-dark .dnhs-dl-search-input-v2::placeholder {
    color: #9ca3af;
}

.dnhs-dl-dark .dnhs-dl-table-container-v2 {
    background: #111827;
    border-color: #374151;
}

.dnhs-dl-dark .dnhs-dl-documents-table-v2 thead {
    background: #1f2937;
}

.dnhs-dl-dark .dnhs-dl-documents-table-v2 th {
    color: #b8bbbf;
    border-bottom-color: #374151;
}

.dnhs-dl-dark .dnhs-dl-documents-table-v2 td {
    color: #e8eaed;
    border-top-color: #374151;
}

.dnhs-dl-dark .dnhs-dl-documents-table-v2 tbody tr:hover {
    background: #1f2937;
}

.dnhs-dl-dark .dnhs-dl-documents-table-v2 tbody tr:nth-child(even) {
    background: #111827;
}

.dnhs-dl-dark .dnhs-dl-action-btn.view {
    background: #1f2937;
    border-color: #374151;
    color: #b8bbbf;
}

.dnhs-dl-dark .dnhs-dl-action-btn.view:hover {
    background: #374151;
    color: #e8eaed;
}

.dnhs-dl-dark .dnhs-dl-pagination-v2 {
    background: #1f2937;
    border-top-color: #374151;
}

.dnhs-dl-dark .dnhs-dl-pagination-results {
    color: #b8bbbf;
}

.dnhs-dl-dark .dnhs-dl-pagination-v2 a,
.dnhs-dl-dark .dnhs-dl-pagination-v2 span {
    background: #1f2937;
    border-color: #374151;
    color: #b8bbbf;
}

.dnhs-dl-dark .dnhs-dl-pagination-v2 a:hover {
    background: #374151;
}

.dnhs-dl-dark .col-id {
    color: #8a8d90;
}

.dnhs-dl-dark .col-date {
    color: #b8bbbf;
}

/* ---------- Accessibility ---------- */

@media (prefers-reduced-motion: reduce) {
    .dnhs-dl-search-input-v2,
    .dnhs-dl-search-btn-v2,
    .dnhs-dl-documents-table-v2 tbody tr,
    .dnhs-dl-action-btn,
    .dnhs-dl-pagination-v2 a {
        transition: none;
    }

    .dnhs-dl-spinner-v2 {
        animation: none;
        border-top-color: #2563eb;
    }

    .dnhs-dl-action-btn:active,
    .dnhs-dl-search-btn-v2:active {
        transform: none;
    }
}
