/*
 * Documents & Media Resource Library — Frontend Styles
 * ======================================================
 * Design aesthetic: Refined editorial with depth, clean typography,
 * smooth animations and a sophisticated blue-slate palette.
 */

/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
    --dml-blue:         #2563eb;
    --dml-blue-light:   #eff6ff;
    --dml-blue-dark:    #1d4ed8;
    --dml-green:        #16a34a;
    --dml-green-light:  #f0fdf4;
    --dml-red:          #dc2626;
    --dml-red-light:    #fef2f2;
    --dml-orange:       #ea580c;
    --dml-orange-light: #fff7ed;
    --dml-purple:       #7c3aed;
    --dml-gray-50:      #f8fafc;
    --dml-gray-100:     #f1f5f9;
    --dml-gray-200:     #e2e8f0;
    --dml-gray-300:     #cbd5e1;
    --dml-gray-400:     #94a3b8;
    --dml-gray-500:     #64748b;
    --dml-gray-600:     #475569;
    --dml-gray-700:     #334155;
    --dml-gray-800:     #1e293b;
    --dml-gray-900:     #0f172a;
    --dml-shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --dml-shadow:       0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.05);
    --dml-shadow-lg:    0 12px 40px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
    --dml-radius:       14px;
    --dml-radius-sm:    8px;
    --dml-radius-xs:    5px;
    --dml-transition:   0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --dml-font:         'Georgia', 'Times New Roman', serif;
    --dml-font-ui:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Library wrapper ───────────────────────────────────────────────────────── */
.dml-library {
    position: relative;
    font-family: var(--dml-font-ui);
    color: var(--dml-gray-800);
}

/* ── Toolbar ───────────────────────────────────────────────────────────────── */
.dml-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

/* ── Search input ──────────────────────────────────────────────────────────── */
.dml-search-wrap {
    position: relative;
    flex: 1;
    min-width: 220px;
}

.dml-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--dml-gray-400);
    font-size: 1rem;
    pointer-events: none;
    z-index: 2;
}

.dml-search-input {
    width: 100%;
    padding: 12px 44px 12px 44px;
    border: 2px solid var(--dml-gray-200);
    border-radius: 50px;
    font-size: 0.95rem;
    background: #fff;
    color: var(--dml-gray-800);
    transition: border-color var(--dml-transition), box-shadow var(--dml-transition);
    outline: none;
    font-family: var(--dml-font-ui);
}

.dml-search-input:focus {
    border-color: var(--dml-blue);
    box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}

.dml-search-input::placeholder { color: var(--dml-gray-400); }

.dml-search-spinner {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

/* ── Sort select ───────────────────────────────────────────────────────────── */
.dml-sort-select {
    padding: 12px 16px;
    border: 2px solid var(--dml-gray-200);
    border-radius: 50px;
    font-size: 0.9rem;
    background: #fff;
    color: var(--dml-gray-700);
    cursor: pointer;
    outline: none;
    transition: border-color var(--dml-transition);
    font-family: var(--dml-font-ui);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.dml-sort-select:focus { border-color: var(--dml-blue); }

/* ── Filter tabs ───────────────────────────────────────────────────────────── */
.dml-filter-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 4px;
}

.dml-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: 2px solid var(--dml-gray-200);
    border-radius: 50px;
    background: #fff;
    color: var(--dml-gray-600);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--dml-transition);
    white-space: nowrap;
    font-family: var(--dml-font-ui);
}

.dml-tab:hover {
    border-color: var(--dml-blue);
    color: var(--dml-blue);
    background: var(--dml-blue-light);
    transform: translateY(-1px);
}

.dml-tab.active {
    background: var(--dml-blue);
    border-color: var(--dml-blue);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.dml-tab-count {
    background: rgba(255,255,255,.25);
    border-radius: 50px;
    padding: 1px 8px;
    font-size: 0.78rem;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.dml-tab:not(.active) .dml-tab-count {
    background: var(--dml-gray-100);
    color: var(--dml-gray-500);
}

/* ── Results bar ───────────────────────────────────────────────────────────── */
.dml-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 0 4px;
}

.dml-results-count {
    font-size: 0.9rem;
    color: var(--dml-gray-500);
}

.dml-view-toggle {
    display: flex;
    gap: 4px;
    background: var(--dml-gray-100);
    border-radius: var(--dml-radius-sm);
    padding: 3px;
}

.dml-view-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--dml-gray-500);
    cursor: pointer;
    transition: all var(--dml-transition);
    font-size: 1rem;
}

.dml-view-btn.active,
.dml-view-btn:hover {
    background: #fff;
    color: var(--dml-blue);
    box-shadow: var(--dml-shadow-sm);
}

/* ── Resource card ─────────────────────────────────────────────────────────── */
.dml-card-resource {
    background: #fff;
    border-radius: var(--dml-radius);
    box-shadow: var(--dml-shadow-sm);
    border: 1px solid var(--dml-gray-200);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform var(--dml-transition), box-shadow var(--dml-transition), border-color var(--dml-transition);
    animation: dmlFadeUp 0.4s ease both;
}

