﻿/* ==========================================================================
   helpdesk-mobile-app.css — فایل جدید
   مسیر: Plugins/FaraMind.Plugin.HelpDeskSystem/Content/css/helpdesk-mobile-app.css
   باید «بعد از» Styles.css و helpdesk-theme.css لود شود.
   ========================================================================== */

/* روی دسکتاپ هیچ‌کدام از اجزای موبایل دیده نشوند */
.hd-m-tabbar, .hd-m-overlay, .hd-m-sheet {
  display: none;
}

@media (max-width: 768px) {

  /* ---------- حذف منوی قدیمی ---------- */
  .hd-bottom-nav,
  .navbar .mobile-toggle,
  .nav-menu {
    display: none !important;
  }

  .page-header > .btn-primary[onclick^="openAddTicket"] {
    display: none !important;
  }
  /* دکمه + مرکزی جایگزین شد */

  body.hd-m {
    --hd-m-tab-h: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(var(--hd-m-tab-h) + 12px) !important;
  }

  /* ---------- هدر بالا: فشرده ---------- */
  .navbar {
    height: 56px;
  }

  .nav-brand {
    font-size: .95rem;
  }

    .nav-brand i {
      width: 30px;
      height: 30px;
    }

  /* ---------- نوار تب پایین ---------- */
  .hd-m-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    display: flex;
    align-items: stretch;
    height: var(--hd-m-tab-h);
    padding: 0 6px env(safe-area-inset-bottom, 0px);
    background: var(--glass);
    -webkit-backdrop-filter: saturate(170%) blur(18px);
    backdrop-filter: saturate(170%) blur(18px);
    border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
    box-shadow: 0 -10px 30px -12px rgba(30, 36, 48, .25);
    transition: transform .3s var(--ease);
  }

  body.hd-m-kb .hd-m-tabbar {
    transform: translateY(110%);
  }

  .hd-m-tab {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: .68rem;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color .25s, transform .2s var(--ease);
  }

    .hd-m-tab i {
      font-size: 1.4rem;
      line-height: 1;
      transition: transform .35s var(--ease);
    }

    .hd-m-tab span {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 100%;
    }

    .hd-m-tab:active {
      transform: scale(.88);
    }

    .hd-m-tab.active {
      color: var(--primary);
      font-weight: 700;
    }

      .hd-m-tab.active i {
        transform: translateY(-3px) scale(1.12);
        filter: drop-shadow(0 4px 8px rgba(255, 107, 0, .45));
      }

      .hd-m-tab.active::before {
        content: "";
        position: absolute;
        top: 0;
        left: 30%;
        right: 30%;
        height: 3px;
        border-radius: 0 0 99px 99px;
        background: linear-gradient(90deg, var(--primary), var(--secondary));
        animation: hd-grow .3s var(--ease);
      }

  .hd-m-spacer {
    flex: 1 1 0;
  }

  .hd-m-fab {
    flex: 0 0 58px;
    width: 58px;
    height: 58px;
    align-self: flex-start;
    margin: -20px 6px 0;
    display: grid;
    place-items: center;
    border: 4px solid var(--bg);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #fff;
    font-size: 1.7rem;
    box-shadow: var(--glow-orange), 0 8px 20px rgba(0, 0, 0, .18);
    cursor: pointer;
    transition: transform .25s var(--ease);
    -webkit-tap-highlight-color: transparent;
  }

    .hd-m-fab:active {
      transform: scale(.88) rotate(90deg);
    }

  /* ---------- شیت‌ها ---------- */
  .hd-m-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(15, 18, 23, .5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
  }

    .hd-m-overlay.show {
      opacity: 1;
      pointer-events: auto;
    }

  .hd-m-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1110;
    max-height: 86dvh;
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    box-shadow: var(--shadow-lg);
    transform: translateY(105%);
    transition: transform .38s var(--ease);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overscroll-behavior: contain;
  }

    .hd-m-sheet.show {
      transform: none;
    }

  .hd-m-grab {
    width: 42px;
    height: 4px;
    border-radius: 99px;
    background: var(--border);
    margin: 8px auto 0;
  }

  .hd-m-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 8px;
  }

    .hd-m-sheet-head strong {
      font-family: 'iransans-medium', sans-serif;
      font-size: 1rem;
    }

  .hd-m-x {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-muted);
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    cursor: pointer;
  }

  .hd-m-sheet-body {
    overflow-y: auto;
    padding: 4px 14px 18px;
    -webkit-overflow-scrolling: touch;
  }

  body.hd-m-lock {
    overflow: hidden;
  }

  /* شیت «بیشتر» */
  .hd-m-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 6px 16px;
  }

    .hd-m-user strong {
      display: block;
      font-size: .95rem;
    }

    .hd-m-user small {
      color: var(--text-muted);
      font-size: .76rem;
    }

  .hd-m-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: 0 6px 16px -4px rgba(255, 107, 0, .5);
  }

  .hd-m-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .hd-m-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 88px;
    padding: 10px 6px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface-2);
    color: var(--text-dark);
    font-family: inherit;
    font-size: .78rem;
    cursor: pointer;
    transition: transform .2s var(--ease), background .2s, border-color .2s;
  }

    .hd-m-tile i {
      font-size: 1.6rem;
      color: var(--primary);
    }

    .hd-m-tile:active {
      transform: scale(.93);
      background: var(--primary-light);
      border-color: var(--primary);
    }

    .hd-m-tile.danger i {
      color: var(--danger);
    }

  /* شیت اطلاعات تیکت: کارت‌های ستون کناری */
  #hd-m-info .sidebar {
    display: block;
  }

  #hd-m-info .info-card {
    box-shadow: none;
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 12px;
  }

  #hd-m-info .ticket-actions {
    flex-direction: column;
  }

  #hd-m-info .ticket-action-btn {
    width: 100%;
  }

  /* ---------- فیلترهای تیکت‌ها ---------- */
  .hd-m-filter-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text-dark);
    font-family: inherit;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
  }

    .hd-m-filter-toggle i:first-child {
      color: var(--primary);
      font-size: 1.2rem;
    }

  .hd-m-caret {
    margin-right: auto;
    transition: transform .25s;
  }

  .hd-m-filter-toggle.open .hd-m-caret {
    transform: rotate(180deg);
  }

  .hd-m-filters {
    display: none;
    flex-direction: column;
    gap: 10px;
  }

    .hd-m-filters.open {
      display: flex;
      animation: hd-fade-up .3s var(--ease);
    }

    .hd-m-filters .form-control {
      width: 100% !important;
    }

  .ticket-status-filter-menu {
    position: static;
    box-shadow: none;
    margin-top: 6px;
  }

  /* کارت‌های لیست تیکت */
  .table-responsive td[data-label="عنوان"] {
    font-weight: 700;
  }

  .table-responsive td[data-label="عملیات"] {
    justify-content: space-between;
  }

  /* ======================================================================
     جزئیات تیکت — حالت چت تمام‌صفحه
     ====================================================================== */
  body.hd-m-detail {
    padding-bottom: calc(var(--hd-m-comp, 84px) + 14px) !important;
  }

    body.hd-m-detail .navbar,
    body.hd-m-detail .hd-m-tabbar {
      display: none;
    }

    body.hd-m-detail .main-wrapper {
      padding: 0 !important;
    }

    body.hd-m-detail #content-area {
      padding-top: calc(62px + env(safe-area-inset-top, 0px));
    }

      /* هدر ثابت */
      body.hd-m-detail #content-area > .page-header {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 920;
        flex-direction: row !important;
        flex-wrap: nowrap;
        align-items: center !important;
        gap: 8px;
        margin: 0 !important;
        min-height: 58px;
        padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 6px !important;
        background: var(--glass);
        -webkit-backdrop-filter: saturate(170%) blur(16px);
        backdrop-filter: saturate(170%) blur(16px);
        border-bottom: 1px solid var(--border);
        box-shadow: 0 6px 18px -12px rgba(0, 0, 0, .35);
        animation: none;
      }

        body.hd-m-detail #content-area > .page-header::after {
          content: "";
          position: absolute;
          left: 0;
          right: 0;
          bottom: -1px;
          height: 2px;
          background: linear-gradient(90deg, var(--primary), var(--secondary) 60%, transparent);
        }

    body.hd-m-detail .page-header > div:first-child {
      flex: 1 1 auto;
      min-width: 0;
      gap: 8px !important;
    }

      body.hd-m-detail .page-header > div:first-child > div {
        min-width: 0;
      }

    body.hd-m-detail .page-title {
      padding-right: 0;
      font-size: .92rem !important;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

      body.hd-m-detail .page-title::before {
        display: none;
      }

    body.hd-m-detail .ticket-back-button {
      flex: 0 0 40px;
      width: 40px;
      min-height: 40px;
      padding: 0 !important;
      border-radius: 50%;
    }

    body.hd-m-detail .ticket-header-meta small:first-child {
      display: none;
    }

    body.hd-m-detail .page-header > .badge {
      flex: 0 0 auto;
      cursor: pointer;
      font-size: .68rem;
      padding: .35rem .6rem;
    }

  .hd-m-info-btn {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--primary);
    font-size: 1.25rem;
    cursor: pointer;
  }

    .hd-m-info-btn:active {
      transform: scale(.9);
    }

  /* گفتگو بدون کادر */
  body.hd-m-detail .detail-grid {
    display: block !important;
  }

    body.hd-m-detail .detail-grid > .card {
      border: 0;
      border-radius: 0;
      background: transparent;
      box-shadow: none;
      margin: 0;
      overflow: visible;
    }

  body.hd-m-detail .conversation-header {
    display: none !important;
  }

  body.hd-m-detail .chat-wrapper {
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible;
    background: transparent;
    padding: 12px 10px 6px;
    gap: 12px;
  }

  body.hd-m-detail .msg-box {
    max-width: calc(100% - 46px);
  }

  body.hd-m-detail .msg-content {
    font-size: .92rem;
  }

  /* کادر پاسخ چسبیده به پایین */
  body.hd-m-detail .reply-area {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--hd-kb, 0px);
    z-index: 910;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--glass);
    -webkit-backdrop-filter: saturate(170%) blur(16px);
    backdrop-filter: saturate(170%) blur(16px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -10px 26px -12px rgba(0, 0, 0, .3);
    border-radius: 20px 20px 0 0;
  }

  body.hd-m-kb.hd-m-detail .reply-area {
    padding-bottom: 8px;
  }

  body.hd-m-detail .reply-area form {
    padding: 0;
    display: block;
  }

  body.hd-m-detail .reply-area .ql-toolbar.ql-snow {
    display: none !important;
  }

  body.hd-m-detail .reply-area.hd-m-tb-open .ql-toolbar.ql-snow {
    display: flex !important;
  }

  body.hd-m-detail .reply-area .ql-container.ql-snow {
    border-radius: 18px;
    background: var(--surface);
  }

  body.hd-m-detail .reply-area .ql-toolbar.ql-snow + .ql-container.ql-snow {
    border-radius: 0 0 14px 14px;
  }

  body.hd-m-detail .reply-area .ql-editor {
    min-height: 44px;
    max-height: 26dvh;
    padding: 10px 14px;
    font-size: 16px;
  }

  body.hd-m-detail .reply-actions {
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    margin-top: 6px;
    gap: 8px;
  }

  body.hd-m-detail .reply-tools {
    width: auto !important;
    flex: 1 1 auto;
    flex-wrap: nowrap;
  }

    body.hd-m-detail .reply-tools .btn {
      width: 42px !important;
      min-width: 42px;
      min-height: 42px;
      padding: 0;
      border-radius: 50%;
    }

  body.hd-m-detail .reply-actions > button[type="submit"] {
    width: 48px !important;
    min-width: 48px !important;
    height: 48px;
    min-height: 48px;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
    gap: 0;
    justify-content: center;
  }

    body.hd-m-detail .reply-actions > button[type="submit"] i {
      font-size: 1.4rem;
      margin: 0;
    }

  body.hd-m-detail .reply-area.text-muted {
    text-align: center;
    font-size: .85rem;
  }

  body.hd-m-detail .ticket-emoji-picker {
    bottom: calc(var(--hd-m-comp, 84px) + var(--hd-kb, 0px) + 8px);
  }

  body.hd-m-detail .ticket-selected-files {
    margin-top: 6px;
  }

  /* حرکت نرم پیام‌ها */
  body.hd-m-detail .msg-container {
    animation-duration: .3s;
  }

  /* ======================================================================
     اصلاحات: هدر دو‌خطی + کادر پاسخ به سبک تلگرام
     ====================================================================== */

  /* ---- هدر دو‌خطی: خط ۱ = برگشت | عنوان | ⓘ ، خط ۲ = اطلاعات | وضعیت ---- */
  body.hd-m-detail #content-area {
    padding-top: calc(80px + env(safe-area-inset-top, 0px));
  }

    body.hd-m-detail #content-area > .page-header {
      display: grid !important;
      grid-template-columns: auto minmax(0, 1fr) auto;
      grid-template-areas:
        "back title info"
        "back meta  badge";
      align-items: center !important;
      column-gap: 10px;
      row-gap: 2px;
      min-height: 68px;
      padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 8px !important;
    }

      /* دیوارهای میانی حذف می‌شوند تا هر المان در گرید جای خودش بنشیند */
      body.hd-m-detail #content-area > .page-header > div:first-child,
      body.hd-m-detail #content-area > .page-header > div:first-child > div {
        display: contents !important;
      }

  body.hd-m-detail .ticket-back-button {
    grid-area: back;
    align-self: center;
  }

  body.hd-m-detail .page-header .page-title {
    grid-area: title;
    min-width: 0;
    line-height: 1.5;
  }

  body.hd-m-detail .ticket-header-meta {
    grid-area: meta;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: .72rem;
    line-height: 1.4;
  }

    body.hd-m-detail .ticket-header-meta small {
      display: inline !important;
      overflow: hidden;
      text-overflow: ellipsis;
      font-size: inherit;
    }

  body.hd-m-detail .page-header > .badge {
    grid-area: badge;
    justify-self: end;
    white-space: nowrap;
  }

  body.hd-m-detail .hd-m-info-btn {
    grid-area: info;
  }

  /* ---- کادر پاسخ: همیشه دیده شود، ثابت پایین، مثل تلگرام ---- */
  body.hd-m-detail .reply-area {
    display: block !important;
    visibility: visible !important;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
  }

    /* یک ردیف: [ابزارها] [ورودی متن] [ارسال] */
    body.hd-m-detail .reply-area form {
      display: grid !important;
      grid-template-columns: auto minmax(0, 1fr) auto;
      align-items: end;
      column-gap: 6px;
      padding: 0;
      margin: 0;
    }

      body.hd-m-detail .reply-area form > * {
        grid-column: 2;
        grid-row: 3;
        min-width: 0;
      }

      body.hd-m-detail .reply-area form > .ql-toolbar.ql-snow {
        grid-column: 1 / -1;
        grid-row: 1;
        margin-bottom: 6px;
        border-radius: 14px;
      }

      body.hd-m-detail .reply-area form > .ticket-selected-files {
        grid-column: 1 / -1;
        grid-row: 2;
        margin: 0 0 6px;
      }

      body.hd-m-detail .reply-area form > .reply-actions {
        display: contents !important;
      }

    body.hd-m-detail .reply-area .reply-tools {
      grid-column: 1;
      grid-row: 3;
      display: flex;
      align-items: center;
      gap: 2px;
      width: auto !important;
      align-self: end;
    }

      body.hd-m-detail .reply-area .reply-tools .btn {
        width: 38px !important;
        min-width: 38px;
        height: 38px;
        min-height: 38px;
        padding: 0;
        border: 0;
        background: transparent;
        color: var(--text-muted);
        border-radius: 50%;
        font-size: 1.3rem;
      }

        body.hd-m-detail .reply-area .reply-tools .btn i {
          font-size: 1.3rem;
        }

    body.hd-m-detail .reply-area .reply-actions > button[type="submit"] {
      grid-column: 3;
      grid-row: 3;
      align-self: end;
      width: 44px !important;
      min-width: 44px !important;
      height: 44px;
      min-height: 44px;
      margin: 0;
      border-radius: 50%;
    }

    body.hd-m-detail .reply-area .ql-container.ql-snow,
    body.hd-m-detail .reply-area textarea#ticketReplyMessage {
      width: 100%;
      border: 1.5px solid var(--border);
      border-radius: 22px;
      background: var(--surface);
    }

    body.hd-m-detail .reply-area textarea#ticketReplyMessage {
      min-height: 44px;
      max-height: 26dvh;
      padding: 11px 14px;
      font-size: 16px;
      resize: none;
      display: block;
    }

    /* قالب‌بندی باز شده، ظاهر کادر را به‌هم نریزد */
    body.hd-m-detail .reply-area .ql-toolbar.ql-snow + .ql-container.ql-snow {
      border-radius: 22px;
    }
}

