

:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --border: #e5e7eb;
  --danger: #ef4444;
  --success: #16a34a;
  --inactive: #f97316;
  --chatcontrast: rgb(241, 241, 12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}



header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

header .right {
  display: flex;
  gap: 12px;
  align-items: center;
}

main {
  display: flex;
  height: calc(100vh - 56px);
}

.sidebar {
  width: 360px;
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.chat-main-column {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.actions-container {
  width: 320px;
  border-left: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
}



.sidebar h2 {
  margin: 12px 0 8px;
  font-size: 16px;
}

li.chat {
  padding: 10px;
  margin-bottom: 6px;
  background: var(--chatcontrast);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  border-left-width: 20px;
}

li.chat.bot-color-1 {
  border-left-color: #b1b1b1; 
}
li.chat.bot-color-2 {
  border-left-color: #a7f3d0; 
}
li.chat.bot-color-3 {
  border-left-color: #bae6fd; 
}
li.chat.bot-color-4 {
  border-left-color: #801aec; 
}

li.chat .meta {
  font-size: 12px;
  color: var(--muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  margin-left: auto;
  flex-shrink: 0;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background-color: var(--border);
}

.chat-info {
  flex-grow: 1;
  min-width: 0;
}

.chat-info-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.chat-name-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.chat-time {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.chat-info-top strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-snippet {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}


#chatHeader {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  min-height: 56px;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  padding: 8px 10px;
  border-radius: 8px;
  max-width: 70%;
  white-space: normal;
  word-break: break-word;
}

.msg .time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  text-align: right;
}

.msg.user {
  background: #e5f0ff;
  align-self: flex-start;
}

.msg.admin {
  background: #eaf7ea;
  align-self: flex-end;
}

.msg.system {
  background: #f3f4f6;
  color: #6b7280;
  align-self: center;
  font-size: 12px;
}

.msg-photo {
  max-width: 100%;
  max-height: 250px;
  border-radius: 6px;
  display: block;
  cursor: pointer;
}

.msg-doc {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  transition: background-color 0.2s;
}

.msg-doc:hover {
  background-color: #1d4ed8;
}

.msg-doc svg {
  stroke: currentColor;
}

.msg-text {
  margin-top: 4px;
}

.msg-photo + .msg-text {
  margin-top: 8px;
}


#sendForm {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--card);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.file-preview {
  display: none; 
  padding: 6px 10px;
  background-color: #f3f4f6;
  border-radius: 6px;
  font-size: 12px;
  justify-content: space-between;
  align-items: center;
}

.file-preview span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clear-file-btn {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}

.clear-file-btn:hover {
  color: var(--danger);
}

#msgText {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  overflow-y: auto;
  max-height: 120px;
  transition: border-color 0.2s;
}

#msgText:focus {
  outline: none;
  border-color: var(--accent);
}


.actions-container h3 {
  margin-top: 10px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.actions form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.actions button,
.actions select,
.actions input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

button {
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 5px;
}

.logout {
  color: var(--danger);
  text-decoration: none;
  font-weight: 600;
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  color: var(--muted);
  transition: background-color 0.2s, color 0.2s;
}

.icon-button:hover {
  background-color: #f1f5f9;
  color: var(--accent);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

#sendForm .input-row button {
  background: var(--accent);
  color: white;
}

#sendForm .input-row button:hover {
  background: #1d4ed8;
}


.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input {
  display: none;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ccc;
  border-radius: 28px;
  transition: .2s;
}

.slider:before {
  position: absolute;
  content: '';
  height: 22px;
  width: 22px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: .2s;
}

input:checked + .slider {
  background: var(--success);
}

input:checked + .slider:before {
  transform: translateX(22px);
}


.error {
  color: var(--danger);
  margin-bottom: 8px;
}

.status-label {
  font-size: 12px;
  color: var(--muted);
}



.tabs-container {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px; 
}

.tabs {
  display: flex;
  flex-wrap: wrap; 
  gap: 4px; 
}

.tab-button {
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}

.tab-button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}


.users-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.users-header button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
}

.table-container {
  margin-top: 12px;
  overflow-x: auto;
}

#usersTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#usersTable th, #usersTable td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

#usersTable th {
  background-color: #f9fafb;
}

.status-active { color: var(--success); font-weight: 600; }
.status-inactive { color: var(--inactive); font-weight: 600; }

.edit-user-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
}


#qaLogList {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.qa-item {
  font-size: 13px;
  padding: 8px;
  background: #f9fafb;
  border-radius: 6px;
}
.qa-time {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
}
.qa-text a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}



.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.visible {
  display: flex;
}

.modal-content {
  background: var(--card);
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 400px;
}


#successModal .modal-content {
  text-align: center;
}
#successModal .modal-content p {
  margin: 0 0 16px;
  font-size: 16px;
}
#successModal .modal-content button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 600;
}


#userModal .modal-content h3 {
  margin-top: 0;
}
#userModal form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-group {
  display: flex;
  flex-direction: column;
}
.form-group label {
  margin-bottom: 4px;
  font-weight: 600;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
}
.form-group-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.modal-actions button {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.modal-actions button[type="submit"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.actions button,
.actions select,
.actions input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

#reassignAdminSelect {
  max-height: 150px;
}



#btnWaiting {
  background-color: var(--text);
  color: white;
  border: none;
}