.dml-card-resource:hover {
    transform: translateY(-5px);
    box-shadow: var(--dml-shadow-lg);
    border-color: var(--dml-blue);
}

/* stagger animation for initial load */
.dml-col:nth-child(1)  .dml-card-resource { animation-delay: 0.00s; }
.dml-col:nth-child(2)  .dml-card-resource { animation-delay: 0.05s; }
.dml-col:nth-child(3)  .dml-card-resource { animation-delay: 0.10s; }
.dml-col:nth-child(4)  .dml-card-resource { animation-delay: 0.15s; }
.dml-col:nth-child(5)  .dml-card-resource { animation-delay: 0.20s; }
.dml-col:nth-child(6)  .dml-card-resource { animation-delay: 0.25s; }
.dml-col:nth-child(7)  .dml-card-resource { animation-delay: 0.30s; }
.dml-col:nth-child(8)  .dml-card-resource { animation-delay: 0.35s; }
.dml-col:nth-child(9)  .dml-card-resource { animation-delay: 0.40s; }
.dml-col:nth-child(10) .dml-card-resource { animation-delay: 0.45s; }
.dml-col:nth-child(11) .dml-card-resource { animation-delay: 0.50s; }
.dml-col:nth-child(12) .dml-card-resource { animation-delay: 0.55s; }

@keyframes dmlFadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Thumbnail ─────────────────────────────────────────────────────────────── */
.dml-card-thumb {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: var(--dml-gray-100);
    flex-shrink: 0;
}

.dml-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.dml-card-resource:hover .dml-card-thumb img {
    transform: scale(1.06);
}

.dml-card-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    background: linear-gradient(135deg, var(--dml-gray-50), var(--dml-gray-100));
}

/* ── Type badge ────────────────────────────────────────────────────────────── */
.dml-type-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,.3);
}

.dml-badge-blue   { background: rgba(37,99,235,.85);  color: #fff; }
.dml-badge-green  { background: rgba(22,163,74,.85);  color: #fff; }
.dml-badge-red    { background: rgba(220,38,38,.85);  color: #fff; }
.dml-badge-orange { background: rgba(234,88,12,.85);  color: #fff; }
.dml-badge-gray   { background: rgba(100,116,139,.85);color: #fff; }

/* ── Card body ─────────────────────────────────────────────────────────────── */
.dml-card-body-resource {
    padding: 18px 20px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ── Category pills ────────────────────────────────────────────────────────── */
.dml-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.dml-cat-pill {
    display: inline-block;
    padding: 2px 10px;
    background: var(--dml-blue-light);
    color: var(--dml-blue);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ── Title ─────────────────────────────────────────────────────────────────── */
.dml-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
    margin: 0 0 8px;
    font-family: var(--dml-font-ui);
    color: var(--dml-gray-900);
}

.dml-card-title a {
    color: inherit;
    text-decoration: none;
    transition: color var(--dml-transition);
}

.dml-card-title a:hover { color: var(--dml-blue); }

/* ── Description ───────────────────────────────────────────────────────────── */
.dml-card-desc {
    font-size: 0.875rem;
    color: var(--dml-gray-500);
    line-height: 1.55;
    margin: 0 0 12px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Meta row ──────────────────────────────────────────────────────────────── */
.dml-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--dml-gray-400);
    padding-top: 10px;
    border-top: 1px solid var(--dml-gray-100);
    margin-top: auto;
}

.dml-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.dml-meta-item i { font-size: 0.85rem; }

/* ── Tags ──────────────────────────────────────────────────────────────────── */
.dml-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.dml-tag {
    font-size: 0.75rem;
    color: var(--dml-gray-400);
    transition: color var(--dml-transition);
    cursor: default;
}

.dml-tag:hover { color: var(--dml-blue); }

/* ── Action buttons ────────────────────────────────────────────────────────── */
.dml-card-actions {
    padding: 14px 20px 18px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid var(--dml-gray-100);
    background: var(--dml-gray-50);
}

.dml-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--dml-transition);
    text-decoration: none;
    border: 2px solid transparent;
    font-family: var(--dml-font-ui);
    white-space: nowrap;
    letter-spacing: 0.2px;
    flex: 1;
    min-width: 110px;
}

.dml-btn-primary {
    background: var(--dml-blue);
    color: #fff;
    border-color: var(--dml-blue);
}

.dml-btn-primary:hover {
    background: var(--dml-blue-dark);
    border-color: var(--dml-blue-dark);
    box-shadow: 0 4px 14px rgba(37,99,235,.35);
    color: #fff;
    transform: translateY(-1px);
}

.dml-btn-outline {
    background: transparent;
    color: var(--dml-blue);
    border-color: var(--dml-blue);
}

.dml-btn-outline:hover {
    background: var(--dml-blue-light);
    transform: translateY(-1px);
}

/* ── No-results ────────────────────────────────────────────────────────────── */
.dml-no-results {
    text-align: center;
    padding: 72px 20px;
    background: #fff;
    border-radius: var(--dml-radius);
    border: 2px dashed var(--dml-gray-200);
}

.dml-no-results-icon {
    font-size: 3.5rem;
    color: var(--dml-gray-300);
    margin-bottom: 16px;
}

.dml-no-results-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--dml-gray-700);
    margin: 0 0 8px;
}

.dml-no-results-text {
    color: var(--dml-gray-400);
    font-size: 0.95rem;
    margin: 0 0 20px;
}

/* ── Load more pagination ──────────────────────────────────────────────────── */
.dml-pagination {
    text-align: center;
    margin-top: 40px;
}

.dml-load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 36px;
    background: #fff;
    border: 2px solid var(--dml-gray-200);
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--dml-gray-700);
    cursor: pointer;
    transition: all var(--dml-transition);
    font-family: var(--dml-font-ui);
}

