/* مكتب الدعم الفني — لوحة الإدارة */
#desk { --pr: #006853; --gold: #C9A227; --line: #E6DCC8; --mut: #7A7160; --soft: #F8F5EE; font-size: 14px; }
.dk-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.dk-tabs { display: flex; gap: 4px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 4px; flex-wrap: wrap; }
.dk-tabs button { border: 0; background: transparent; font: inherit; font-weight: 700; padding: 7px 12px; border-radius: 9px; cursor: pointer; color: var(--mut); }
.dk-tabs button.on { background: #fff; color: var(--pr); box-shadow: 0 2px 6px rgba(0,0,0,.07); }
.dk-tabs i { font-style: normal; font-size: 11.5px; background: #E9E2D2; color: #5A513F; border-radius: 9px; padding: 1px 7px; margin-inline-start: 3px; }
.dk-tabs button.on i { background: var(--pr); color: #fff; }
.dk-search { flex: 1; min-width: 180px; font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.dk-live { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: #146C3A; font-size: 13px; }
.dk-live b { width: 9px; height: 9px; border-radius: 50%; background: #22A55B; box-shadow: 0 0 0 3px rgba(34,165,91,.2); }
.dk-icon { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 6px 10px; cursor: pointer; font-size: 16px; line-height: 1; }

.dk-body { display: grid; grid-template-columns: 300px minmax(0, 1fr) 270px; height: min(78vh, 760px); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #fff; }
.dk-list { border-inline-end: 1px solid var(--line); overflow-y: auto; background: #FCFBF7; }
.dk-item { display: flex; gap: 10px; width: 100%; text-align: start; border: 0; border-bottom: 1px solid #F0EADD; background: transparent; padding: 11px 12px; cursor: pointer; font: inherit; color: inherit; }
.dk-item:hover { background: #F6F1E5; }
.dk-item.on { background: #E9F4EF; box-shadow: inset -3px 0 0 var(--pr); }
.dk-item.unread .dk-row b::after { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #D93A4A; margin-inline-start: 6px; vertical-align: middle; }
.dk-av { position: relative; width: 38px; height: 38px; border-radius: 50%; background: var(--pr); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dk-av i.on { position: absolute; bottom: -1px; left: -1px; width: 11px; height: 11px; border-radius: 50%; background: #22A55B; border: 2px solid #fff; }
.dk-it { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.dk-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.dk-row small { color: var(--mut); font-size: 11.5px; white-space: nowrap; }
.dk-prev { color: #5E5647; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dk-row.tags { justify-content: flex-start; flex-wrap: wrap; }
.dk-row em, .dk-who em { font-style: normal; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 8px; background: #EEE8DA; color: #5A513F; }
em.wait { background: #FFF1D6; color: #8A5A00; } em.wait.warn { background: #FFE2B8; color: #8A4A00; } em.wait.late { background: #FDDCDC; color: #9A1F1F; }
em.st-replied { background: #E4F4EA; color: #146C3A; } em.st-closed { background: #ECECEC; color: #666; }
em.bal { background: #F6ECCB; color: #6B5208; } em.guest { background: #EEF0F4; color: #56607A; } em.rt { background: #EEF4FF; color: #1E3A6B; }
.dk-who em.on { background: #E4F4EA; color: #146C3A; }

.dk-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.dk-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.dk-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.dk-who span { display: flex; gap: 5px; flex-wrap: wrap; }
.dk-who small { color: var(--mut); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.dk-back { display: none; border: 0; background: var(--soft); border-radius: 10px; width: 36px; height: 36px; font-size: 18px; cursor: pointer; }
.dk-info { display: none; }
.dk-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); background: #FCFBF7; }
.dk-acts button, .dk-acts select { font: inherit; font-size: 12.5px; font-weight: 700; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 5px 10px; cursor: pointer; }
.dk-acts .grp { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 700; }
.dk-acts [data-g] { background: var(--gold); border-color: var(--gold); color: #1d1605; }
.dk-acts .close { margin-inline-start: auto; color: #146C3A; } .dk-acts .reopen { margin-inline-start: auto; }
.dk-msgs { flex: 1; overflow-y: auto; padding: 14px; background: var(--soft); display: flex; flex-direction: column; gap: 8px; }
.dk-day { align-self: center; font-size: 11px; font-weight: 700; color: var(--mut); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1px 10px; margin: 4px 0; }
.dk-b { max-width: 78%; border-radius: 14px; padding: 8px 12px; line-height: 1.75; white-space: normal; word-wrap: break-word; }
.dk-b small { display: block; font-size: 11px; color: var(--mut); font-weight: 700; }
.dk-b.in { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-start-start-radius: 4px; }
.dk-b.out { align-self: flex-end; background: #DDF3E6; border: 1px solid #BFE6CF; border-start-end-radius: 4px; }
.dk-b.auto { align-self: flex-end; background: #EEF4FF; border: 1px dashed #B8CBEA; font-size: 13px; }
.dk-img img { display: block; max-width: 240px; max-height: 220px; border-radius: 10px; margin: 6px 0; border: 1px solid var(--line); }
.dk-canned { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 0; }
.dk-canned button { flex-shrink: 0; font: inherit; font-size: 12.5px; font-weight: 700; border: 1px solid #CFE3DA; background: #F1F8F5; color: var(--pr); border-radius: 18px; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
.dk-canned .edit { border-color: var(--line); background: #fff; color: var(--mut); }
.dk-compose { display: flex; gap: 8px; padding: 10px 12px 12px; }
.dk-compose textarea { flex: 1; font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; resize: vertical; min-height: 46px; max-height: 200px; }
.dk-compose button { font: inherit; font-weight: 800; border: 0; background: var(--pr); color: #fff; border-radius: 12px; padding: 0 20px; cursor: pointer; }
.dk-compose button:disabled { opacity: .6; }

.dk-ctx { border-inline-start: 1px solid var(--line); overflow-y: auto; padding: 14px; background: #FCFBF7; }
.dk-ctx h4 { margin: 0 0 10px; font-size: 15px; } .dk-ctx h5 { margin: 16px 0 6px; font-size: 13px; }
.dk-ctx .kv { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px dashed #EDE5D3; font-size: 13px; }
.dk-ctx .kv span { color: var(--mut); }
.dk-ctx .li { display: flex; flex-direction: column; background: #fff; border: 1px solid #EFE7D6; border-radius: 10px; padding: 6px 9px; margin-bottom: 5px; font-size: 12.5px; }
.dk-ctx .li span { color: var(--mut); font-size: 11.5px; }
.dk-ctx .li.diag { border-color: #F3D2CC; background: #FFF7F5; } .dk-ctx .li.diag small { color: #7A2F24; font-size: 11.5px; }
.dk-ctx .muted, .dk-empty { color: var(--mut); }
.dk-empty { padding: 30px 16px; text-align: center; margin: auto; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr; unicode-bidi: plaintext; }

.dk-flash { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 999; padding: 11px 18px; border-radius: 12px; font-weight: 700; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.2); transition: opacity .3s; }
.dk-flash.ok { background: #146C3A; } .dk-flash.err { background: #B0443B; }
.dk-modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 998; display: flex; align-items: center; justify-content: center; padding: 14px; }
.dk-mc { background: #fff; border-radius: 16px; width: min(640px, 100%); max-height: 88vh; display: flex; flex-direction: column; padding: 16px; }
.dk-cl { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.dk-ce { display: grid; grid-template-columns: 1fr auto; gap: 6px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.dk-ce input, .dk-ce textarea { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; }
.dk-ce textarea { grid-column: 1 / -1; resize: vertical; }
.dk-ce button { border: 0; background: transparent; color: #B0443B; font: inherit; font-weight: 700; cursor: pointer; }
.dk-mf { display: flex; gap: 8px; } .dk-mf span { flex: 1; }
.dk-mf button { font: inherit; font-weight: 700; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.dk-mf .pri { background: var(--pr); color: #fff; border-color: var(--pr); }

@media (max-width: 1100px) {
  .dk-body { grid-template-columns: 280px minmax(0, 1fr); }
  .dk-ctx { display: none; }
  .dk-info { display: inline-block; }
  .dk-body.show-ctx .dk-ctx { display: block; position: absolute; }
  .dk-body { position: relative; }
  .dk-body.show-ctx .dk-ctx { inset: 0 auto 0 0; width: min(300px, 90%); z-index: 5; box-shadow: 10px 0 30px rgba(0,0,0,.12); }
}
@media (max-width: 760px) {
  .dk-body { grid-template-columns: 1fr; height: 80vh; }
  .dk-chat { display: none; }
  .dk-body.has-sel .dk-list { display: none; }
  .dk-body.has-sel .dk-chat { display: flex; }
  .dk-back { display: inline-block; }
  .dk-b { max-width: 90%; }
  .dk-acts { gap: 6px; }
  .dk-acts .close, .dk-acts .reopen { margin-inline-start: 0; }
  .dk-search { order: 3; flex-basis: 100%; }
}
/* 4.16: مظهر أهدأ وأنيق للمحادثات */
#desk .dk-body { border-radius: 18px; box-shadow: 0 10px 30px rgba(0, 40, 30, .06); }
#desk .dk-list { background: #fff; }
#desk .dk-item { border-bottom-color: #F1F4F3; }
#desk .dk-item.on { background: #EEF6F2; box-shadow: inset -4px 0 0 #006853; }
#desk .dk-msgs { background: #F6F8F7; background-image: radial-gradient(#E6ECE9 1px, transparent 1px); background-size: 18px 18px; }
#desk .dk-b { box-shadow: 0 2px 6px rgba(0,0,0,.04); }
#desk .dk-head { background: #fff; }
#desk .dk-acts { background: #FAFBFA; }
#desk .dk-compose { background: #fff; border-top: 1px solid #EEF1F0; }
#desk .dk-compose textarea { background: #F8FAF9; }
#desk .dk-canned { background: #fff; padding-bottom: 6px; }
#desk .dk-ctx { background: #fff; }