/* ==========================================================================
   کادر پاسخ — دسکتاپ و موبایل: اگر ادیتور ارتفاع نداشته باشد دیده نمی‌شود
   ========================================================================== */
.reply-area .ql-editor {
  min-height: 90px;
}

.reply-area textarea#ticketReplyMessage {
  display: block;
  width: 100%;
  min-height: 90px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-dark);
  font-family: inherit;
  resize: vertical;
}

/* ==========================================================================
   بهبودهای عمومی UI: دکمه‌های آیکنی، دکمه نصب، فرم فاکتور
   ========================================================================== */
.row-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.btn.btn-icon,
.btn.btn-sm.btn-icon {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  font-size: 1.05rem;
  line-height: 1;
}

.hd-install-btn {
  position: fixed;
  z-index: 1200;
  left: 14px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--secondary);
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  cursor: pointer;
  opacity: .92;
  transition: transform .2s, opacity .2s;
}

  .hd-install-btn:hover {
    opacity: 1;
    transform: translateY(-2px);
  }

.inv-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.inv-section {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2, var(--surface));
}

  .inv-section .form-group:last-child {
    margin-bottom: 0;
  }

.inv-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 700;
}

  .inv-section-title i {
    color: var(--primary);
  }

.inv-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.inv-req {
  color: var(--danger);
}

