/* ===== SAS Support Hub - Custom Styles (Tabler-based) ===== */

/* --- Global --- */
:root {
  --chat-sidebar-width: 340px;
  --info-panel-width: 320px;
  --chat-bg: var(--tblr-bg-surface);
}

html { height: 100%; overflow: hidden; }

/* --- Header Action Buttons --- */
.header-action-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: rgba(255,255,255,.08); border: none; color: #94a3b8;
  cursor: pointer; transition: background .15s, color .15s;
  font-size: .9rem;
}
.header-action-btn:hover { background: rgba(255,255,255,.15); color: #e2e8f0; }
.header-status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; animation: pulse 2s infinite;
}
.header-status-dot.bg-success { animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
body { height: 100%; margin: 0; overflow: hidden; }
#appPage { height: 100vh; height: 100dvh; }
#appPage > .page { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.page-wrapper { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }

/* Theme toggle */
[data-bs-theme="dark"] select option { background: var(--tblr-bg-surface, #1e293b); color: var(--tblr-body-color, #e2e8f0); }

/* --- Login Page --- */
#loginPage { background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%); }
[data-bs-theme="light"] #loginPage { background: linear-gradient(135deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%); }

/* --- View System --- */
.view-container { display: none; flex: 1; overflow: hidden; min-height: 0; }
.view-container.active-view { display: flex; flex-direction: column; }
#conversationsView.active-view,
#contactsView.active-view { display: flex; overflow: hidden; }
/* Settings uses flex layout with internal scrolling */
#settingsView.active-view { overflow: hidden; }
#settingsView > .container-fluid { height: 100%; display: flex; flex-direction: column; overflow: hidden; padding: 0 !important; }
/* Analytics needs scrolling */
#analyticsView.active-view { overflow-y: auto; overflow-x: hidden; }
/* Tickets: list scrolls, detail fills height */
#ticketsView.active-view { overflow: hidden; }
#ticketsView > .container-fluid { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
#tkListView { flex: 1; overflow-y: auto; }
#tkDetailView { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#tkDetailView .chat-layout { flex: 1; min-height: 0; }

/* --- Chat Layout (3-panel) --- */
.chat-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: 100%;
  min-height: 0;
}

/* --- Sidebar --- */
.chat-sidebar {
  width: var(--chat-sidebar-width);
  min-width: var(--chat-sidebar-width);
  border-left: 1px solid var(--tblr-border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--tblr-bg-surface);
}

.chat-sidebar-header {
  padding: .75rem;
  border-bottom: 1px solid var(--tblr-border-color);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--tblr-border-color-translucent);
  transition: background .15s;
  position: relative;
}
.chat-list-item:hover { background: var(--tblr-bg-surface-secondary); }
.chat-list-item.active { background: rgba(var(--tblr-primary-rgb), .1); border-right: 3px solid var(--tblr-primary); }

.chat-list-item .item-body { flex: 1; min-width: 0; }
.chat-list-item .item-name { font-weight: 600; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list-item .item-preview { font-size: .8rem; color: var(--tblr-secondary-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list-item .item-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; flex-shrink: 0; }
.chat-list-item .item-time { font-size: .7rem; color: var(--tblr-secondary-color); white-space: nowrap; }
.chat-list-item .item-badge { display: inline-flex; }

.channel-icon { width: 16px; height: 16px; flex-shrink: 0; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; position: absolute; bottom: 12px; left: 12px; border: 2px solid var(--tblr-bg-surface); }

/* --- Chat Main Area --- */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  max-height: 100%;
}

.chat-header {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface);
  flex-shrink: 0;
  overflow: visible;
}
.chat-header .d-flex {
  flex-wrap: nowrap;
}
/* Header dropdowns */
.chat-header select.form-select-sm {
  font-size: .75rem;
  padding: .2rem 1.5rem .2rem .4rem;
  min-width: 0;
  max-width: 110px;
}
/* Make header controls scrollable on small screens */
.chat-header .flex-shrink-0 {
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chat-header .flex-shrink-0::-webkit-scrollbar { display: none; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  background: #0b141a;
  /* WhatsApp-style dot pattern */
  background-image: radial-gradient(circle, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* --- Message Bubbles --- */
.msg-row { display: flex; margin-bottom: 2px; max-width: 75%; position: relative; }
.msg-row.msg-client { align-self: flex-end; }
.msg-row.msg-staff { align-self: flex-start; }
.msg-row.msg-system { align-self: center; max-width: 90%; }
.msg-row.msg-note { align-self: flex-start; max-width: 75%; }

.msg-bubble {
  padding: .5rem .75rem;
  border-radius: .75rem;
  position: relative;
  word-break: break-word;
  font-size: .875rem;
  line-height: 1.5;
}

/* ---- Dark mode bubbles (default) ---- */
.msg-client .msg-bubble {
  background: #005c4b;
  color: #e9edef;
  border-bottom-left-radius: 2px;
}
.msg-staff .msg-bubble {
  background: #1f2c33;
  color: #e9edef;
  border-bottom-right-radius: 2px;
}
.msg-text { color: inherit; }
.msg-sender { color: inherit; }
.msg-time { color: rgba(255,255,255,.55); }

/* ---- Light mode bubbles ---- */
[data-bs-theme="light"] .msg-client .msg-bubble {
  background: #d9fdd3;
  color: #111b21;
}
[data-bs-theme="light"] .msg-staff .msg-bubble {
  background: #ffffff;
  color: #111b21;
  border: 1px solid #e2e8f0;
}
[data-bs-theme="light"] .msg-time { color: rgba(0,0,0,.45); }
[data-bs-theme="light"] .msg-sender { color: inherit; }
[data-bs-theme="light"] .chat-messages { background: #efeae2; background-image: radial-gradient(circle, rgba(0,0,0,.04) 1px, transparent 1px); }
[data-bs-theme="light"] .msg-channel-badge { background: rgba(0,0,0,.06); color: #667781; }
[data-bs-theme="light"] .typing-indicator { background: #f0f2f5; }
[data-bs-theme="light"] .date-group span { background: #fff; color: #54656f; }
.msg-system .msg-bubble {
  background: #182229;
  font-size: .8rem;
  color: rgba(255,255,255,.65);
  text-align: center;
  border-radius: 1rem;
  padding: .25rem .75rem;
}
.msg-note .msg-bubble {
  background: rgba(255, 193, 7, .15);
  color: #e9edef;
  border: 1px dashed rgba(255, 193, 7, .4);
}
[data-bs-theme="light"] .msg-system .msg-bubble { background: #f0f2f5; color: #54656f; }
[data-bs-theme="light"] .msg-note .msg-bubble { background: #fef3c7; color: #92400e; border-color: rgba(245,158,11,.3); }

.msg-sender { font-size: .75rem; font-weight: 600; margin-bottom: 2px; }
.msg-text { white-space: pre-wrap; }
.msg-text a { color: var(--tblr-primary); text-decoration: underline; }
.msg-footer { display: flex; align-items: center; gap: .5rem; justify-content: flex-end; margin-top: 2px; }
.msg-time { font-size: .65rem; color: var(--tblr-secondary-color); }
.msg-channel-badge { font-size: .6rem; padding: 1px 4px; border-radius: 3px; background: rgba(255,255,255,.08); color: rgba(255,255,255,.5); }

/* Message ticks */
.msg-ticks { display: inline-flex; margin-inline-start: 4px; }
.msg-ticks svg { width: 14px; height: 14px; }
.tick-pending { color: #64748b; } /* رمادي — جاري الإرسال */
.tick-sent { color: #94a3b8; } /* رمادي فاتح — ✓ تم الإرسال */
.tick-delivered { color: #94a3b8; } /* رمادي فاتح — ✓✓ تم التوصيل */
.tick-read { color: #53bdeb; } /* أزرق — ✓✓ تمت القراءة */
.tick-failed { color: #ef4444; } /* أحمر — ✕ فشل */

/* Date group separator */
.date-group { text-align: center; margin: .75rem 0; }
.date-group span {
  background: #182229;
  padding: .25rem .75rem;
  border-radius: 1rem;
  font-size: .75rem;
  color: rgba(255,255,255,.65);
}

/* --- Typing Indicator --- */
.typing-indicator {
  padding: .5rem 1rem;
  font-size: .8rem;
  color: var(--tblr-secondary-color);
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
  background: var(--tblr-bg-surface);
  border-top: 1px solid var(--tblr-border-color-translucent);
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tblr-secondary-color);
  animation: typingBounce 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* --- Channel Filter Tabs --- */
#channelFilters {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--tblr-border-color-translucent);
  gap: 0;
}
#channelFilters .btn {
  font-size: .72rem;
  font-weight: 500;
  padding: 4px 0;
  border: none;
  border-radius: 0;
  transition: background .2s, color .2s;
}
#channelFilters .btn.active {
  background: var(--tblr-primary);
  color: #fff;
  font-weight: 600;
}
#channelFilters .btn:not(.active):hover {
  background: rgba(var(--tblr-primary-rgb), .1);
}

/* --- Chat Header Toolbar --- */
.chat-header .flex-shrink-0 {
  gap: 6px !important;
}
.chat-header .flex-shrink-0 .btn-icon {
  border-radius: 8px;
  transition: background .15s, transform .1s;
}
.chat-header .flex-shrink-0 .btn-icon:hover {
  transform: translateY(-1px);
}

/* --- AI Suggestion Bar --- */
.ai-suggestion-bar {
  padding: 6px 12px;
  background: rgba(59, 130, 246, 0.05);
  border-bottom: 1px solid rgba(59, 130, 246, 0.1);
  direction: rtl;
}

/* --- Chat Input Area --- */
.chat-input-area {
  border-top: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface);
  padding: .5rem;
  flex-shrink: 0;
}

.chat-input-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-end;
  gap: 4px;
  flex-wrap: nowrap !important;
}
.chat-input-wrapper {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
}

/* أزرار الإدخال فوق مربع الرسالة */
.chat-input-row {
  flex-direction: column !important;
  gap: 0 !important;
}
.chat-input-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 2px 0 4px;
}
.chat-input-toolbar .toolbar-spacer {
  flex: 1;
  min-width: 8px;
}
.chat-input-toolbar .btn-icon.btn-sm {
  width: 30px !important;
  height: 30px !important;
  border-radius: 8px !important;
  flex-shrink: 0;
}
.btn-ghost-purple { color: #a855f7 !important; }
.btn-ghost-purple:hover { background: rgba(168,85,247,.1) !important; }
.btn-ghost-cyan { color: #06b6d4 !important; }
.btn-ghost-cyan:hover { background: rgba(6,182,212,.1) !important; }
.chat-input-send-inline {
  border-radius: 50% !important;
  width: 32px !important;
  height: 32px !important;
}
.chat-input-bottom {
  display: flex;
  align-items: stretch;
  gap: 6px;
  width: 100%;
}
.chat-input-send-btn {
  border-radius: 12px !important;
  width: 52px !important;
  min-width: 52px !important;
  height: auto !important;
  flex-shrink: 0;
  font-size: 1.2rem;
}
.chat-input-send-btn .icon {
  width: 26px !important;
  height: 26px !important;
}
.chat-input-wrapper {
  width: 100% !important;
  flex: unset !important;
}
/* Force icon buttons to be small and consistent */
.chat-input-area .btn-icon.btn-sm {
  width: 34px !important;
  height: 34px !important;
  border-radius: 8px !important;
  min-width: 32px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-input-area .btn-icon.btn-sm .icon {
  width: 18px !important;
  height: 18px !important;
}

.chat-input-area textarea {
  resize: none;
  max-height: 160px;
  min-height: 68px;
  border-radius: .5rem;
  padding: .4rem .6rem;
  font-size: .875rem;
  line-height: 1.5;
}

/* Internal note mode */
.chat-input-area.internal-mode textarea { border-color: rgba(255, 193, 7, .5); background: rgba(255, 193, 7, .05); }
.chat-input-area.internal-mode .btn-ghost-warning { background: rgba(255, 193, 7, .2); }

/* Close with reply row */
#closeWithReplyRow {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 3px 8px !important;
  border-top: 1px solid var(--tblr-border-color-translucent);
}
#closeWithReplyRow .form-check-label {
  font-size: .72rem;
  color: var(--tblr-secondary-color);
  user-select: none;
}

/* --- Upload Preview --- */
.upload-preview {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem;
  margin-bottom: .5rem;
  background: var(--tblr-bg-surface-secondary);
  border-radius: .5rem;
}
.upload-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: .25rem; }
.upload-name { flex: 1; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Voice Record Bar --- */
.voice-record-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem;
  background: rgba(var(--tblr-danger-rgb), .1);
  border-radius: .5rem;
  margin-top: .5rem;
}
.recording-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tblr-danger); animation: recPulse 1s infinite; }
@keyframes recPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.recording-timer { font-size: .8rem; font-variant-numeric: tabular-nums; direction: ltr; }
.rec-waveform { display: flex; align-items: center; gap: 2px; flex: 1; height: 32px; direction: ltr; }
.rec-bar { width: 3px; border-radius: 2px; background: var(--tblr-danger); transition: height .08s ease; min-height: 3px; opacity: .7; }

/* --- Voice Recording on Send Button --- */
.voice-recording-active {
  animation: micPulse 1.5s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--tblr-danger-rgb), .5); }
  50% { box-shadow: 0 0 0 8px rgba(var(--tblr-danger-rgb), 0); }
}
.voice-rec-bars-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  width: 100%;
}
.voice-rec-bar-item {
  width: 4px;
  height: 6px;
  border-radius: 2px;
  background: #fff;
  transition: height .08s ease;
  min-height: 6px;
}
.voice-rec-cancel-mini {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  z-index: 10;
  transition: background .15s;
}
.voice-rec-cancel-mini:hover { background: var(--tblr-danger); }

/* --- Voice Notes (WhatsApp style) --- */
.voice-note { display: flex; align-items: center; gap: 8px; min-width: 240px; max-width: 340px; padding: 6px 4px; direction: ltr; }
.voice-note audio, .msg-bubble audio { display: none !important; width: 0 !important; height: 0 !important; position: absolute !important; opacity: 0 !important; pointer-events: none !important; }
.vn-play-btn { cursor: pointer; flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #00a884; color: #fff; border: none; transition: background .15s; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.vn-play-btn:hover { background: #00c49a; }
.vn-play-btn svg { width: 18px; height: 18px; }
.vn-waveform { flex: 1; display: flex; align-items: center; gap: 1.5px; height: 32px; cursor: pointer; position: relative; direction: ltr; }
.vn-bar { width: 3px; border-radius: 2px; background: rgba(255,255,255,.25); transition: background .15s; min-height: 3px; }
.vn-bar.active { background: #25d366; }
.vn-dot { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #25d366; top: 50%; transform: translateY(-50%); left: 0; transition: left .05s linear; box-shadow: 0 1px 4px rgba(0,0,0,.3); z-index: 1; }
.vn-time { font-size: .72rem; color: rgba(255,255,255,.6); white-space: nowrap; direction: ltr; min-width: 36px; text-align: center; font-variant-numeric: tabular-nums; }
.vn-speed { font-size: .68rem; cursor: pointer; padding: 3px 7px; border-radius: 12px; background: rgba(255,255,255,.15); color: rgba(255,255,255,.7); border: none; min-width: 30px; transition: background .15s; font-weight: 600; }
.vn-speed:hover { background: rgba(255,255,255,.25); }
/* Client (green) bubble overrides */
.msg-client .vn-play-btn { background: #fff; color: #25d366; }
.msg-client .vn-play-btn:hover { background: #f0f0f0; }
.msg-client .vn-bar { background: rgba(255,255,255,.4); }
.msg-client .vn-bar.active { background: #fff; }
.msg-client .vn-dot { background: #fff; }
.msg-client .vn-time { color: rgba(255,255,255,.75); }
.msg-client .vn-speed { background: rgba(255,255,255,.2); color: #fff; }
/* Light mode voice note */
[data-bs-theme="light"] .vn-play-btn { background: #00a884; color: #fff; }
[data-bs-theme="light"] .vn-play-btn:hover { background: #00c49a; }
[data-bs-theme="light"] .vn-bar { background: rgba(0,0,0,.15); }
[data-bs-theme="light"] .vn-bar.active { background: #00a884; }
[data-bs-theme="light"] .vn-dot { background: #00a884; }
[data-bs-theme="light"] .vn-time { color: rgba(0,0,0,.45); }
[data-bs-theme="light"] .vn-speed { background: rgba(0,0,0,.06); color: rgba(0,0,0,.45); }

/* --- Media in messages --- */
.msg-image { max-width: 280px; max-height: 300px; border-radius: .5rem; cursor: pointer; object-fit: cover; display: block; margin-bottom: 4px; }
.msg-sticker { max-width: 150px; background: none !important; }
.msg-video { max-width: 300px; border-radius: .5rem; display: block; margin-bottom: 4px; }
.msg-doc { display: flex; align-items: center; gap: .5rem; padding: .5rem; background: var(--tblr-bg-surface-tertiary); border-radius: .5rem; text-decoration: none; color: inherit; margin-bottom: 4px; }
.msg-doc:hover { opacity: .85; }
.msg-doc-icon { flex-shrink: 0; }
.msg-doc-info { font-size: .8rem; min-width: 0; }
.msg-doc-info div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-doc-size { font-size: .7rem; color: var(--tblr-secondary-color); }

/* Hide bubble background when only image/sticker */
.msg-bubble:has(> .msg-image:first-child):not(:has(.msg-text)) { background: transparent !important; padding: .25rem; }
.msg-bubble:has(> .msg-sticker:first-child) { background: transparent !important; padding: 0; }

/* --- Info Panel --- */
.chat-info-panel {
  width: var(--info-panel-width);
  min-width: var(--info-panel-width);
  border-right: 1px solid var(--tblr-border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--tblr-bg-surface);
  transition: width .2s, min-width .2s;
}
.chat-info-panel.collapsed { width: 0; min-width: 0; overflow: hidden; }

.info-panel-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--tblr-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--tblr-bg-surface);
  z-index: 5;
}
.info-panel-body { flex: 1; overflow-y: auto; padding: .5rem; }

.info-section {
  padding: .75rem;
  border-bottom: 1px solid var(--tblr-border-color-translucent);
}
.info-section-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--tblr-secondary-color);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: .5rem;
}
/* Collapsible info sections */
.info-collapse-header {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
  color: var(--tblr-body-color);
  padding: 2px 0;
  user-select: none;
}
.info-collapse-header:hover { color: var(--tblr-primary); }
.info-collapse-chevron {
  transition: transform .2s;
  margin-right: auto;
  flex-shrink: 0;
  opacity: .5;
}
.info-collapse.collapsed .info-collapse-chevron { transform: rotate(-90deg); }
.info-collapse.collapsed .info-collapse-body { display: none; }
.info-collapse-body { margin-top: 6px; }
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .25rem 0;
  font-size: .8rem;
}
.info-label { color: var(--tblr-secondary-color); flex-shrink: 0; }
.info-value { font-weight: 500; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; min-width: 0; }

/* --- Drop Overlay --- */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(var(--tblr-primary-rgb), .1);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.drop-overlay-content {
  text-align: center;
  padding: 2rem;
  border: 2px dashed var(--tblr-primary);
  border-radius: 1rem;
}

/* --- Image Viewer --- */
.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.image-viewer img { max-width: 95vw; max-height: 95vh; object-fit: contain; }

/* --- Context Menu --- */
.ctx-menu {
  position: fixed;
  z-index: 9990;
  background: var(--tblr-bg-surface);
  border: 1px solid var(--tblr-border-color);
  border-radius: .5rem;
  padding: .25rem;
  min-width: 160px;
  box-shadow: var(--tblr-box-shadow-lg);
}
.ctx-menu-item {
  display: block;
  width: 100%;
  padding: .5rem .75rem;
  font-size: .8rem;
  border: none;
  background: none;
  color: var(--tblr-body-color);
  text-align: right;
  cursor: pointer;
  border-radius: .25rem;
  white-space: nowrap;
}
.ctx-menu-item:hover { background: var(--tblr-bg-surface-secondary); }
.ctx-menu-item.text-danger:hover { background: rgba(var(--tblr-danger-rgb), .1); }
.ctx-menu-divider { height: 1px; background: var(--tblr-border-color); margin: .25rem 0; }

/* --- Message Channel Avatar Icon --- */
.msg-avatar-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border-radius: 50%;
  align-self: flex-end;
  margin-bottom: 4px;
}
.msg-row.msg-client { display: flex; gap: 6px; }
.msg-row.msg-client .msg-bubble { flex: 1; min-width: 0; }

/* --- Chat Input Multi-line --- */
#chatInput {
  min-height: 36px;
  max-height: 120px;
  resize: none;
  overflow-y: auto;
  line-height: 1.4;
}

/* --- Gotik Refresh Button --- */
.gotik-refresh-icon {
  cursor: pointer;
  font-size: .8rem;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: .7;
  transition: opacity .2s;
}
.gotik-refresh-icon:hover { opacity: 1; }

/* --- Emoji Panel --- */
.emoji-panel {
  position: absolute;
  bottom: 100%;
  right: 0;
  background: var(--tblr-bg-surface);
  border: 1px solid var(--tblr-border-color);
  border-radius: .5rem;
  padding: .5rem;
  width: 280px;
  max-height: 200px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  box-shadow: var(--tblr-box-shadow-lg);
  z-index: 50;
}
.emoji-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: .25rem;
  border: none;
  background: none;
}
.emoji-item:hover { background: var(--tblr-bg-surface-secondary); }

/* --- Canned Popup --- */
.canned-popup {
  position: absolute;
  bottom: 100%;
  right: 0;
  left: 0;
  background: var(--tblr-bg-surface);
  border: 1px solid var(--tblr-border-color);
  border-radius: .5rem;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: var(--tblr-box-shadow-lg);
  z-index: 50;
}
.canned-item {
  padding: .5rem .75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--tblr-border-color-translucent);
  font-size: .85rem;
}
.canned-item:hover, .canned-item.active { background: var(--tblr-bg-surface-secondary); }
.canned-shortcut { font-weight: 600; color: var(--tblr-primary); margin-left: .5rem; direction: ltr; display: inline; }

/* --- Message Action Buttons (React + Reply) --- */
.msg-action-btns {
  display: none;
  gap: 2px;
  margin-top: 4px;
  justify-content: flex-end;
}
.msg-row:hover .msg-action-btns,
.msg-row:active .msg-action-btns,
.msg-row:focus-within .msg-action-btns { display: flex; }
/* على الموبايل: tap يظهرهم */
@media (max-width: 768px) {
  .msg-action-btns { display: flex; opacity: 0.5; }
  .msg-row:active .msg-action-btns { opacity: 1; }
}
.msg-act-btn {
  border: none;
  background: rgba(0,0,0,.25);
  backdrop-filter: blur(4px);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: .75rem;
  color: rgba(255,255,255,.85);
  padding: 0;
  transition: background .15s, transform .1s;
}
.msg-act-btn:hover { background: rgba(0,0,0,.45); color: #fff; transform: scale(1.1); }
[data-bs-theme="light"] .msg-act-btn { background: rgba(255,255,255,.7); color: rgba(0,0,0,.6); }
[data-bs-theme="light"] .msg-act-btn:hover { background: rgba(255,255,255,.9); color: rgba(0,0,0,.85); }

/* --- Quoted Message (Reply-to) --- */
.msg-quoted {
  background: rgba(255,255,255,.07);
  border-right: 3px solid #6366f1;
  border-radius: .375rem;
  padding: 4px 8px;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: .78rem;
}
.msg-quoted:hover { background: rgba(255,255,255,.12); }
[data-bs-theme="light"] .msg-quoted { background: rgba(0,0,0,.04); }
[data-bs-theme="light"] .msg-quoted:hover { background: rgba(0,0,0,.08); }
.msg-quoted-name { font-weight: 600; font-size: .7rem; margin-bottom: 1px; }
.msg-quoted-text { color: var(--tblr-secondary-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }

/* Reply Preview Bar */
.reply-preview-bar {
  padding: 6px 12px;
  background: var(--tblr-bg-surface-secondary);
  border-bottom: 1px solid var(--tblr-border-color);
}
.reply-preview-content {
  display: flex;
  align-items: center;
  gap: 8px;
}
.reply-preview-line {
  width: 3px;
  height: 32px;
  background: #6366f1;
  border-radius: 2px;
  flex-shrink: 0;
}
.reply-preview-body { flex: 1; min-width: 0; }
.reply-preview-name { font-size: .72rem; font-weight: 600; color: #6366f1; }
.reply-preview-text { font-size: .72rem; color: var(--tblr-secondary-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Message highlight on scroll */
.msg-highlight .msg-bubble {
  animation: msgHighlight 2s ease-out;
}
@keyframes msgHighlight {
  0%,30% { box-shadow: 0 0 0 3px rgba(99,102,241,.5); }
  100% { box-shadow: none; }
}

/* Legacy .msg-react-btn compat */
.msg-react-btn { display: none; }
.msg-reaction {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: .75rem;
  background: var(--tblr-bg-surface-secondary);
  padding: 1px 4px;
  border-radius: 1rem;
  margin-top: 2px;
}

.react-picker {
  position: absolute;
  top: 0;
  background: var(--tblr-bg-surface);
  border: 1px solid var(--tblr-border-color);
  border-radius: .75rem;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--tblr-box-shadow-lg);
  z-index: 60;
}
.msg-client .react-picker { left: calc(100% + 4px); }
.msg-staff .react-picker { right: calc(100% + 4px); }
.react-emoji {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  border-radius: 50%;
  border: none;
  background: none;
  transition: transform .1s, background .1s;
}
.react-emoji:hover { background: var(--tblr-bg-surface-secondary); transform: scale(1.25); }

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}
.toast {
  padding: .75rem 1.25rem;
  border-radius: .5rem;
  font-size: .85rem;
  color: #fff;
  pointer-events: auto;
  animation: toastIn .3s;
  box-shadow: var(--tblr-box-shadow-lg);
}
.toast.success { background: var(--tblr-success); }
.toast.error { background: var(--tblr-danger); }
.toast.warning { background: var(--tblr-warning); color: #000; }
.toast.info { background: var(--tblr-info); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* --- Confirm Overlay --- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-box {
  background: var(--tblr-bg-surface);
  border-radius: .75rem;
  padding: 1.5rem;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow: var(--tblr-box-shadow-lg);
}
.confirm-msg { margin-bottom: 1rem; font-size: .9rem; }
.confirm-actions { display: flex; gap: .5rem; justify-content: center; }

/* --- PWA Install Banner --- */
.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9980;
  background: linear-gradient(135deg, var(--tblr-primary), var(--tblr-purple));
  color: #fff;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- Extra button sizes --- */
.btn-xs { font-size: .7rem; padding: .15rem .4rem; line-height: 1.4; border-radius: .25rem; }

/* --- Gotik URL Icons Row --- */
.gotik-urls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.gotik-url-btn {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 8px; border-radius: 8px; font-size: .74rem; cursor: pointer;
  border: 1.5px solid; background: transparent;
  color: var(--tblr-body-color); text-decoration: none; position: relative; white-space: nowrap;
  transition: background .15s, transform .1s;
}
.gotik-url-btn:hover { background: rgba(var(--tblr-primary-rgb),.12); transform: translateY(-1px); }
.gotik-url-btn .url-icon { font-size: .8rem; }
.gotik-url-btn .url-tooltip {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #e2e8f0; padding: 4px 8px; border-radius: 4px; font-size: .65rem;
  white-space: nowrap; z-index: 100; direction: ltr; max-width: 280px; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.gotik-url-btn .url-tooltip::after { content:''; position:absolute; top:100%; left:50%; transform:translateX(-50%); border:4px solid transparent; border-top-color:#1e293b; }
.gotik-url-btn:hover .url-tooltip { display: block; }
.gotik-url-copy { opacity:.4; font-size:.7rem; cursor:pointer; transition: opacity .15s; }
.gotik-url-copy:hover { opacity:1; }

/* --- MikroTik Action Buttons --- */
.mk-actions-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 8px 0 6px;
}
.mk-action-btn {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 7px 6px; border-radius: 8px; font-size: .72rem; font-weight: 600;
  cursor: pointer; border: 1.5px solid; background: transparent;
  color: var(--tblr-body-color); text-decoration: none; white-space: nowrap;
  transition: background .15s, transform .1s, box-shadow .15s;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.mk-action-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.mk-btn-icon { font-size: .82rem; }
.mk-btn-shell { border-color: #10b981; }
.mk-btn-shell:hover { background: rgba(16,185,129,.15); color: #10b981; }
.mk-btn-webfig { border-color: #3b82f6; }
.mk-btn-webfig:hover { background: rgba(59,130,246,.15); color: #3b82f6; }
.mk-btn-winbox { border-color: #f59e0b; }
.mk-btn-winbox:hover { background: rgba(245,158,11,.15); color: #f59e0b; }

.mk-tools-row {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px;
}
.mk-tool-btn {
  font-size: .68rem; padding: 3px 8px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--tblr-border-color-translucent); background: transparent;
  color: var(--tblr-secondary-color); white-space: nowrap;
  transition: background .15s, color .15s;
}
.mk-tool-btn:hover { background: rgba(var(--tblr-primary-rgb),.1); color: var(--tblr-primary); }
.mk-tool-exec { color: #f59e0b; border-color: rgba(245,158,11,.3); }
.mk-tool-exec:hover { background: rgba(245,158,11,.12); }
.mk-tool-fetch { color: #06b6d4; border-color: rgba(6,182,212,.3); }
.mk-tool-fetch:hover { background: rgba(6,182,212,.12); }

/* Advanced Panel Button */
.ap-status { display:inline-flex; align-items:center; gap:4px; padding:3px 8px; border-radius:6px; font-size:.7rem; font-weight:600; }
.ap-status.installed { background:rgba(16,185,129,.15); color:#10b981; }
.ap-status.not-installed { background:rgba(107,114,128,.15); color:#6b7280; }

/* --- WA Session Color Dots --- */
.wa-color-dot {
  display: inline-block;
  width: 18px; height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .15s, border-color .15s;
}
.wa-color-dot:hover { transform: scale(1.2); }
.wa-color-dot.active { border-color: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.3); transform: scale(1.15); }

/* --- Editable Info Fields --- */
.info-editable { cursor: pointer; border-bottom: 1px dashed transparent; transition: border-color .2s; }
.info-editable:hover { border-bottom-color: var(--tblr-primary); }
.info-edit-input { background: transparent; border: none; border-bottom: 1px solid var(--tblr-primary); color: inherit; font-size: inherit; width: 100%; padding: 0; outline: none; }

/* --- Message Editing Highlight --- */
.msg-row.editing .msg-bubble {
  outline: 2px solid var(--tblr-primary);
  outline-offset: 2px;
  border-radius: .75rem;
}

/* --- Speech-to-Text Button --- */
.speech-active {
  animation: speech-pulse 1s infinite;
}
@keyframes speech-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- Invoice Cards --- */
.inv-card { transition: background .15s; }
.inv-card:hover { background: rgba(var(--tblr-primary-rgb),.08) !important; }

/* --- Gotik Info Cards --- */
.gotik-card {
  background: var(--tblr-bg-surface-secondary);
  border-radius: .5rem;
  padding: .75rem;
  margin-bottom: .5rem;
}
.gotik-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 600;
  font-size: .8rem;
}
.gotik-card-body { margin-top: .5rem; font-size: .8rem; }
.gotik-collapse-section { border-top: 1px solid var(--tblr-border-color-translucent); margin-top: 6px; }
.gotik-collapse-title { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; cursor: pointer; font-weight: 600; font-size: .78rem; color: var(--tblr-secondary-color); user-select: none; }
.gotik-collapse-title:hover { color: var(--tblr-primary); }
.gotik-collapse-content { padding: 4px 0 6px; }
.gotik-collapse-content .d-flex.gap-1.flex-wrap { display: grid !important; grid-template-columns: 1fr 1fr; gap: 6px !important; }
.gotik-collapse-content .d-flex.gap-1.flex-wrap .btn { font-size: .7rem; padding: 5px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 6px; }
.gotik-field { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; }
.gotik-field .copyable {
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 3px;
  direction: ltr;
  font-family: monospace;
  font-size: .75rem;
  background: var(--tblr-bg-surface-tertiary);
}
.gotik-field .copyable:active { background: var(--tblr-primary); color: #fff; }

/* --- Status/Priority Badges --- */
.badge-status { font-size: .7rem; padding: 2px 6px; border-radius: 3px; }
.badge-status.open { background: rgba(59,130,246,.15); color: #3b82f6; }
.badge-status.pending { background: rgba(245,158,11,.15); color: #f59e0b; }
.badge-status.in_progress { background: rgba(139,92,246,.15); color: #8b5cf6; }
.badge-status.resolved { background: rgba(16,185,129,.15); color: #10b981; }
.badge-status.closed { background: rgba(107,114,128,.15); color: #6b7280; }

.badge-priority { font-size: .7rem; padding: 2px 6px; border-radius: 3px; }
.badge-priority.low { background: rgba(107,114,128,.15); color: #6b7280; }
.badge-priority.normal { background: rgba(59,130,246,.1); color: #60a5fa; }
.badge-priority.medium { background: rgba(59,130,246,.15); color: #3b82f6; }
.badge-priority.high { background: rgba(245,158,11,.15); color: #f59e0b; }
.badge-priority.urgent { background: rgba(239,68,68,.15); color: #ef4444; }

/* --- SLA countdown --- */
.sla-timer { font-variant-numeric: tabular-nums; direction: ltr; }
.sla-ok { color: var(--tblr-success); }
.sla-warn { color: var(--tblr-warning); }
.sla-breach { color: var(--tblr-danger); }

/* --- Analytics --- */
.stat-card { text-align: center; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; }
.stat-card .stat-label { font-size: .8rem; color: var(--tblr-secondary-color); }

.perf-bar { height: 8px; border-radius: 4px; background: var(--tblr-bg-surface-tertiary); overflow: hidden; }
.perf-bar-fill { height: 100%; border-radius: 4px; background: var(--tblr-primary); transition: width .3s; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .chat-sidebar { width: 100%; min-width: 100%; }
  .chat-sidebar.mobile-hidden { display: none; }

  /* Info panel: full screen overlay on mobile */
  .chat-info-panel {
    position: fixed; inset: 0; z-index: 1050;
    width: 100% !important; min-width: 100% !important;
    background: var(--tblr-bg-surface);
  }
  .chat-info-panel.collapsed { display: none !important; }

  /* Header: two rows on mobile */
  .chat-header { padding: .4rem .5rem; overflow: visible; }
  .chat-header > .d-flex { flex-wrap: wrap !important; gap: .4rem; }
  .chat-header .flex-shrink-0 {
    width: 100%;
    display: flex !important;
    flex-wrap: wrap;
    gap: .25rem;
    overflow-x: auto;
  }
  .chat-header select.form-select-sm {
    font-size: .7rem;
    padding: .15rem 1.2rem .15rem .3rem;
    max-width: 95px;
    height: 28px;
  }

  /* Info panel values: allow wrapping */
  .info-value { white-space: normal; max-width: 65%; word-break: break-word; text-align: left; }
  .info-row { font-size: .78rem; }

  /* Table on mobile: show only #, client, subject, status */
  #tkListView .table th,
  #tkListView .table td { font-size: .75rem; padding: .4rem .3rem; }
  #tkListView .table th:nth-child(n+5),
  #tkListView .table td:nth-child(n+5) { display: none; }

  /* Chat input: compact on mobile */
  .chat-input-area { padding: .3rem .4rem; }
  .chat-input-row { gap: 2px !important; }
  .chat-input-area .btn-icon.btn-sm {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
  }
  .chat-input-area .btn-icon.btn-sm .icon {
    width: 16px !important;
    height: 16px !important;
  }
  /* Hide canned on very small, keep: emoji, attach, voice, internal, send */
  .chat-input-send #btnCanned { display: none !important; }
  .chat-input-area textarea { font-size: .82rem; min-height: 32px; padding: .3rem .5rem; }

  /* Page full height on mobile */
  .page-wrapper { flex: 1; overflow: hidden; min-height: 0; }
  .view-container.active-view { height: 100%; overflow: hidden; }
  .chat-layout { height: 100%; min-height: 0; }
  .chat-main { min-height: 0; }

  /* Conversations header on mobile: show back + name + info btn only */
  #chatHeader .flex-shrink-0 { gap: .25rem; }

  /* Tickets detail: tighter layout */
  #tkDetailView .chat-layout { flex-direction: column; }
  #tkDetailView .chat-main { flex: 1; }
  #tkChatHeader select { display: none !important; }

  /* Mobile back button always visible */
  .d-md-none { display: inline-flex !important; }

  /* Voice note on mobile */
  .voice-note { min-width: 180px; max-width: 260px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .chat-sidebar { width: 280px; min-width: 280px; }
  .chat-info-panel { width: 280px; min-width: 280px; }
}

/* --- Nav active state --- */
.nav-tab.active { color: var(--tblr-primary) !important; border-bottom: 2px solid var(--tblr-primary); }

/* --- Scrollbar --- */
.chat-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.info-panel-body::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.info-panel-body::-webkit-scrollbar-track { background: transparent; }
.chat-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.info-panel-body::-webkit-scrollbar-thumb { background: var(--tblr-border-color); border-radius: 2px; }

/* --- Modal fixes --- */
.modal.show { display: flex !important; align-items: center; justify-content: center; background: rgba(0,0,0,.5); }
.modal-blur { backdrop-filter: blur(4px); }
/* ═══ Notification Bell ═══ */
.badge-notification {
  position: absolute;
  top: -2px;
  right: -2px;
  font-size: .65rem;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  padding: 0 4px;
  border-radius: 10px;
}
#notifDropdown .dropdown-header {
  padding: 8px 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--border, #334155);
}
#notifDropdown .notif-item {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, #334155);
  white-space: normal;
}
#notifDropdown .notif-item:hover {
  background: rgba(99, 102, 241, .08);
}
#notifDropdown select option {
  background: var(--surface-primary, #1e293b);
  color: var(--text-primary, #e2e8f0);
}

/* ═══ SLA Warning Card ═══ */
.stat-card.sla-warning {
  border: 1px solid rgba(239, 68, 68, .4);
  animation: sla-pulse 2s ease-in-out infinite;
}
@keyframes sla-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
  50% { box-shadow: 0 0 12px 2px rgba(239, 68, 68, .2); }
}

/* ═══ Reports Table ═══ */
#reportsContent table th {
  color: var(--text-secondary, #94a3b8);
  font-weight: 600;
}
#reportsContent table td {
  color: var(--text-primary, #e2e8f0);
}

/* ═══ Pagination ═══ */
.pagination-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border, #334155);
}
.pagination-bar button {
  background: var(--surface-primary, #1e293b);
  border: 1px solid var(--border, #334155);
  color: var(--text-primary, #e2e8f0);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: .8rem;
  cursor: pointer;
}
.pagination-bar button:hover {
  background: var(--accent, #6366f1);
  color: #fff;
}
.pagination-bar button:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.pagination-bar .page-info {
  font-size: .8rem;
  color: var(--text-muted, #64748b);
}

/* ═══ Settings Tabbed Layout ═══ */
.settings-layout {
  display: flex;
  gap: 0;
  height: 100%;
  overflow: hidden;
}
.settings-sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-dark, #0f172a);
  border-left: 1px solid var(--border, #334155);
  padding: 16px 0;
  overflow-y: auto;
  height: 100%;
}
.settings-sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  padding: 0 16px 12px;
  margin: 0;
  border-bottom: 1px solid var(--border, #334155);
}
.settings-tabs-list {
  display: flex;
  flex-direction: column;
  padding-top: 8px;
}
.settings-tab-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-secondary, #94a3b8);
  font-size: .85rem;
  cursor: pointer;
  text-align: right;
  transition: all .15s;
  border-right: 3px solid transparent;
}
.settings-tab-btn:hover {
  background: rgba(99, 102, 241, .06);
  color: var(--text-primary, #e2e8f0);
}
.settings-tab-btn.active {
  background: rgba(99, 102, 241, .1);
  color: var(--accent, #6366f1);
  border-right-color: var(--accent, #6366f1);
  font-weight: 600;
}
.settings-tab-icon {
  font-size: 1rem;
  min-width: 22px;
  text-align: center;
}
.settings-main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  height: 100%;
}
.settings-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border, #334155);
}
.settings-page-header h2 {
  font-size: 1.15rem;
  margin: 0;
}
.settings-item {
  background: var(--bg-surface, #1e293b);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--border, #334155);
}
.settings-item:hover {
  border-color: rgba(99, 102, 241, .3);
}

/* Responsive */
@media (max-width: 768px) {
  .settings-layout {
    flex-direction: column;
  }
  .settings-sidebar {
    width: 100%;
    min-width: auto;
    border-left: none;
    border-bottom: 1px solid var(--border, #334155);
    padding: 8px 0;
  }
  .settings-tabs-list {
    flex-direction: row;
    overflow-x: auto;
    padding: 0 8px;
    gap: 2px;
  }
  .settings-tab-btn {
    padding: 8px 12px;
    white-space: nowrap;
    border-right: none;
    border-bottom: 2px solid transparent;
    font-size: .78rem;
  }
  .settings-tab-btn.active {
    border-bottom-color: var(--accent, #6366f1);
    border-right-color: transparent;
  }
  .settings-tab-label {
    display: none;
  }
  .settings-tab-icon {
    font-size: 1.2rem;
  }
  .settings-main {
    padding: 16px;
  }
}
select option {
  background: var(--bg-surface, #1e293b);
  color: var(--text-primary, #e2e8f0);
}

/* ═══ Lookup / Info Page ═══ */
.lookup-collapse { overflow: hidden; }
.lookup-collapse-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.lookup-collapse-header:hover { background: rgba(99, 102, 241, .04); }
.lookup-collapse-arrow { font-size: .8rem; color: var(--text-muted, #64748b); transition: transform .2s; }
.lookup-collapse-body { border-top: 1px solid var(--border, #334155); }

.lookup-field {
  background: var(--bg-dark, #0f172a);
  border-radius: 8px;
  padding: 10px 14px;
}
.lookup-field-label {
  display: block;
  font-size: .72rem;
  color: var(--text-muted, #64748b);
  margin-bottom: 2px;
}
.lookup-field-value {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
}
.lookup-field-sm { padding: 4px 0; }
.lookup-field-label-sm { display: block; font-size: .68rem; color: var(--text-muted, #64748b); }
.lookup-field-value-sm { font-size: .82rem; font-weight: 500; }

.lookup-card {
  background: var(--bg-surface, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 10px;
  margin: 8px 12px;
  overflow: hidden;
}
.lookup-card-header {
  padding: 10px 14px;
  background: rgba(0,0,0,.15);
  border-bottom: 1px solid var(--border, #334155);
  font-size: .9rem;
}
.lookup-actions-group {
  border-top: 1px solid var(--border, #334155);
  padding: 6px 14px 8px;
}
.lookup-actions-label {
  font-size: .7rem;
  color: var(--text-muted, #64748b);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.lookup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lookup-cmd-result {
  background: var(--bg-dark, #0f172a);
  border-radius: 8px;
  padding: 10px;
  margin: 4px 8px;
}
.lookup-cmd-output {
  font-size: .78rem;
  max-height: 300px;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  background: var(--bg-dark, #0f172a);
  color: var(--text-primary, #e2e8f0);
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border, #334155);
}

.lookup-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 20px;
  background: var(--bg-dark, #0f172a);
  border-radius: 8px;
}
.lookup-stat-value { font-size: 1.4rem; font-weight: 700; }
.lookup-stat-label { font-size: .75rem; color: var(--text-muted, #64748b); }

.lookup-invoice {
  padding: 8px 14px;
  margin: 0 12px 4px;
  border-radius: 8px;
  border-right: 3px solid transparent;
}
.lookup-invoice.unpaid {
  background: rgba(239, 68, 68, .06);
  border-right-color: #ef4444;
}
.lookup-invoice.paid {
  background: rgba(34, 197, 94, .04);
  border-right-color: #22c55e;
}
.lookup-ticket {
  padding: 10px 14px;
  margin: 0 12px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  border-right: 3px solid transparent;
}
.lookup-ticket:hover {
  background: rgba(99, 102, 241, .06);
  border-right-color: var(--accent, #6366f1);
}

/* ═══ Lookup Page — Compact Centered Cards ═══ */
#lookupContent {
  max-width: 650px;
  margin: 0 auto;
  padding: 0 12px;
}
#lookupGotikPanel .info-section-title {
  font-size: .95rem;
  padding: 8px 0 4px;
  margin-top: 12px;
}
#lookupGotikPanel .gotik-card {
  background: var(--bg-surface, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
#lookupGotikPanel .gotik-card-header {
  font-size: .88rem;
  padding-bottom: 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border, #334155);
}
#lookupGotikPanel .gotik-card-body {
  font-size: .82rem;
}
#lookupGotikPanel .gotik-field {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: .82rem;
  gap: 12px;
}
#lookupGotikPanel .gotik-field > span:first-child {
  color: var(--text-muted, #64748b);
  white-space: nowrap;
  min-width: 70px;
}
#lookupGotikPanel .gotik-field .copyable {
  font-size: .78rem;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-dark, #0f172a);
}
#lookupGotikPanel .d-flex.gap-1 {
  gap: 5px !important;
  flex-wrap: wrap;
}
#lookupGotikPanel .d-flex.gap-1 .btn,
#lookupGotikPanel .btn-xs {
  font-size: .75rem;
  padding: 2px 8px;
}
#lookupGotikPanel .gotik-urls {
  gap: 5px;
  margin: 6px 0;
}
#lookupGotikPanel .gotik-url-btn {
  font-size: .75rem;
  padding: 4px 8px;
}
#lookupGotikPanel .mk-actions-grid {
  gap: 4px; margin: 6px 0 4px;
}
#lookupGotikPanel .mk-action-btn {
  font-size: .72rem; padding: 5px 4px;
}
#lookupGotikPanel .mk-tool-btn {
  font-size: .65rem; padding: 2px 6px;
}
#lookupGotikPanel .gotik-ssh-title {
  font-size: .78rem !important;
  margin-top: 8px !important;
  padding-top: 6px;
  border-top: 1px solid var(--border, #334155);
}
#lookupGotikPanel .gotik-card[style*="padding:.5rem"] {
  padding: 8px 12px !important;
  margin-bottom: 4px;
}
#lookupTicketsSection {
  max-width: 650px;
  margin: 0 auto;
}

/* ═══ FAB Button (مساعد الصيانة) ═══ */
.fab-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent, #6366f1);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  box-shadow: 0 4px 16px rgba(99, 102, 241, .4);
  cursor: pointer;
  z-index: 1000;
  transition: transform .2s, box-shadow .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(99, 102, 241, .5);
}
.fab-btn:active {
  transform: scale(.95);
}
@media (max-width: 768px) {
  .fab-btn {
    bottom: 16px;
    left: 16px;
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }
}

/* SAS Management */
.sas-search-bar { display:flex; gap:.5rem; max-width:500px; margin:0 auto 1.5rem; }
.sas-cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(420px,100%),1fr)); gap:1rem; }
.sas-card { background:var(--tblr-bg-surface); border:1px solid rgba(255,255,255,.08); border-radius:.75rem; overflow:hidden; }
.sas-card-header { padding:.75rem 1rem; border-bottom:1px solid rgba(255,255,255,.06); display:flex; align-items:center; justify-content:space-between; gap:.5rem; flex-wrap:wrap; }
.sas-card-body { padding:.75rem; }

.sas-progress { height:24px; background:rgba(255,255,255,.05); position:relative; }
.sas-progress-bar { height:100%; background:linear-gradient(90deg,#3b82f6,#8b5cf6); transition:width .3s ease; border-radius:0; }
.sas-progress-text { position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); font-size:.7rem; color:#fff; font-weight:600; white-space:nowrap; }
.sas-progress.success .sas-progress-bar { background:linear-gradient(90deg,#10b981,#059669); }
.sas-progress.error .sas-progress-bar { background:linear-gradient(90deg,#ef4444,#dc2626); }

.sas-access-table { width:100%; border-collapse:collapse; font-size:.8rem; margin:.5rem 0; table-layout:fixed; }
.sas-access-table th, .sas-access-table td { padding:.4rem .3rem; border:1px solid rgba(255,255,255,.06); text-align:center; overflow:hidden; text-overflow:ellipsis; }
.sas-access-table th { background:rgba(255,255,255,.03); font-weight:600; font-size:.7rem; color:#94a3b8; }
.sas-access-table a { display:inline-flex; align-items:center; justify-content:center; gap:3px; padding:4px 6px; border-radius:6px; background:rgba(59,130,246,.1); color:#60a5fa; font-size:.7rem; text-decoration:none; transition:background .15s; width:100%; box-sizing:border-box; }
.sas-access-table a:hover { background:rgba(59,130,246,.2); }

.sas-ops { padding:.75rem; background:rgba(255,255,255,.02); border-radius:.5rem; margin-top:.75rem; }
.sas-ops h5 { font-size:.85rem; font-weight:600; margin-bottom:.5rem; }
.sas-op-item { display:flex; align-items:center; gap:.5rem; padding:.35rem .5rem; border-radius:.375rem; cursor:pointer; transition:background .15s; font-size:.8rem; }
.sas-op-item:hover { background:rgba(255,255,255,.04); }
.sas-op-item input[type="checkbox"] { width:16px; height:16px; accent-color:#3b82f6; cursor:pointer; flex-shrink:0; }
.sas-op-num { display:inline-flex; align-items:center; justify-content:center; width:20px; height:20px; border-radius:50%; background:#3b82f6; color:#fff; font-size:.65rem; font-weight:700; flex-shrink:0; }
.sas-op-item.success { opacity:.6; }
.sas-op-item.success .sas-op-num { background:#10b981; }
.sas-op-item.failed .sas-op-num { background:#ef4444; }
.sas-op-item.running { background:rgba(59,130,246,.08); }
.sas-op-item.running .sas-op-num { background:#f59e0b; animation:sasPulse 1s infinite; }
@keyframes sasPulse { 0%,100%{opacity:1} 50%{opacity:.5} }

.sas-ops-footer { display:flex; align-items:center; justify-content:space-between; margin-top:.5rem; padding-top:.5rem; border-top:1px solid rgba(255,255,255,.06); gap:.5rem; flex-wrap:wrap; }

.sas-mk-section { margin-top:.75rem; padding:.75rem; background:rgba(6,182,212,.05); border:1px solid rgba(6,182,212,.15); border-radius:.5rem; }
.sas-mk-header { display:flex; align-items:center; gap:.5rem; margin-bottom:.5rem; font-size:.8rem; font-weight:600; color:#06b6d4; flex-wrap:wrap; }
.sas-mk-btns { display:flex; gap:.5rem; flex-wrap:wrap; }

.sas-user-info { display:flex; flex-wrap:wrap; gap:.5rem .75rem; padding:.75rem 1rem; background:rgba(255,255,255,.02); border-radius:.5rem; margin-bottom:1rem; font-size:.8rem; }
.sas-user-info span { display:flex; align-items:center; gap:.35rem; }
.sas-user-info .label { color:#94a3b8; }
.sas-user-info .value { font-weight:600; }

/* SAS Mgmt Mobile */
@media (max-width:576px) {
  .sas-search-bar { max-width:100%; }
  .sas-card-header { font-size:.8rem; padding:.6rem .75rem; }
  .sas-card-body { padding:.6rem; }
  .sas-access-table { font-size:.7rem; }
  .sas-access-table th, .sas-access-table td { padding:.35rem .2rem; }
  .sas-access-table a { font-size:.65rem; padding:3px 4px; }
  .sas-op-item { font-size:.75rem; gap:.4rem; padding:.3rem .4rem; }
  .sas-ops-footer { font-size:.75rem; }
  .sas-ops-footer .btn { font-size:.7rem; padding:.25rem .5rem; }
  .sas-mk-header { font-size:.75rem; }
  .sas-user-info { font-size:.75rem; gap:.4rem .6rem; padding:.5rem .75rem; }
}
/* Command group drag-and-drop */
.cmd-group-zone.drag-hover,
.cmd-new-group-zone.drag-hover {
  background: rgba(99, 102, 241, .08);
  border-color: #6366f1 !important;
  border-style: solid !important;
}
.cmd-card { transition: transform .1s; }
.cmd-card[draggable="true"]:hover { transform: translateX(-2px); }
