﻿:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --line: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0ea5e9;
}

body { background: var(--bg); color: var(--text); }
.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  grid-template-areas: "left center right";
  min-height: 100vh;
}
.app-shell.sidebar-collapsed {
  grid-template-columns: 92px minmax(0, 1fr) 320px;
}

.sidebar-left { grid-area: left; }
.main-center { grid-area: center; }
.sidebar-right { grid-area: right; }

.sidebar-left, .main-center, .sidebar-right {
  border-right: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
}
.sidebar-right { border-right: 0; border-left: 1px solid var(--line); }
.sidebar-left { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand-block {
  width: 42px; height: 42px; border-radius: 10px;
  background: #111827; color: #fff; display: grid; place-items: center; font-weight: 700;
}
.channel-nav { display: flex; flex-direction: column; gap: 8px; }
.channel-item {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px;
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 8px; text-align: left;
  cursor: pointer;
}
.channel-item.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.channel-icon {
  background: var(--channel-color, #94a3b8); color: #fff; border-radius: 8px;
  width: 30px; height: 30px; display: grid; place-items: center; font-size: 12px;
}
.channel-label { font-size: 14px; }
.channel-badge {
  min-width: 22px; padding: 2px 6px; border-radius: 999px; background: #0f172a; color: #fff; font-size: 12px;
}
.sidebar-bottom-actions { margin-top: auto; display: grid; gap: 8px; }
.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #0f172a;
  text-decoration: none;
  border-radius: 10px;
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.icon-btn.primary { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.icon-btn.danger { color: #dc2626; }
.action-label { font-size: 13px; }

.main-center { display: grid; grid-template-rows: auto 1fr; min-width: 0; }
.ticket-header {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ticket-header h1 { font-size: 18px; }
.ticket-header p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ticket-actions { display: flex; gap: 8px; }
.ticket-actions button {
  border: 1px solid var(--line); background: #fff; padding: 8px 12px; border-radius: 8px; cursor: pointer;
}
.ticket-actions .danger { color: #dc2626; }

.center-workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}

.inbox-list-panel {
  border-right: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}
.inbox-filters { padding: 10px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inbox-filters select { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.conversation-list { overflow-y: auto; }
.conversation-item {
  width: 100%; border: 0; background: #fff; border-bottom: 1px solid var(--line);
  text-align: left; padding: 10px 10px 10px 14px; display: grid; gap: 6px; cursor: pointer;
  position: relative;
  --brand-color: transparent;
  --brand-glow: rgba(14, 165, 233, 0.2);
  transition: background-color 120ms ease, box-shadow 140ms ease;
}
.conversation-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--brand-color);
  border-radius: 0 4px 4px 0;
  transition: width 120ms ease;
}
.conversation-item:hover {
  background: #f8fbff;
  box-shadow: inset 0 0 0 1px var(--brand-glow), 0 0 0 1px var(--brand-glow);
}
.conversation-item:hover::before {
  width: 5px;
}
.conversation-item.active {
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px var(--brand-glow), 0 0 0 1px var(--brand-glow);
}
.conversation-item.active::before {
  width: 6px;
}
.conversation-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.conversation-subject { font-weight: 600; font-size: 14px; }
.conversation-time { color: var(--muted); font-size: 12px; }
.conversation-meta-row { display: flex; justify-content: space-between; gap: 8px; }
.brand-tag, .channel-tag, .priority-tag, .status-tag {
  display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 11px;
}
.channel-tag { background: #f1f5f9; color: #334155; text-transform: uppercase; }
.priority-tag { background: #fef3c7; color: #92400e; }
.status-tag { background: #e2e8f0; color: #334155; }
.status-tag.status-open { background: #dcfce7; color: #166534; }
.status-tag.status-pending { background: #fef3c7; color: #92400e; }
.status-tag.status-closed { background: #e2e8f0; color: #334155; }
.status-tag.status-archived { background: #f1f5f9; color: #475569; }
.unread-pill { background: #111827; color: #fff; border-radius: 999px; min-width: 22px; text-align: center; font-size: 11px; padding: 2px 6px; }
.unread-pill.hidden { visibility: hidden; }
.conversation-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.conversation-panel { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.conversation-meta {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 48px;
}
.message-thread {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.bubble {
  max-width: 72%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
}
.bubble header { display: flex; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.bubble-content p { margin: 0 0 4px; }
.bubble-content code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 2px 6px;
}
.bubble-client { background: #f8fafc; align-self: flex-start; }
.bubble-operator { background: #e0f2fe; align-self: flex-end; }
.message-attachments { margin-top: 6px; display: grid; gap: 4px; }
.message-attachments a { color: #0f172a; text-decoration: none; font-size: 12px; }
.message-attachments a:hover { text-decoration: underline; }
.empty-state { color: var(--muted); font-size: 14px; }

.composer {
  border-top: 1px solid var(--line);
  padding: 12px;
  background: #fff;
  position: sticky;
  bottom: 0;
}
.composer-toolbar { display: flex; gap: 6px; margin-bottom: 8px; }
.editor {
  min-height: 72px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  outline: none;
}
.composer-actions { margin-top: 8px; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.composer-actions button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 12px;
}
.composer-actions .primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.attachment-name { color: var(--muted); font-size: 12px; margin-right: auto; }

.sidebar-right { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.sidebar-right h2 { font-size: 16px; }
.widget { border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.widget h3 { font-size: 13px; margin-bottom: 6px; color: var(--muted); }
.tag {
  display: inline-block; font-size: 12px; padding: 3px 8px; border-radius: 999px;
}
.tag.urgent { background: #fee2e2; color: #b91c1c; }
.tag.open { background: #dcfce7; color: #166534; }
.widget textarea, .widget select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}
.modal.open { display: flex; }
.modal-card {
  width: min(520px, 96vw);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 8px;
}
.modal-card input,
.modal-card select,
.modal-card textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}
.modal-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal-actions .primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}
.modal-hint { font-size: 12px; color: #b45309; }
.modal-link { font-size: 12px; color: #0369a1; text-decoration: none; margin-top: -4px; }
.modal-link:hover { text-decoration: underline; }

.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-card {
  width: min(380px, 94vw); padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  display: grid; gap: 10px;
}
.login-card p { color: var(--muted); }
.login-card input,
.login-card select,
.login-card textarea { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.login-card button { background: #111827; color: #fff; border: 0; border-radius: 8px; padding: 10px; cursor: pointer; }
.alert-error { background: #fee2e2; color: #991b1b; padding: 8px; border-radius: 8px; }
.alert-success { background: #dcfce7; color: #166534; padding: 8px; border-radius: 8px; }

.app-shell.sidebar-collapsed .channel-label,
.app-shell.sidebar-collapsed .action-label { display: none; }
.app-shell.sidebar-collapsed .channel-item {
  grid-template-columns: 30px auto;
  justify-content: space-between;
}
.app-shell.sidebar-collapsed .channel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 2px 5px;
  font-size: 11px;
}

@media (max-width: 1360px) {
  .app-shell { grid-template-columns: 92px minmax(0, 1fr); grid-template-areas: "left center"; }
  .app-shell.sidebar-collapsed { grid-template-columns: 92px minmax(0, 1fr); }
  .sidebar-right { display: none; }
  .channel-label, .action-label { display: none; }
}

@media (max-width: 980px) {
  .center-workspace { grid-template-columns: 1fr; }
  .inbox-list-panel { border-right: 0; border-bottom: 1px solid var(--line); max-height: 220px; }
  .composer { position: static; }
}

.widget-actions { margin-top: 8px; display: flex; justify-content: flex-end; }
.widget-actions button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 10px; cursor: pointer; }

.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #0f172a;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.hide {
  opacity: 0;
  transform: translateY(-6px);
}

.realtime-status {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #64748b;
}

.realtime-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
}

.realtime-status.is-online { color: #166534; }
.realtime-status.is-online::before { background: #22c55e; }

.realtime-status.is-connecting { color: #92400e; }
.realtime-status.is-connecting::before { background: #f59e0b; }

.realtime-status.is-retrying { color: #b45309; }
.realtime-status.is-retrying::before { background: #fb923c; }

.realtime-status.is-fallback { color: #475569; }
.realtime-status.is-fallback::before { background: #94a3b8; }

.message-attachments a { color: #0f172a; text-decoration: none; font-size: 12px; }
.message-attachments a:hover { text-decoration: underline; }
.attachment-preview { display: grid; gap: 6px; }
.attachment-preview img,
.attachment-preview video {
  width: min(280px, 100%);
  border-radius: 10px;
  border: 1px solid #dbe3ee;
  background: #fff;
}
.attachment-preview audio {
  width: min(320px, 100%);
}
.attachment-preview figcaption {
  font-size: 12px;
  color: #334155;
}
.attachment-preview figcaption a { font-weight: 600; }
html, body {
  height: 100%;
  overflow: hidden;
}

.app-shell {
  height: 100vh;
  overflow: hidden;
}

.main-center,
.sidebar-left,
.sidebar-right {
  height: 100vh;
  overflow: hidden;
}

.sidebar-left,
.sidebar-right {
  overflow-y: auto;
}

.center-workspace {
  overflow: hidden;
}

.inbox-list-panel,
.conversation-panel {
  min-height: 0;
}

.day-separator {
  align-self: center;
  font-size: 11px;
  color: #64748b;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 3px 10px;
}

.emoji-panel {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fff;
}

.emoji-btn {
  border: 1px solid #dbe3ee;
  background: #f8fafc;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.emoji-btn:hover {
  background: #eef2ff;
}

.attachment-preview.attachment-audio {
  gap: 4px;
  background: #ffffff;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  padding: 8px;
}

.attachment-preview audio {
  width: min(320px, 100%);
  height: 34px;
}



