/* ═══════════════════════════════════════════════════════════════════════════
   DocuCore Public Styles — Scribd / Exam-Trove inspired design
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  --dc-yellow:   #f5c518;
  --dc-yellow-d: #d4aa00;
  --dc-black:    #1a1a1a;
  --dc-dark:     #111111;
  --dc-white:    #ffffff;
  --dc-grey-bg:  #f4f4f4;
  --dc-grey-bd:  #e0e0e0;
  --dc-grey-txt: #6b7280;
  --dc-blue:     #1565c0;
  --dc-text:     #1a1a1a;
  --dc-radius:   8px;
  --dc-shadow:   0 1px 4px rgba(0,0,0,.10);
  --dc-shadow-h: 0 4px 18px rgba(0,0,0,.15);
}

/* ARCHIVE HERO */
.dp-archive-hero { background: var(--dc-dark); padding: 28px 0 22px; }
.dp-archive-hero__inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.dp-archive-hero__title { font-size: 2.4rem; font-weight: 900; color: #fff; margin: 0 0 6px; letter-spacing: -.5px; line-height: 1.2; }
.dp-archive-hero__title em { font-style: normal; color: var(--dc-yellow); }
.dp-archive-hero__desc { font-size: .95rem; color: #bbb; margin: 0; }

/* WRAPPER */
.docucore-library { max-width: 1200px; margin: 0 auto; padding: 20px 20px 48px; }

/* CONTROLS */
.dp-catalog__controls {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--dc-grey-bd);
}

/* SEARCH */
.dp-search { position: relative; flex: 1 1 260px; min-width: 200px; }
.dp-search__icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: #9ca3af; pointer-events: none; display: flex;
}
.dp-search__input {
  width: 100%; padding: 9px 14px 9px 38px;
  border: 1px solid var(--dc-grey-bd); border-radius: 24px;
  font-size: 14px; line-height: 1.5; background: #fff;
  transition: border-color .2s, box-shadow .2s; box-sizing: border-box;
}
.dp-search__input:focus { outline: none; border-color: #666; box-shadow: 0 0 0 3px rgba(0,0,0,.07); }
.dp-search__input::placeholder { color: #aaa; }

/* FILTERS */
.dp-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dp-filter { display: inline-block; }
.dp-select {
  padding: 8px 30px 8px 12px; border: 1px solid var(--dc-grey-bd); border-radius: 6px;
  font-size: 13px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E") no-repeat right 10px center;
  background-size: 8px; -webkit-appearance: none; appearance: none;
  cursor: pointer; min-width: 110px; font-weight: 500; color: var(--dc-text);
  transition: border-color .15s;
}
.dp-select:focus { outline: none; border-color: #888; }
.dp-select:hover { border-color: #aaa; }
.dp-sort { margin-left: 4px; }

/* VIEW TOGGLE */
.dp-view-toggle {
  display: flex; gap: 2px; border: 1px solid var(--dc-grey-bd);
  border-radius: 6px; overflow: hidden; background: #f8f8f8;
}
.dp-view-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: transparent; border: none;
  cursor: pointer; color: #aaa; padding: 0; transition: background .12s, color .12s;
}
.dp-view-btn:hover  { background: #eee; color: #555; }
.dp-view-btn.is-active { background: #fff; color: var(--dc-black); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.dp-view-btn svg { width: 16px; height: 16px; }
.dp-results-count { font-size: 12.5px; color: #888; margin-left: auto; white-space: nowrap; align-self: center; }

/* GRID */
.doc-grid, .dp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

/* ═══════════════════════════════════════════════════════════════
   DOCUMENT CARD  — matches reference design
   (thumbnail + PDF badge + title + author + pages-left + bookmark)
═══════════════════════════════════════════════════════════════ */
.doc-card {
  background: var(--dc-white);
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: box-shadow .18s, transform .15s;
  display: flex;
  flex-direction: column;
  position: relative;
}
.doc-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  transform: translateY(-2px);
}

/* The <a> covers the image and body — full height */
.doc-card__link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
  outline-offset: 2px;
}
.doc-card__link:focus-visible {
  outline: 2px solid #0073aa;
}

/* ── Thumbnail image area (3:4 portrait ratio) ── */
.doc-card__media {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #f5f5f5;
  overflow: hidden;
  flex-shrink: 0;
}

/* Actual thumbnail image — contain within the area */
.doc-card__thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}

/* Placeholder shown when no thumbnail is generated yet */
.doc-card__thumb--placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #f0f0f0, #e4e4e4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.doc-card__ph-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #bbb;
  text-transform: uppercase;
}

/* File-type badge — solid black pill top-left (matches reference screenshot) */
.doc-card__badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  background: #111;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .6px;
  padding: 2px 7px;
  border-radius: 4px;
  line-height: 1.6;
  pointer-events: none;
  text-transform: uppercase;
}

/* ── Card body (below the image) ── */
.doc-card__body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 3px;
}

