/* ============================================================
   css/docviewer.css — чтение документов (.docx) прямо в браузере
   Модальное окно + типографика отрендеренного документа.
   Работает в паре с js/docviewer.js (mammoth.js).
   ============================================================ */

.doc-modal {
  position: fixed; inset: 0; z-index: 6000;
  display: none; align-items: center; justify-content: center;
  padding: clamp(12px, 3vw, 40px);
  background: rgba(6, 4, 10, 0.88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.doc-modal.open { display: flex; animation: docFade .25s ease; }
@keyframes docFade { from { opacity: 0; } to { opacity: 1; } }

.doc-modal-inner {
  display: flex; flex-direction: column;
  width: 100%; max-width: 880px; max-height: 90vh;
  border-radius:12px; overflow: hidden;
  background: linear-gradient(180deg, #1b1228, #140d20);
  border: 1px solid rgba(142, 83, 225, 0.25);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255,255,255,0.03);
  animation: docPop .3s cubic-bezier(.22,.9,.41,1);
}
@keyframes docPop { from { transform: translateY(16px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

/* Шапка модалки */
.doc-modal-head {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}
.doc-modal-head .doc-ico {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius:11px;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--btn));
}
.doc-modal-head .doc-ico svg { width: 22px; height: 22px; }
.doc-modal-head .doc-titles { flex: 1; min-width: 0; }
.doc-modal-head h3 {
  margin: 0; font-family: 'Wix Madefor Display', sans-serif; font-size: 1.05rem; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doc-modal-head .doc-sub { font-size: 0.8rem; color: rgba(234, 230, 247, 0.55); }
.doc-modal-actions { display: flex; gap: 8px; }
.doc-modal-actions a, .doc-modal-actions button {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius:10px; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 0.85rem; text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.05); color: var(--text);
  transition: all .2s ease;
}
.doc-modal-actions a:hover, .doc-modal-actions button:hover { background: rgba(164, 102, 255, 0.2); border-color: rgba(164,102,255,0.4); }
.doc-modal-actions svg { width: 16px; height: 16px; }
.doc-modal-close { width: 40px; height: 40px; justify-content: center; padding: 0 !important; border-radius: 50% !important; font-size: 18px; }
.doc-modal-close:hover { transform: rotate(90deg); }

/* Тело документа (скролл) */
.doc-modal-body {
  flex: 1; overflow-y: auto; padding: clamp(20px, 4vw, 44px);
  scrollbar-width: thin; scrollbar-color: rgba(164,102,255,0.4) transparent;
}
.doc-modal-body::-webkit-scrollbar { width: 10px; }
.doc-modal-body::-webkit-scrollbar-thumb { background: rgba(164,102,255,0.35); border-radius:6px; }

/* Состояния */
.doc-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 60px 20px; text-align: center; color: rgba(234, 230, 247, 0.7);
}
.doc-spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid rgba(164, 102, 255, 0.2); border-top-color: var(--btn);
  animation: docSpin .8s linear infinite;
}
@keyframes docSpin { to { transform: rotate(360deg); } }
.doc-state svg { width: 44px; height: 44px; opacity: 0.6; }
.doc-state h4 { margin: 0; color: #fff; font-family: 'Wix Madefor Display', sans-serif; }

/* Шапка-баннер: картинка + наложенный поверх текст (правый верх) */
.doc-hero {
  position: relative; border-radius:14px; overflow: hidden;
  margin: 0 0 24px; border: 1px solid rgba(255, 255, 255, 0.08);
}
.doc-hero-bg { width: 100%; height: auto; display: block; }
.doc-hero-overlay {
  position: absolute; top: 0; right: 0; bottom: 0; left: 38%;
  display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-end;
  gap: 3px; padding: 18px 22px; text-align: right;
  background: linear-gradient(to left, rgba(10, 6, 16, 0.55), transparent 85%);
}
.doc-hero-overlay p { margin: 0; color: #fff; font-size: 0.86rem; line-height: 1.45; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7); }
.doc-hero-overlay p:first-child { font-weight: 700; font-size: 0.95rem; }
@media (max-width: 560px) {
  .doc-hero-overlay { left: 20%; padding: 12px 14px; }
  .doc-hero-overlay p { font-size: 0.7rem; }
  .doc-hero-overlay p:first-child { font-size: 0.78rem; }
}

/* Типографика отрендеренного .docx */
.doc-content { max-width: 70ch; margin: 0 auto; color: rgba(234, 230, 247, 0.9); line-height: 1.7; font-size: 1rem; }
.doc-content > :first-child { margin-top: 0; }
.doc-content h1, .doc-content h2, .doc-content h3, .doc-content h4 {
  font-family: 'Wix Madefor Display', sans-serif; color: #fff; line-height: 1.25;
  margin: 1.6em 0 .6em;
}
.doc-content h1 { font-size: 1.6rem; }
.doc-content h2 { font-size: 1.35rem; }
.doc-content h3 { font-size: 1.15rem; color: #d7c4ff; }
.doc-content h4 { font-size: 1.02rem; color: #d7c4ff; }
.doc-content p { margin: 0 0 1em; }
.doc-content ul, .doc-content ol { margin: 0 0 1em; padding-left: 1.4em; }
.doc-content li { margin-bottom: .4em; }
.doc-content a { color: var(--btn); text-decoration: underline; }
.doc-content strong, .doc-content b { color: #fff; }
.doc-content em { color: #e8d9ff; }
.doc-content hr { border: 0; border-top: 1px solid rgba(255,255,255,0.1); margin: 1.6em 0; }
.doc-content img { max-width: 100%; height: auto; border-radius:10px; }
.doc-content table { width: 100%; border-collapse: collapse; margin: 0 0 1.2em; font-size: 0.92rem; }
.doc-content th, .doc-content td { border: 1px solid rgba(255, 255, 255, 0.12); padding: 8px 12px; text-align: left; }
.doc-content th { background: rgba(164, 102, 255, 0.12); color: #fff; }
.doc-content blockquote {
  margin: 0 0 1em; padding: 6px 16px; border-left: 3px solid var(--accent);
  background: rgba(142, 83, 225, 0.08); border-radius: 0 10px 10px 0; color: rgba(234,230,247,0.85);
}

@media (max-width: 560px) {
  .doc-modal-head { flex-wrap: wrap; }
  .doc-modal-actions .label-text { display: none; }
}

/* ============================================================
   Карточки документов (список документации)
   ============================================================ */
.doc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.doc-card {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 18px; border-radius:11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.doc-card:hover { transform: translateY(-4px); border-color: rgba(164, 102, 255, 0.35); box-shadow: 0 18px 44px rgba(0,0,0,0.45); }
.doc-card-ico {
  flex: 0 0 46px; width: 46px; height: 46px; border-radius:13px;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(140deg, rgba(142,83,225,0.4), rgba(164,102,255,0.2));
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.doc-card-ico svg { width: 24px; height: 24px; }
.doc-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.doc-card-title { font-weight: 600; color: #fff; line-height: 1.35; }
.doc-card-date { font-size: 0.8rem; color: rgba(234, 230, 247, 0.5); }
.doc-card-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.doc-card-actions .doc-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius:10px; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 0.85rem; text-decoration: none;
  border: 1px solid transparent; transition: all .2s ease;
}
.doc-card-actions .doc-btn svg { width: 15px; height: 15px; }
.doc-card-actions .doc-btn.read {
  background: linear-gradient(135deg, var(--btn), #8e5dff); color: #fff;
  box-shadow: 0 6px 16px rgba(164, 102, 255, 0.25);
}
.doc-card-actions .doc-btn.read:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(164, 102, 255, 0.4); }
.doc-card-actions .doc-btn.dl {
  background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.1); color: var(--text);
}
.doc-card-actions .doc-btn.dl:hover { background: rgba(255, 255, 255, 0.1); }
