/*
 * Neshatco layout fixes. Perfex loads assets/css/custom.css on admin and client pages after its
 * own styles and keeps it across upgrades.
 */

/* Tab bars (project tabs and others) in the right-to-left layout: one row that you swipe
   sideways. Perfex turns off its scrolling tab bar in right-to-left (init_tabs_scrollable), so
   the tabs fell back to floats and wrapped onto several uneven lines. */
[dir="rtl"] .horizontal-tabs > .nav-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
[dir="rtl"] .horizontal-tabs > .nav-tabs::-webkit-scrollbar {
  display: none;
}
[dir="rtl"] .horizontal-tabs > .nav-tabs > li {
  float: none;
  flex: 0 0 auto;
}
[dir="rtl"] .horizontal-tabs > .nav-tabs > li > a {
  white-space: nowrap;
}

/* Phones: the page never scrolls sideways. A few pixels of overflow (from right-to-left offsets
   and wide widgets) made the whole page shift sideways on the dashboard and project pages.
   Wide tables keep their own horizontal scroll inside .table-responsive. */
@media (max-width: 768px) {
  /* hidden on html applies to the window; clip on body cuts overflow without turning body
     into its own scroll box (overflow-x: hidden there made body, not the window, scroll). */
  html {
    overflow-x: hidden;
  }
  body {
    overflow-x: clip;
  }
}

/* Phones, sidebar open: the sidebar scrolls on its own and the page behind it stays still.
   Before, a sidebar taller than a short page stretched the page, and scrolling showed an empty
   area below the content. */
@media (max-width: 768px) {
  body.page-small.show-sidebar #menu {
    position: fixed;
    top: 0;
    bottom: 0;
    height: auto !important;
    min-height: 0 !important;
    max-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  html:has(body.page-small.show-sidebar),
  body.page-small.show-sidebar {
    overflow: hidden;
  }
}

/* Lists in task comments and descriptions show their bullets and numbers again (the Tailwind
   base styles remove them). */
.comment-content ul,
.tc-content ul,
#task_view_description ul {
  list-style: disc;
  padding-inline-start: 1.5em;
  margin: 0.25em 0 0.5em;
}
.comment-content ol,
.tc-content ol,
#task_view_description ol {
  list-style: decimal;
  padding-inline-start: 1.5em;
  margin: 0.25em 0 0.5em;
}
.comment-content p,
#task_view_description p {
  margin: 0 0 0.5em;
}

/* Replies to task comments (my_functions_helper.php, "Replies to task comments"): indented under
   their comment, with a line on the side where the thread starts. */
.task-comment.neshatco-comment-reply,
.neshatco-reply-form.neshatco-comment-reply {
  margin-inline-start: 40px;
  padding-inline-start: 14px;
  border-inline-start: 2px solid #e2e8f0;
}
.task-comment.neshatco-comment-reply {
  padding-top: 8px;
}
.neshatco-reply-link {
  text-decoration: none;
}
@media (max-width: 767px) {
  .task-comment.neshatco-comment-reply,
  .neshatco-reply-form.neshatco-comment-reply {
    margin-inline-start: 16px;
  }
}
.neshatco-reply-editor {
  position: relative;
}
.neshatco-reply-form .neshatco-reply-attach {
  margin-inline-end: auto;
}
.neshatco-reply-form .neshatco-mention-list {
  inset-inline-start: 0;
  inset-inline-end: auto;
  left: auto;
  right: auto;
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
}
[dir="rtl"] .neshatco-reply-form .neshatco-mention-list,
.rtl .neshatco-reply-form .neshatco-mention-list {
  right: 0;
}
html:not([dir="rtl"]) body:not(.rtl) .neshatco-reply-form .neshatco-mention-list {
  left: 0;
}

/* Mentions take the direction of the name: "@Sina Neshat" keeps its @ in front inside Persian
   text, and a Persian name reads right to left. */