.inv-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

  .inv-seg label {
    margin: 0;
    cursor: pointer;
  }

  .inv-seg input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  .inv-seg span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 38px;
    border-radius: 9px;
    font-size: .88rem;
    color: var(--text-muted);
    transition: background .2s, color .2s;
  }

  .inv-seg input:checked + span {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
  }

  .inv-seg input:focus-visible + span {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

.invoice-item-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, .8fr) minmax(0, 1.2fr);
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

  .invoice-item-row .inv-field label {
    display: block;
    margin-bottom: 4px;
    font-size: .76rem;
    color: var(--text-muted);
  }

  .invoice-item-row .inv-field-desc,
  .invoice-item-row .inv-row-foot {
    grid-column: 1 / -1;
  }

.inv-row-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: .82rem;
  color: var(--text-muted);
}

  .inv-row-foot strong {
    color: var(--text-dark);
  }

.inv-remove {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--danger);
  font-size: 1.1rem;
  cursor: pointer;
}

  .inv-remove:hover {
    background: rgba(239, 68, 68, .1);
  }

.inv-footer {
  position: sticky;
  bottom: -20px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -20px -20px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.inv-summary {
  display: flex;
  flex-direction: column;
  font-size: .76rem;
  color: var(--text-muted);
}

  .inv-summary strong {
    font-size: 1.05rem;
    color: var(--text-dark);
  }

.inv-footer .btn-primary {
  min-width: 150px;
  min-height: 44px;
}

@media (max-width: 768px) {
  .inv-grid-2 {
    grid-template-columns: 1fr;
  }

  .invoice-item-row {
    grid-template-columns: 1fr 1fr;
  }

    .invoice-item-row .inv-field-service {
      grid-column: 1 / -1;
    }

  .inv-footer .btn-primary {
    flex: 1 1 auto;
  }

  .btn.btn-icon,
  .btn.btn-sm.btn-icon {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }

  .hd-install-btn {
    width: 36px;
    height: 36px;
    font-size: 1.05rem;
    bottom: calc(var(--hd-m-tab-h, 64px) + 10px);
    left: 10px;
    opacity: .85;
  }

  body.hd-m-detail .hd-install-btn {
    display: none;
  }

  /* ======================================================================
     جزئیات تیکت: هدر کامل، چت قابل اسکرول، کادر پاسخ ثابت مثل تلگرام
     ====================================================================== */
  html:has(body.hd-m-detail) {
    overflow: hidden;
  }

  body.hd-m-detail {
    overflow: hidden;
    padding-bottom: 0 !important;
    height: 100dvh;
  }

    body.hd-m-detail #bale-connect-banner {
      display: none !important;
    }

    body.hd-m-detail #content-area {
      position: fixed;
      inset: var(--hd-m-viewport-top, 0px) 0 auto;
      height: var(--hd-m-viewport-height, 100dvh);
      display: grid;
      grid-template-rows: auto minmax(0, 1fr);
      padding: 0;
      overflow: hidden;
      background: var(--surface-2);
      isolation: isolate;
    }

    body.hd-m-detail #content-area > .page-header {
      position: relative !important;
      top: auto;
      left: auto;
      right: auto;
      grid-template-columns: auto minmax(0, 1fr) auto auto;
      grid-template-areas:
        "back title badge info"
        "back meta  meta  meta";
      min-height: 64px;
    }

    body.hd-m-detail #content-area > .detail-grid {
      min-height: 0;
      height: 100%;
      overflow: hidden;
      animation: none;
      transform: none;
    }

    body.hd-m-detail .detail-grid > .card {
      display: flex;
      flex-direction: column;
      min-height: 0;
      height: 100%;
      overflow: hidden !important;
      animation: none;
      transform: none;
    }

    body.hd-m-detail .ticket-header-meta {
      flex-wrap: nowrap;
      gap: 8px;
    }

      body.hd-m-detail .ticket-header-meta small:first-child {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      body.hd-m-detail .ticket-header-meta .ticket-created-at {
        flex: 0 0 auto;
        display: inline-flex !important;
        align-items: center;
        gap: 3px;
      }

    body.hd-m-detail .page-header > .badge {
      justify-self: end;
    }

    body.hd-m-detail .chat-wrapper {
      position: static;
      flex: 1 1 0;
      width: 100%;
      height: auto;
      overflow-y: auto !important;
      overflow-x: hidden;
      overscroll-behavior: contain;
      -webkit-overflow-scrolling: touch;
      scroll-behavior: auto;
      padding: 12px 10px 14px;
      box-sizing: border-box;
      background: radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--primary) 5%, transparent), transparent 65%), var(--surface-2);
    }

    body.hd-m-detail .msg-container {
      flex-shrink: 0;
      min-width: 0;
    }

    body.hd-m-detail .msg-box {
      min-width: 0;
    }

    body.hd-m-detail .msg-content {
      overflow-wrap: anywhere;
    }

    body.hd-m-detail .msg-content pre {
      max-width: 100%;
      overflow-x: auto;
    }

    body.hd-m-detail .reply-area {
      position: relative;
      left: auto;
      right: auto;
      bottom: auto;
      flex: 0 0 auto;
      min-height: 0;
      box-sizing: border-box;
      max-height: 55%;
      overflow: auto;
      background: var(--surface);
      box-shadow: 0 -4px 16px -12px rgba(0, 0, 0, .25);
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }

    body.hd-m-detail .reply-area .ql-editor,
    body.hd-m-detail .reply-area textarea#ticketReplyMessage {
      min-height: 44px;
      max-height: min(140px, 22dvh);
      overflow-y: auto;
      overscroll-behavior: contain;
    }

    body.hd-m-detail .reply-area .ql-container.ql-snow {
      height: auto;
      min-width: 0;
    }

    body.hd-m-detail .reply-area .ql-toolbar.ql-snow {
      flex-wrap: wrap;
      max-height: 100px;
      overflow-y: auto;
    }

    body.hd-m-detail .ticket-selected-files {
      max-height: 72px;
      overflow-y: auto;
    }

    body.hd-m-detail .ticket-selected-files:empty {
      display: none;
    }

    body.hd-m-detail .ticket-emoji-picker {
      top: auto;
      bottom: calc(var(--hd-m-comp, 64px) + var(--hd-kb, 0px) + 8px);
      max-height: 45%;
      max-width: calc(100% - 20px);
      overflow-y: auto;
    }
}