.dml-load-more-btn:hover {
    border-color: var(--dml-blue);
    color: var(--dml-blue);
    box-shadow: 0 4px 14px rgba(37,99,235,.15);
    transform: translateY(-2px);
}

.dml-load-more-btn.loading {
    pointer-events: none;
    opacity: .7;
}

/* ── Loading overlay ───────────────────────────────────────────────────────── */
.dml-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.75);
    backdrop-filter: blur(4px);
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--dml-radius);
    animation: dmlFadeIn .2s ease;
}

.dml-spinner {
    text-align: center;
}

@keyframes dmlFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Section header (category view) ───────────────────────────────────────── */
.dml-section-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 3px solid var(--dml-blue);
}

.dml-section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dml-gray-900);
    margin: 0;
}

.dml-section-count {
    font-size: 0.875rem;
    color: var(--dml-gray-400);
    font-weight: 500;
}

/* ── Standalone search bar ─────────────────────────────────────────────────── */
.dml-standalone-search {
    position: relative;
    max-width: 600px;
}

.dml-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--dml-gray-200);
    border-radius: var(--dml-radius);
    box-shadow: var(--dml-shadow-lg);
    z-index: 100;
    max-height: 420px;
    overflow-y: auto;
}

/* ── LIST view mode ────────────────────────────────────────────────────────── */
.dml-library.dml-list-view .dml-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.dml-library.dml-list-view .dml-col {
    flex: 0 0 100%;
    max-width: 100%;
    width: 100%;
    padding: 0;
    margin-bottom: 12px;
}

.dml-library.dml-list-view .dml-card-resource {
    flex-direction: row;
    height: auto;
    min-height: 110px;
}

.dml-library.dml-list-view .dml-card-thumb {
    width: 140px;
    min-width: 140px;
    aspect-ratio: auto;
    border-radius: 0;
}

.dml-library.dml-list-view .dml-card-body-resource {
    padding: 12px 16px;
}

.dml-library.dml-list-view .dml-card-desc {
    -webkit-line-clamp: 2;
    margin-bottom: 6px;
}

.dml-library.dml-list-view .dml-card-actions {
    flex-direction: column;
    justify-content: center;
    min-width: 140px;
    border-left: 1px solid var(--dml-gray-100);
    border-top: none;
    background: var(--dml-gray-50);
    padding: 12px 16px;
}

.dml-library.dml-list-view .dml-btn {
    min-width: auto;
    width: 100%;
    flex: none;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .dml-toolbar { flex-direction: column; }
    .dml-search-wrap { width: 100%; }
    .dml-sort-select { width: 100%; }

    .dml-filter-tabs { gap: 6px; }
    .dml-tab { padding: 7px 14px; font-size: 0.82rem; }

    .dml-library.dml-list-view .dml-card-resource { flex-direction: column; }
    .dml-library.dml-list-view .dml-card-thumb    { width: 100%; aspect-ratio: 16/9; }
    .dml-library.dml-list-view .dml-card-actions  { border-left: none; border-top: 1px solid var(--dml-gray-100); flex-direction: row; }
}

@media (max-width: 480px) {
    .dml-card-actions { flex-direction: column; }
    .dml-btn { min-width: auto; }
}

/* ── Utility: smooth grid transition when filtering ───────────────────────── */
.dml-grid {
    transition: opacity .2s ease;
}

.dml-grid.dml-loading {
    opacity: .4;
    pointer-events: none;
}

/* ── PDF preview iframe ────────────────────────────────────────────────────── */
#dmlPdfFrame {
    border-radius: 0 0 var(--dml-radius-sm) var(--dml-radius-sm);
}

/* ── Bootstrap modal tweaks ────────────────────────────────────────────────── */
.modal-content {
    border-radius: var(--dml-radius);
    border: none;
    box-shadow: var(--dml-shadow-lg);
}
