/* ===== NextERP — Data & Backup hub (Phase 24) =====
   Styles for js/dataHub.js. Every colour is a var() from app.css :root, so
   dark mode needs no rules of its own, and every horizontal measurement uses
   logical properties (inline-start/end), so Arabic and Kurdish right-to-left
   layouts need none either. Loaded after app.css so those variables exist.
   Everything is prefixed dh- except the three hooks on the sidebar button. */

/* ---------- frame ---------- */

.dh-overlay .dh-modal,
.dh-modal{
  max-width:880px;
  width:100%;
  display:flex;
  flex-direction:column;
  max-height:90vh;
  overflow:hidden;
}
.dh-modal .modal-head{ flex:0 0 auto; gap:12px; }
.dh-modal .modal-head-title{ min-width:0; flex:1 1 auto; }
.dh-modal .modal-head-title > div{ min-width:0; }
.dh-modal .modal-head-sub{ font-size:12px; color:var(--ink-soft); margin-top:2px; line-height:1.4; }

.dh-body{
  flex:1 1 auto;
  overflow-y:auto;
  overscroll-behavior:contain;
  gap:18px;
}

.dh-loading{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  font-size:13px;
  color:var(--ink-soft);
  padding:24px 0;
}

/* ---------- tabs ---------- */

.dh-tabs{
  flex:0 0 auto;
  display:flex;
  gap:4px;
  padding:0 22px;
  border-bottom:1px solid var(--panel-edge);
  overflow-x:auto;
  scrollbar-width:thin;
}
.dh-tab{
  flex:0 0 auto;
  background:none;
  border:none;
  border-bottom:2px solid transparent;
  margin-bottom:-1px;
  padding:12px 10px;
  font-family:'Inter',sans-serif;
  font-size:13px;
  font-weight:600;
  color:var(--ink-soft);
  cursor:pointer;
  white-space:nowrap;
  border-radius:0;
}
.dh-tab:hover{ color:var(--ink); }
.dh-tab[aria-selected="true"]{ color:var(--ink); border-bottom-color:var(--accent); }
.dh-tab:focus-visible{ outline:2px solid var(--accent); outline-offset:-2px; border-radius:6px; }

/* ---------- panel content ---------- */

.dh-panel{ display:flex; flex-direction:column; gap:16px; }
.dh-panel.hidden{ display:none; }

.dh-intro h3{ margin:0 0 6px; font-size:15px; font-weight:700; color:var(--ink); }
.dh-intro p{ margin:0 0 6px; font-size:13px; line-height:1.55; color:var(--ink); }
.dh-intro p:last-child{ margin-bottom:0; }

.dh-card{
  border:1px solid var(--panel-edge);
  border-radius:var(--radius);
  background:var(--panel);
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:12px;
}
.dh-card h4{ margin:0; font-size:14px; font-weight:700; color:var(--ink); }
.dh-card p{ margin:0; font-size:12.5px; line-height:1.55; }

.dh-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(240px, 1fr));
  gap:12px;
}

.dh-form-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:12px;
}
.dh-form-grid .field{ margin:0; }

.dh-muted{ color:var(--ink-soft); font-size:12.5px; line-height:1.5; }
.dh-block{ display:block; margin-top:2px; }
.dh-warn-text{ color:var(--amber-note-text); font-size:12.5px; line-height:1.5; margin:0; }

.dh-actions{ display:flex; flex-wrap:wrap; align-items:center; gap:10px; }
.dh-btn-sm{ padding:6px 12px; font-size:12px; border-radius:9px; }
.btn.is-busy{ opacity:.75; cursor:progress; }

/* ---------- notices ---------- */

.dh-notice,
.dh-notice-inline{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  background:var(--amber-note);
  border:1px solid var(--amber-note-edge);
  color:var(--amber-note-text);
  border-radius:10px;
  padding:10px 12px;
  font-size:12.5px;
  line-height:1.5;
}
.dh-notice.hidden{ display:none; }
#dataHubError{ white-space:pre-line; }

/* ---------- status, progress, badges ---------- */

.dh-status{
  display:flex;
  flex-direction:column;
  gap:10px;
  border:1px solid var(--panel-edge);
  border-radius:var(--radius);
  padding:14px 16px;
  background:var(--surface-soft);
}
.dh-status p{ margin:0; font-size:13px; line-height:1.5; }
.dh-status-line{ display:flex; align-items:center; gap:10px; font-size:13px; color:var(--ink); }
.dh-ready-head{ display:flex; align-items:center; flex-wrap:wrap; gap:10px; }

.dh-spinner{
  width:14px;
  height:14px;
  flex:0 0 auto;
  border-radius:50%;
  border:2px solid var(--panel-edge);
  border-top-color:var(--accent);
  animation:dh-spin .8s linear infinite;
}