#reassignForm button {
  background-color: var(--chatcontrast);
  color: var(--text);
  font-weight: 600;
  border-color: #e0ca0d;
}

#closeForm button {
  background-color: var(--danger);
  color: white;
  border: none;
}

#paymentForm button {
  background-color: var(--success);
  color: white;
  border: none;
}


#waitingChats li.chat {
  background-color: var(--text); 
  color: white; 
  border-color: #4a5568;
}

#waitingChats li.chat .meta {
  color: #a0aec0; 
}


#closedChats li.chat,
#closedByMeChats li.chat {
  background-color: #f3f4f6;
  color: var(--muted);
  border-color: #e5e7eb;
}

#closedChats li.chat strong,
#closedByMeChats li.chat strong {
  color: var(--text);
}


.activity-admin {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden; 
}

.activity-admin.clickable .activity-admin-header {
  cursor: pointer;
}

.activity-admin.clickable .activity-admin-header:hover {
  background-color: #f9fafb;
}

.activity-admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  transition: background-color 0.2s;
}

.activity-admin-header span:first-child {
  font-weight: 600;
}

.status-online, .status-offline {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-online {
  background-color: #dcfce7;
  color: #15803d;
}

.status-offline {
  background-color: #f3f4f6;
  color: var(--muted);
}

.activity-log-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background-color: #f9fafb;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid transparent; 
}

.activity-admin.open .activity-log-details {
  max-height: 500px; 
  transition: max-height 0.4s ease-in;
  border-top-color: var(--border); 
}

.activity-log-details ul {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-log-details li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.log-ts {
  color: var(--text);
  flex-shrink: 0;
}

.log-action {
  text-align: right;
}




.template-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.template-info strong {
  display: block;
  margin-bottom: 4px;
}

.template-info p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.template-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.template-actions button {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  background: none;
  border: 1px solid var(--border);
}

.template-actions .delete-template-btn {
  color: var(--danger);
}
.template-actions .delete-template-btn:hover {
  background-color: var(--danger);
  color: white;
}

#templateModal textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  resize: vertical;
}

.message-templates-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.template-button {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: #f9fafb;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s;
}

.template-button:hover {
  background-color: #f3f4f6;
}

.msg {
  position: relative;
}

.reply-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.msg:hover .reply-btn {
  display: flex;
}

.reply-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--muted);
}

.reply-btn:hover {
  background-color: var(--accent);
}
.reply-btn:hover svg {
  stroke: white;
}


.msg-reply {
  padding: 4px 8px;
  margin-bottom: 4px;
  background-color: rgba(0, 0, 0, 0.05);
  border-left: 2px solid var(--accent);
  border-radius: 4px;
  font-size: 12px;
}

.msg-reply strong {
  color: var(--accent);
  display: block;
  margin-bottom: 2px;
}

.msg-reply p {
  margin: 0;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


#replyPreview {
  display: none;
  padding: 8px 12px;
  background-color: #f3f4f6;
  border-top: 1px solid var(--border);
  font-size: 13px;
  justify-content: space-between;
  align-items: center;
}

#replyPreview.visible {
  display: flex;
}

#replyPreviewContent {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}

#cancelReplyBtn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}



.image-modal .image-modal-content {
  background: transparent;
  box-shadow: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#modalImage {
  max-width: 90vw;
  max-height: 90vh;
  display: block;
  border-radius: 8px;
}

.image-modal-close {
  position: absolute;
  top: 15px;
  right: 25px;
  font-size: 40px;
  font-weight: bold;
  color: white;
  background: none;
  border: none;
  cursor: pointer;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  z-index: 1001;
  line-height: 1;
}

.btn-danger {
  background-color: var(--danger);
  color: white;
  border: none;
}

.btn-danger:hover {
  background-color: #dc2626;
}


.block-form {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.block-form input {
  flex-grow: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.block-form button {
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  background-color: var(--danger);
  color: white;
  cursor: pointer;
}

#blacklistTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#blacklistTable th, #blacklistTable td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

#blacklistTable th {
  background-color: #f9fafb;
}

.unblock-client-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.btn-success {
  background-color: var(--success);
  color: white;
  border: none;
}

.btn-success:hover {
  background-color: #15803d;
}



.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.msg-content-wrapper {
  flex-grow: 1;
}

.msg-meta {
  flex-shrink: 0;
}

.msg-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.msg:hover .msg-buttons {
  opacity: 1;
}

.msg-buttons button {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin: 0;
}

.msg-buttons button svg {
  width: 16px;
  height: 16px;
  stroke: var(--muted);
}

.msg-buttons button:hover {
  background-color: var(--accent);
}
.msg-buttons button:hover svg {
  stroke: white;
}

.msg.user .msg-buttons {
  order: -1; 
}

.msg-edit-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-edit-textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 50px;
}

.msg-edit-textarea:focus {
  outline: none;
}

.msg-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.msg-edit-actions button {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.msg-edit-actions .msg-edit-save {
  background-color: var(--accent);
  color: white;
  border-color: var(--accent);
}

.delete-user-btn {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.delete-user-btn:hover {
  background: var(--danger);
  color: white;
}

#usersTable td:last-child {
  display: flex;
  gap: 4px;
}



#chatSearchInput {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}

.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.pagination-controls button {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-weight: 600;
  cursor: pointer;
  margin: 0;
}

.pagination-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-controls span {
  font-size: 13px;
  color: var(--muted);
}