.doc-card__title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.4;
  color: #111;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.doc-card__author {
  font-size: 11.5px;
  color: #9ca3af;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Card footer: "XX pages left" ── */
.doc-card__footer {
  display: flex;
  align-items: center;
  margin-top: auto;
  padding-top: 8px;
  padding-right: 28px; /* room for absolute bookmark button */
}

.doc-card__pages-left {
  font-size: 11.5px;
  color: #666;
  white-space: nowrap;
}
.doc-card__pages-left--done {
  color: #16a34a;
  font-weight: 600;
}

/* Bookmark button — absolute bottom-right of card (sibling to <a>) */
.doc-card__bookmark {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 3;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  color: #bbb;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .2s;
  border-radius: 4px;
  line-height: 0;
}
.doc-card__bookmark:hover,
.doc-card__bookmark:focus-visible { color: #333; outline: none; }
.doc-card__bookmark.is-saved { color: #111; }
.doc-card__bookmark svg { width: 17px; height: 17px; }

/* ── Legacy aliases (keep for any code still referencing old classes) ── */
.doc-card__ribbon { display: none; }   /* replaced by .doc-card__badge */
.doc-card__lock   { position: absolute; top: 8px; right: 8px; z-index: 2;
  background: rgba(0,0,0,.55); border-radius: 50%;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.doc-card__lock svg { width: 13px; height: 13px; color: #fff; }
.doc-card__rating { display: none; }   /* hidden in new design */
.doc-card__rating-thumb { display: none; }

.doc-list { display: flex; flex-direction: column; gap: 0; list-style: none; padding: 0; margin: 0; }
.doc-list-row {
  background: var(--dc-white); border: 1px solid var(--dc-grey-bd);
  border-radius: 6px; overflow: hidden; transition: box-shadow .15s; margin-bottom: 10px;
}
.doc-list-row:hover { box-shadow: var(--dc-shadow-h); }
.doc-list-row__link { display: flex; align-items: flex-start; gap: 16px; padding: 16px; text-decoration: none; color: inherit; }

.doc-list-row__thumb-wrap { position: relative; flex-shrink: 0; }
.doc-list-row__thumb { width: 72px; height: 96px; object-fit: contain; background: #fff; border-radius: 3px; border: 1px solid #e5e7eb; display: block; }
.doc-list-row__thumb--ph { width: 72px; height: 96px; background: #f3f4f6; border-radius: 4px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #9ca3af; border: 1px solid #e5e7eb; }
.doc-list-row__badge { position: absolute; top: 5px; left: 5px; }
.doc-list-row__badge .dp-badge { font-size: 9px; padding: 1px 4px; border-radius: 3px; }

.doc-list-row__body { flex: 1; min-width: 0; }
.doc-list-row__meta-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 5px; font-size: 12px; color: var(--dc-grey-txt); }
.doc-list-row__rating { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: #555; }
.doc-list-row__rating svg { width: 13px; height: 13px; }
.doc-list-row__dot { color: #ccc; }
.doc-list-row__title { font-size: 16px; font-weight: 700; margin: 0 0 6px; color: var(--dc-black); line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.doc-list-row__excerpt { font-size: 13px; color: #4b5563; margin: 0 0 8px; line-height: 1.55; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.doc-list-row__footer { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--dc-grey-txt); }
.doc-list-row__uploader { font-size: 12px; color: #888; }
.doc-list-row__cat-tag { display: inline-block; padding: 2px 8px; border: 1px solid #e5e7eb; border-radius: 4px; font-size: 11.5px; color: #555; background: #f9fafb; }

.doc-list-row__right { display: flex; align-items: flex-start; padding-top: 2px; flex-shrink: 0; }
.doc-list-row__bookmark { background: none; border: none; cursor: pointer; padding: 4px; color: #ccc; display: flex; transition: color .15s; }
.doc-list-row__bookmark:hover { color: #555; }
.doc-list-row__bookmark svg { width: 18px; height: 18px; }

/* AUTOCOMPLETE */
.dp-suggest-box { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 9999; overflow: hidden; }
.dp-suggest-box[hidden] { display: none; }
.dp-suggest-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; cursor: pointer; gap: 8px; transition: background .1s; }
.dp-suggest-item:hover { background: #f8fafc; }
.dp-suggest-item + .dp-suggest-item { border-top: 1px solid #f1f5f9; }
.dp-suggest-item__title { font-size: 14px; font-weight: 500; color: #1e293b; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-suggest-item__title mark { background: #fef08a; color: inherit; padding: 0 1px; border-radius: 2px; }
.dp-suggest-item__meta { display: flex; gap: 4px; flex-shrink: 0; }
.dp-suggest-item__cat { font-size: 11px; color: #94a3b8; background: #f1f5f9; padding: 2px 6px; border-radius: 4px; }

.dp-tier-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.dp-tier-badge--free    { background: #e8f5e9; color: #2e7d32; }
.dp-tier-badge--pro     { background: #e3f2fd; color: #1565c0; }
.dp-tier-badge--premium { background: #fce4ec; color: #880e4f; }

.dp-pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 36px; }
.dp-btn--page { padding: 8px 18px; border: 1px solid var(--dc-grey-bd); border-radius: 6px; background: #fff; font-size: 13px; cursor: pointer; transition: background .15s; font-weight: 500; }
.dp-btn--page:hover:not(:disabled) { background: #f0f0f0; }
.dp-btn--page:disabled { opacity: .4; cursor: not-allowed; }

/* FRONTEND UPLOAD */
.dp-upload-form { max-width: 640px; }
.dp-upload-form__inner { background: #fff; border: 1px solid var(--dc-grey-bd); border-radius: var(--dc-radius); padding: 28px; }
.dp-form-group { margin-bottom: 20px; }
.dp-form-label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--dc-black); }
.dp-required   { color: #c0392b; margin-left: 2px; }
.dp-form-input { width: 100%; padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; line-height: 1.5; box-sizing: border-box; transition: border-color .15s; }
.dp-form-input:focus { outline: none; border-color: #333; }
.dp-form-textarea { resize: vertical; min-height: 80px; }
.dp-form-select   { height: 38px; }
.dp-file-drop-zone { position: relative; border: 2px dashed #ccc; border-radius: 6px; padding: 28px 20px; text-align: center; cursor: pointer; background: #f9f9f9; transition: border-color .15s, background .15s; }
.dp-file-drop-zone:hover, .dp-file-drop-zone--hover { border-color: #333; background: #f3f3f3; }
.dp-file-drop-zone--selected { border-color: #16a34a; background: #f0fdf4; border-style: solid; }
.dp-file-drop-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dp-file-drop-zone__label { pointer-events: none; color: #555; }
.dp-file-drop-zone__icon  { display: block; font-size: 32px; margin-bottom: 8px; }
.dp-form-actions { display: flex; align-items: center; gap: 16px; margin-top: 8px; }
.dp-submit-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 24px; background: var(--dc-black); color: #fff; border: none; border-radius: 4px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s; }
.dp-submit-btn:hover:not(:disabled) { background: #333; }
.dp-submit-btn:disabled             { opacity: .6; cursor: not-allowed; }
.dp-upload-progress { flex: 1; background: #e5e5e5; border-radius: 4px; height: 20px; position: relative; overflow: hidden; }
.dp-upload-progress__bar   { height: 100%; background: var(--dc-black); border-radius: 4px; width: 0%; transition: width .1s; }
.dp-upload-progress__label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; }
.dp-upload-result { padding: 12px 16px; border-radius: 4px; margin-bottom: 16px; font-weight: 500; display: none; }
.dp-upload-result--success { background: #d1e7dd; color: #0a3622; border: 1px solid #a3cfbb; }
.dp-upload-result--error   { background: #f8d7da; color: #58151c; border: 1px solid #f1aeb5; }
.dp-upload-form--login { color: #555; }

/* RESPONSIVE */
@media (max-width: 768px) {
  .doc-grid, .dp-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }
  .dp-catalog__controls { flex-direction: column; align-items: stretch; }
  .dp-search { min-width: 100%; }
  .dp-sort { margin-left: 0; }
  .dp-results-count { margin-left: 0; }
  .dp-archive-hero__title { font-size: 1.7rem; }
}
@media (max-width: 480px) {
  .doc-list-row__link { gap: 10px; padding: 12px; }
  .doc-list-row__thumb { width: 56px; height: 75px; }
  .doc-list-row__thumb--ph { width: 56px; height: 75px; }
  .doc-list-row__title { font-size: 14px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RTL SUPPORT — Arabic and other right-to-left languages
   ═══════════════════════════════════════════════════════════════════════════ */
[dir="rtl"] .dp-archive-hero__title,
.rtl .dp-archive-hero__title,
html[lang="ar"] .dp-archive-hero__title {
  letter-spacing: 0;
  font-family: 'Noto Sans Arabic', 'Segoe UI', Tahoma, 'Arial Unicode MS', sans-serif;
}

[dir="rtl"] .dp-catalog__controls,
html[lang="ar"] .dp-catalog__controls { direction: rtl; }

[dir="rtl"] .dp-search__icon,
html[lang="ar"] .dp-search__icon { left: auto; right: 12px; }
[dir="rtl"] .dp-search__input,
html[lang="ar"] .dp-search__input { padding-left: 14px; padding-right: 38px; }

[dir="rtl"] .dp-results-count,
html[lang="ar"] .dp-results-count { margin-left: 0; margin-right: auto; }

[dir="rtl"] .dp-sort,
html[lang="ar"] .dp-sort { margin-left: 0; margin-right: 4px; }

[dir="rtl"] .doc-card__ribbon,
[dir="rtl"] .doc-card__badge,
html[lang="ar"] .doc-card__ribbon,
html[lang="ar"] .doc-card__badge { left: auto; right: 8px; }
[dir="rtl"] .doc-card__lock,
html[lang="ar"] .doc-card__lock { right: auto; left: 8px; }

[dir="rtl"] .doc-card__title,
[dir="rtl"] .doc-card__author,
[dir="rtl"] .doc-card__excerpt,
html[lang="ar"] .doc-card__title,
html[lang="ar"] .doc-card__author,
html[lang="ar"] .doc-card__excerpt {
  font-family: 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  text-align: right;
}

[dir="rtl"] .doc-list-row__badge,
html[lang="ar"] .doc-list-row__badge { left: auto; right: 5px; }

[dir="rtl"] .doc-list-row__title,
[dir="rtl"] .doc-list-row__excerpt,
html[lang="ar"] .doc-list-row__title,
html[lang="ar"] .doc-list-row__excerpt {
  font-family: 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  text-align: right;
}

[dir="rtl"] .doc-list-row__right,
html[lang="ar"] .doc-list-row__right { margin-left: 0; margin-right: auto; }

[dir="rtl"] .doc-card__footer,
html[lang="ar"] .doc-card__footer { flex-direction: row-reverse; }
[dir="rtl"] .doc-card__pages-left,
html[lang="ar"] .doc-card__pages-left { text-align: right; }
[dir="rtl"] .doc-card__badge,
html[lang="ar"] .doc-card__badge { left: auto; right: 8px; font-family: 'Noto Sans Arabic', sans-serif; }