.dh-progress{
  position:relative;
  height:8px;
  border-radius:999px;
  background:var(--panel-edge);
  overflow:hidden;
}
.dh-progress-bar{
  height:100%;
  border-radius:999px;
  background:linear-gradient(90deg, var(--accent), var(--accent-dark));
  transition:width .25s ease;
}
.dh-progress.is-indeterminate .dh-progress-bar{
  position:absolute;
  inset-inline-start:0;
  animation:dh-slide 1.3s ease-in-out infinite;
}

.dh-badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:3px 9px;
  border-radius:999px;
  border:1px solid transparent;
  font-size:11.5px;
  font-weight:600;
  white-space:nowrap;
  line-height:1.4;
}
.dh-badge-green{ background:var(--pill-green-bg); border-color:var(--pill-green-border); color:var(--pill-green-text); }
.dh-badge-red{ background:var(--pill-red-bg); border-color:var(--pill-red-border); color:var(--pill-red-text); }
.dh-badge-blue{ background:var(--pill-blue-bg); border-color:var(--pill-blue-border); color:var(--pill-blue-text); }
.dh-badge-yellow{ background:var(--pill-yellow-bg); border-color:var(--pill-yellow-border); color:var(--pill-yellow-text); }
.dh-badge-gray{ background:var(--pill-gray-bg); border-color:var(--pill-gray-border); color:var(--pill-gray-text); }

.dh-chips{ display:flex; flex-wrap:wrap; gap:8px; }

/* ---------- download lists ---------- */

.dh-part-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:6px; }
.dh-part-dl{
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto auto;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border-radius:10px;
  background:var(--panel);
  border:1px solid var(--panel-edge);
}
.dh-part-index{ font-size:12px; font-weight:700; color:var(--ink); white-space:nowrap; }
.dh-part-name{
  font-family:'JetBrains Mono',monospace;
  font-size:11.5px;
  color:var(--ink-soft);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  min-width:0;
}
.dh-part-size{ font-size:12px; color:var(--ink-soft); white-space:nowrap; }
.dh-part-dl .btn{ text-decoration:none; }

/* ---------- restore ---------- */

.dh-dropzone{
  display:flex;
  align-items:center;
  justify-content:center;
  flex-wrap:wrap;
  gap:12px;
  padding:20px;
  border:2px dashed var(--panel-edge);
  border-radius:var(--radius);
  background:var(--surface-soft);
  text-align:center;
  transition:border-color .15s ease, background .15s ease;
}
.dh-dropzone.is-dragover{ border-color:var(--accent); background:var(--surface-hover); }

#dhRestoreBody{ display:flex; flex-direction:column; gap:14px; }
.dh-part-table{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; }
.dh-part-table:empty{ display:none; }
.dh-part-row{
  display:grid;
  grid-template-columns:64px minmax(0,1fr) auto auto;
  align-items:center;
  gap:12px;
  padding:10px 12px;
  border:1px solid var(--panel-edge);
  border-radius:10px;
  background:var(--panel);
}
.dh-part-main{ display:flex; flex-direction:column; gap:5px; min-width:0; }
.dh-part-detail{ font-size:12px; color:var(--ink-soft); line-height:1.45; overflow-wrap:anywhere; }
.dh-part-detail:empty{ display:none; }
.dh-part-state{ display:flex; justify-content:flex-end; }
.dh-part-actions{ display:flex; gap:6px; justify-content:flex-end; flex-wrap:wrap; }
.dh-part-actions:empty{ display:none; }

.dh-apply-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:12px;
  padding-top:4px;
  border-top:1px solid var(--panel-edge);
}
.dh-apply-row .dh-actions{ margin-inline-start:auto; }

.dh-kv{
  display:grid;
  grid-template-columns:max-content minmax(0,1fr);
  gap:6px 16px;
  margin:0;
  padding:12px 14px;
  border-radius:10px;
  background:var(--surface-soft);
  border:1px solid var(--panel-edge);
  font-size:12.5px;
}
.dh-kv dt{ color:var(--ink-soft); font-weight:600; }
.dh-kv dd{ margin:0; color:var(--ink); overflow-wrap:anywhere; }

/* ---------- forms ---------- */

.dh-check{
  display:flex;
  align-items:flex-start;
  gap:10px;
  font-size:13px;
  color:var(--ink);
  cursor:pointer;
  line-height:1.45;
}
.dh-check input{ margin-top:3px; flex:0 0 auto; accent-color:var(--accent); }
.dh-radio-group{ display:flex; flex-direction:column; gap:10px; }

.dh-secret{ display:flex; gap:8px; align-items:center; }
.dh-secret input{ flex:1 1 auto; min-width:0; }