.comment-content span.mention,
.mention {
  unicode-bidi: plaintext;
}

/* "task 443" / "comment 250" links in comments and descriptions. */
a.neshatco-task-ref {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  unicode-bidi: isolate;
}
.task-comment.neshatco-ref-flash {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
  transition: box-shadow 0.3s;
}

/* Milestone filter on a project's Tasks tab: before the rows-per-page box; a full row on phones. */
.neshatco-milestone-filter {
  display: inline-block;
  vertical-align: middle;
  margin-inline-end: 6px;
  margin-bottom: 6px;
}
.neshatco-milestone-filter select {
  width: auto;
  min-width: 160px;
  max-width: 260px;
  display: inline-block;
}
.neshatco-milestone-filter select.neshatco-milestone-filter-active {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb;
}
@media (max-width: 767px) {
  /* Perfex pins the rows-per-page box to the left of this row on phones: sit beside it. */
  .neshatco-milestone-filter {
    display: block;
    margin-inline-end: 0;
    margin-left: 92px;
  }
  .neshatco-milestone-filter select {
    width: 100%;
    max-width: none;
  }
}

/* Approvals (my_functions_helper.php, "Approvals"). */
.neshatco-approval-status {
  background: transparent;
  font-weight: 600;
}
.neshatco-approval .neshatco-approval-decision {
  background: #f8fafc;
  border-inline-start: 3px solid #94a3b8;
}
.neshatco-approval-approved .neshatco-approval-decision { border-inline-start-color: #16a34a; }
.neshatco-approval-rejected .neshatco-approval-decision { border-inline-start-color: #dc2626; }
.neshatco-approval-pending { border-inline-start: 3px solid #d97706; }
.neshatco-approval .comment-content p:last-child { margin-bottom: 0; }
.neshatco-approvals-project select { max-width: 260px; }
@media (max-width: 767px) {
  .neshatco-approvals-project, .neshatco-approvals-project select { width: 100%; max-width: none; }
  .neshatco-approval .btn-success, .neshatco-approval .btn-danger { flex: 1 1 0; }
}
.neshatco-approval-answered .neshatco-approval-decision { border-inline-start-color: #2563eb; }
.neshatco-approval-kind {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  font-weight: 600;
}
@media (max-width: 767px) {
  .neshatco-approval .btn-primary[value=answered] { flex: 1 1 0; }
}
/* Dashboard widget: requests waiting for you. */
.neshatco-approvals-widget .neshatco-aw-item {
  display: block;
  padding: 8px 6px;
  border-top: 1px solid #f1f5f9;
  color: inherit;
}
.neshatco-approvals-widget .neshatco-aw-item:hover { background: #f8fafc; text-decoration: none; }
.neshatco-approvals-widget .neshatco-aw-title { font-weight: 600; color: #1e293b; overflow-wrap: anywhere; }
.neshatco-approvals-widget .neshatco-aw-meta { font-size: 12px; color: #64748b; overflow-wrap: anywhere; }
.neshatco-approvals-widget .neshatco-aw-heading { font-size: 13px; font-weight: 600; color: #475569; margin: 10px 6px 4px; }
/* Reports: new / seen markers (reports widget, lists). */
.neshatco-reports-widget .neshatco-aw-item { display: flex; align-items: flex-start; gap: 8px; }
.neshatco-reports-widget .neshatco-aw-item form { margin: 0; }
.neshatco-report-new { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; font-weight: 600; }
.neshatco-report-seen-label { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
/* Files on approvals and questions: a grid of images, videos and audio full width, file chips. */
.neshatco-approval-files .naf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.neshatco-approval-files .naf-cell, .neshatco-approval-files .naf-media, .neshatco-approval-files .naf-file-wrap { position: relative; }
.neshatco-approval-files .naf-image {
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}
.neshatco-approval-files .naf-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.neshatco-approval-files .naf-media { margin-bottom: 8px; }
.neshatco-approval-files video {
  width: 100%;
  max-height: 70vh;
  border-radius: 6px;
  background: #000;
  display: block;
}
.neshatco-approval-files audio { width: 100%; display: block; }
.neshatco-approval-files .naf-caption { font-size: 12px; color: #64748b; margin-top: 3px; overflow-wrap: anywhere; }
.neshatco-approval-files .naf-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.neshatco-approval-files .naf-size { color: #94a3b8; font-size: 12px; white-space: nowrap; }
.neshatco-approval-files .naf-delete { position: absolute; top: 4px; inset-inline-end: 4px; margin: 0; }
.neshatco-approval-files .naf-file-wrap .naf-delete { position: static; display: inline-block; }
.neshatco-approval-upload input[type=file] { height: auto; padding: 6px; }
@media (max-width: 767px) {
  .neshatco-approval-files .naf-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Project notification levels (neshatco_notifications_helper.php). */
.neshatco-notify-menu { padding: 12px 14px; min-width: 300px; max-width: calc(100vw - 32px); }
.neshatco-notify-menu label { white-space: normal; }
.neshatco-notify-default { border-top: 1px dashed #e2e8f0; padding-top: 10px; margin-left: 0; margin-right: 0; }
.neshatco-notify-default > [class*=col-] { padding-left: 0; padding-right: 0; }
.neshatco-notify-row select { margin-bottom: 6px; }
.neshatco-notify-save { position: sticky; bottom: 0; padding: 10px 0; background: #f8fafc; z-index: 2; }
@media (min-width: 768px) {
  .neshatco-notify-default > [class*=col-] { padding-left: 15px; padding-right: 15px; }
  .neshatco-notify-default { margin-left: -15px; margin-right: -15px; border-top: 1px dashed #e2e8f0; }
}
/* Agent docs (neshatco_project_docs_helper.php). */
.neshatco-docs-intro { max-width: 720px; }
.neshatco-docs-list li + li { border-top: 1px solid #f1f5f9; }
.neshatco-docs-list a { padding: 12px 16px; color: inherit; }
.neshatco-docs-list a:hover { background: #f8fafc; text-decoration: none; }
.neshatco-docs-list .tw-font-semibold { overflow-wrap: anywhere; }
.neshatco-doc-body { overflow-wrap: anywhere; line-height: 1.7; }
.neshatco-doc-body h1 { font-size: 1.5em; } .neshatco-doc-body h2 { font-size: 1.3em; } .neshatco-doc-body h3 { font-size: 1.15em; }
.neshatco-doc-body pre, .neshatco-doc-pre { white-space: pre-wrap; overflow-x: auto; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 10px; font-size: 13px; }
.neshatco-doc-body code { background: #f1f5f9; padding: 1px 4px; border-radius: 4px; }
.neshatco-doc-body pre code { background: none; padding: 0; }
.neshatco-doc-body table { width: 100%; display: block; overflow-x: auto; border-collapse: collapse; }
.neshatco-doc-body th, .neshatco-doc-body td { border: 1px solid #e2e8f0; padding: 4px 8px; }
.neshatco-doc-body img { max-width: 100%; }
.neshatco-doc-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.55; }
.neshatco-doc-head h4 { overflow-wrap: anywhere; }
/* Deploy/publish approval badge above a project's tabs. */
.neshatco-deploy-badge { display: inline-block; margin-bottom: 8px; margin-inline-end: 6px; padding: 6px 10px; font-size: 12px; font-weight: 600; border: 1px solid; background: transparent; vertical-align: middle; }
.neshatco-deploy-ask { color: #b45309; border-color: #f59e0b; }
.neshatco-deploy-auto { color: #15803d; border-color: #22c55e; }
.neshatco-notify-project { display: inline-block; vertical-align: middle; }
/* Project secrets in Infisical (neshatco_secrets_helper.php). */
.neshatco-secrets-intro { max-width: 760px; }
.neshatco-secrets h4, .neshatco-secrets h5 { overflow-wrap: anywhere; }
.neshatco-secrets code, .neshatco-secrets-email { overflow-wrap: anywhere; word-break: break-all; }
.neshatco-secrets-env { display: inline-block; min-width: 150px; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 6px; background: #f8fafc; font-size: 13px; }
.neshatco-secrets-env-prod { border-color: #fcd34d; background: #fffbeb; }
.neshatco-secrets-sync { padding: 10px 12px; border-radius: 6px; background: #f0fdf4; border: 1px solid #bbf7d0; }
.neshatco-secrets-sync.neshatco-secrets-sync-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.neshatco-secrets pre, pre.neshatco-secrets-sync-error { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; font-size: 12px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 10px; }
.neshatco-secrets-sync pre { background: #fff; color: #7f1d1d; }
.neshatco-secrets-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 0; }
.neshatco-secrets-list li + li { border-top: 1px solid #f1f5f9; }
.neshatco-secrets-list .label { white-space: normal; }
.neshatco-secrets-agents li { padding: 12px 16px; }
.neshatco-secrets-agents li + li { border-top: 1px solid #f1f5f9; }
.neshatco-secrets-token { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.neshatco-secrets-issued { border: 1px solid #fcd34d; }
.neshatco-secrets-existing-form .form-control { flex: 1 1 220px; min-width: 0; }
.neshatco-secrets-code { direction: ltr; text-align: left; }
@media (max-width: 767px) {
  .neshatco-secrets-env { flex: 1 1 100%; }
}
/* Results and reports (neshatco_reports_helper.php). */
.neshatco-report-state { background: transparent; font-weight: 600; }
.neshatco-report-type { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; font-weight: 600; }
.neshatco-report-missing { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; font-weight: 600; }
.neshatco-report-awaiting_review { border-inline-start: 3px solid #d97706; }
.neshatco-report-shared { border-inline-start: 3px solid #16a34a; }
.neshatco-report-title, .neshatco-report-summary, .neshatco-report-links { overflow-wrap: anywhere; }
.neshatco-report-summary h1, .neshatco-report-summary h2, .neshatco-report-summary h3 { font-size: 15px; font-weight: 600; margin: 14px 0 6px; }
.neshatco-report-summary img { max-width: 100%; }
.neshatco-report-summary table { width: 100%; display: block; overflow-x: auto; border-collapse: collapse; }
.neshatco-report-summary th, .neshatco-report-summary td { border: 1px solid #e2e8f0; padding: 4px 8px; }
.neshatco-report-summary pre { white-space: pre-wrap; overflow-x: auto; }
.neshatco-report-metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.neshatco-report-metrics .nrm-item { border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px 10px; background: #f8fafc; min-width: 0; }
.neshatco-report-metrics .nrm-value { font-size: 20px; font-weight: 600; color: #0f172a; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.neshatco-report-metrics .nrm-label { font-size: 12px; color: #64748b; overflow-wrap: anywhere; }
.neshatco-report-links li { padding: 3px 0; }
.neshatco-report-internal { background: #fffbeb; border: 1px solid #fde68a; color: #78350f; }
.neshatco-report-internal .tc-content p:last-child { margin-bottom: 0; }
.neshatco-report-list .neshatco-report-item { display: block; padding: 12px 16px; color: inherit; }
.neshatco-report-list .neshatco-report-row { position: relative; border-top: 1px solid #f1f5f9; }
.neshatco-report-list .neshatco-report-row:first-child { border-top: 0; }
.neshatco-report-list .neshatco-report-row.has-seen .neshatco-report-item { padding-bottom: 40px; }
.neshatco-report-list .nri-seen { position: absolute; bottom: 10px; inset-inline-end: 16px; margin: 0; }
.neshatco-report-list .neshatco-report-item:hover { background: #f8fafc; text-decoration: none; }
.neshatco-report-item .nri-title { font-weight: 600; color: #1e293b; overflow-wrap: anywhere; }
.neshatco-report-item .nri-meta { font-size: 12px; color: #64748b; overflow-wrap: anywhere; }
.neshatco-report-item .nri-metrics { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: #475569; margin-top: 4px; }
.neshatco-report-item .nri-preview { font-size: 13px; color: #475569; margin-top: 4px; overflow-wrap: anywhere; }
.neshatco-report-item .nri-thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid #e2e8f0; flex: none; }
.neshatco-report-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.neshatco-report-filters .form-control { width: auto; max-width: 220px; flex: 0 1 auto; }
.neshatco-report-types .nrt-item { padding: 12px 16px; border-top: 1px solid #f1f5f9; }
.neshatco-report-types .nrt-item:first-child { border-top: 0; }
.neshatco-report-types .label { font-weight: 500; }
.nrt-template, .nrt-language { width: auto; flex: 1 1 160px; }
.neshatco-report-comments .nrc-item { padding: 10px 0; border-top: 1px solid #f1f5f9; }
.neshatco-report-comments .nrc-item:first-of-type { border-top: 0; }
.neshatco-report-comments .nrc-internal { background: #f8fafc; padding-inline: 10px; border-radius: 6px; }
.neshatco-report-comments .nrc-client { border-inline-start: 3px solid #0ea5e9; padding-inline-start: 10px; }
.neshatco-report-comments .tc-content p:last-child { margin-bottom: 0; }
.neshatco-report-comments-portal { margin-top: -12px; }
.neshatco-report-form .nrf-metric .form-control:first-child { flex: 2 1 0; }
.neshatco-report-form .nrf-metric .form-control:last-child { flex: 1 1 0; }
.neshatco-task-reports li { overflow-wrap: anywhere; }
@media (max-width: 767px) {
  .neshatco-report-filters .form-control, .neshatco-report-filters .btn { width: 100%; max-width: none; flex: 1 1 100%; }
  .neshatco-report-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .neshatco-report-actions .btn { flex: 1 1 auto; }
  .neshatco-report-actions form { flex: 1 1 auto; }
  .neshatco-report-actions form .btn { width: 100%; }
}
.neshatco-report-state i, .neshatco-report-missing i { margin-inline-end: 3px; }
/* Count badges on a selected filter button stay readable. */
.btn-primary .badge { background: #fff !important; color: #1d4ed8 !important; }
/* Reports: Persian/Arabic text right to left; English words, links and ids isolated (task 565). */
.neshatco-rtl { direction: rtl; text-align: right; }
.neshatco-rtl bdi { unicode-bidi: isolate; }
/* Links and code take their own direction from their text (a URL stays left to right, a Persian label right to left). */
.neshatco-rtl a, .neshatco-rtl code { unicode-bidi: plaintext; }
.neshatco-rtl ul, .neshatco-rtl ol { padding-left: 0; padding-right: 1.6em; }
.neshatco-rtl.neshatco-report-links, .neshatco-rtl ul.list-unstyled { padding-right: 0; }
.neshatco-rtl h1, .neshatco-rtl h2, .neshatco-rtl h3, .neshatco-rtl h4, .neshatco-rtl h5, .neshatco-rtl h6 { text-align: right; }
/* Reports: images large, at the content's width; two columns when several (task 568). */
.neshatco-approval-files .naf-grid.naf-large { grid-template-columns: 1fr; }
.neshatco-approval-files .naf-grid.naf-large.naf-count-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.neshatco-approval-files .naf-large .naf-image { aspect-ratio: auto; background: #f8fafc; }
.neshatco-approval-files .naf-large .naf-image img { width: 100%; height: auto; max-height: 75vh; object-fit: contain; }
.neshatco-approval-files .naf-large.naf-count-2 .naf-image img { max-height: 420px; }