.dh-file-row{ display:flex; align-items:center; flex-wrap:wrap; gap:10px; }

.dh-checklist{ list-style:none; margin:0; padding:0; display:flex; flex-wrap:wrap; gap:6px 16px; font-size:12px; color:var(--ink-soft); }
.dh-checklist li{ display:flex; align-items:center; gap:6px; }
.dh-checklist li::before{
  content:"";
  width:8px;
  height:8px;
  border-radius:50%;
  border:1.5px solid var(--ink-soft);
  flex:0 0 auto;
}
.dh-checklist li.ok{ color:var(--pill-green-text); }
.dh-checklist li.ok::before{ background:var(--pill-green-text); border-color:var(--pill-green-text); }

/* ---------- vault preview ---------- */

.dh-preview{ display:flex; flex-direction:column; gap:10px; padding-top:4px; }
.dh-account-list{
  list-style:none;
  margin:0;
  padding:0;
  max-height:260px;
  overflow-y:auto;
  border:1px solid var(--panel-edge);
  border-radius:10px;
}
.dh-account-list li{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:8px 12px;
  font-size:12.5px;
  border-bottom:1px solid var(--panel-edge);
}
.dh-account-list li:last-child{ border-bottom:none; }
.dh-account-name{ min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--ink); }

/* ---------- selective tab (static markup in index.html) ---------- */

.dh-selective-btn{ justify-content:center; }
.dh-selective-btn.hidden{ display:none; }

/* ---------- sidebar button hooks ---------- */

#dataHubBtn.dh-attention::after,
#dataHubBtn.dh-busy::after{
  content:"";
  position:absolute;
  top:9px;
  inset-inline-start:25px;
  width:8px;
  height:8px;
  border-radius:50%;
  box-shadow:0 0 0 2px var(--panel);
}
#dataHubBtn.dh-attention::after{ background:var(--danger); }
#dataHubBtn.dh-busy::after{ background:var(--accent); animation:dh-pulse 1.4s ease-in-out infinite; }
#dataHubBtn.dh-attention.dh-busy::after{ background:var(--danger); }

/* ---------- animation ---------- */

@keyframes dh-spin{ to{ transform:rotate(360deg); } }
@keyframes dh-slide{
  0%{ transform:translateX(-100%); }
  100%{ transform:translateX(300%); }
}
[dir="rtl"] .dh-progress.is-indeterminate .dh-progress-bar{ animation-name:dh-slide-rtl; }
@keyframes dh-slide-rtl{
  0%{ transform:translateX(100%); }
  100%{ transform:translateX(-300%); }
}
@keyframes dh-pulse{
  0%, 100%{ opacity:1; }
  50%{ opacity:.35; }
}

@media (prefers-reduced-motion: reduce){
  .dh-spinner, .dh-progress.is-indeterminate .dh-progress-bar, #dataHubBtn.dh-busy::after{ animation:none; }
  .dh-progress-bar, .dh-dropzone{ transition:none; }
}

/* ---------- small screens ---------- */

@media (max-width:640px){
  #dataHubOverlay{ padding:0; align-items:stretch; }
  #dataHubOverlay .dh-modal{
    max-width:none;
    max-height:none;
    height:100%;
    border-radius:0;
  }
  .dh-tabs{ padding:0 12px; }
  .dh-modal .modal-head{ padding:14px 16px; }
  .dh-body{ padding:16px; }

  .dh-part-dl{
    grid-template-columns:minmax(0,1fr) auto;
    grid-template-areas:"index size" "name name" "action action";
  }
  .dh-part-dl .dh-part-index{ grid-area:index; }
  .dh-part-dl .dh-part-size{ grid-area:size; }
  .dh-part-dl .dh-part-name{ grid-area:name; white-space:normal; overflow-wrap:anywhere; }
  .dh-part-dl .btn{ grid-area:action; justify-self:start; }

  .dh-part-row{
    grid-template-columns:minmax(0,1fr) auto;
    grid-template-areas:"index state" "main main" "actions actions";
    row-gap:8px;
  }
  .dh-part-row .dh-part-index{ grid-area:index; }
  .dh-part-row .dh-part-state{ grid-area:state; }
  .dh-part-row .dh-part-main{ grid-area:main; }
  .dh-part-row .dh-part-actions{ grid-area:actions; justify-content:flex-start; }

  .dh-apply-row .dh-actions{ margin-inline-start:0; width:100%; }
  .dh-apply-row .dh-actions .btn{ flex:1 1 auto; justify-content:center; }
  .dh-kv{ grid-template-columns:minmax(84px, max-content) minmax(0,1fr); gap:4px 12px; padding:10px 12px; }
}
