* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'DM Sans', sans-serif;
  background: #0d0d1a;
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* ============================================================
   SIDEBAR NAVIGATION
   ============================================================ */
.app-nav {
  width: 68px;
  background: #0a0a18;
  border-right: 1px solid #1e1e35;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  z-index: 10;
}

.nav-logo {
  padding: 16px 0 12px;
  border-bottom: 1px solid #1e1e35;
  width: 100%;
  display: flex;
  justify-content: center;
}

.nav-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}

.nav-items {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  width: 100%;
}

.nav-item {
  width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s;
  position: relative;
  font-family: 'DM Sans', sans-serif;
}

.nav-item:hover {
  background: #1a1a2e;
  color: #aaa;
}

.nav-item.active {
  background: #1a1a2e;
  color: #6366f1;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: #6366f1;
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 20px;
  height: 20px;
}

.nav-item span:not(.nav-badge) {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.nav-bottom {
  padding: 12px 0;
  border-top: 1px solid #1e1e35;
  width: 100%;
  display: flex;
  justify-content: center;
}

.nav-status {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   MAIN AREA
   ============================================================ */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ===== Header ===== */
.header {
  background: #1a1a2e;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #2a2a3e;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hotel-name {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

.header-subtitle {
  font-size: 11px;
  color: #888;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.code-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: rgba(45, 212, 191, 0.08);
  border: 1px solid rgba(45, 212, 191, 0.2);
  border-radius: 6px;
}

.code-label {
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.code-value {
  font-family: 'Space Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  color: #2dd4bf;
  letter-spacing: 3px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #888;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
}

.status-dot.connected {
  background: #2dd4bf;
}

/* ============================================================
   TAB CONTENT
   ============================================================ */
.tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
}

/* ============================================================
   DASHBOARD TAB
   ============================================================ */
.dashboard {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: #141425;
  border: 1px solid #2a2a3e;
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}

.stat-card:hover {
  border-color: #6366f1;
}

.stat-card-value {
  font-family: 'Space Mono', monospace;
  font-size: 32px;
  font-weight: 700;
  color: #6366f1;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card-label {
  font-size: 12px;
  color: #888;
  font-weight: 500;
}

.stat-card-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  opacity: 0.15;
  color: #fff;
}

.stat-card-icon svg {
  width: 100%;
  height: 100%;
}

.stat-card-amber .stat-card-value { color: #f59e0b; }
.stat-card-blue .stat-card-value { color: #3b82f6; }
.stat-card-green .stat-card-value { color: #10b981; }
.stat-card-red .stat-card-value { color: #ef4444; }

.dashboard-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dash-panel {
  background: #141425;
  border: 1px solid #2a2a3e;
  border-radius: 12px;
  overflow: hidden;
}

.dash-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #2a2a3e;
}

.dash-panel-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.btn-link {
  background: none;
  border: none;
  color: #6366f1;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}

.btn-link:hover { text-decoration: underline; }

.dash-panel-body {
  max-height: 360px;
  overflow-y: auto;
}

.dash-ticket-item, .dash-conv-item {
  padding: 10px 16px;
  border-bottom: 1px solid #1e1e35;
  cursor: pointer;
  transition: background 0.15s;
}

.dash-ticket-item:hover, .dash-conv-item:hover {
  background: #1e1e35;
}

.dash-ticket-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.dash-ticket-id {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: #6366f1;
  font-weight: 600;
}

.dash-ticket-time {
  font-size: 10px;
  color: #666;
}

.dash-ticket-summary {
  font-size: 12px;
  color: #ccc;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-ticket-meta {
  display: flex;
  gap: 6px;
  align-items: center;
}

.dash-conv-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.dash-conv-room {
  font-weight: 600;
  font-size: 13px;
  color: #fff;
}

.dash-conv-time {
  font-size: 10px;
  color: #666;
}

.dash-conv-preview {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   CONVERSATIONS TAB
   ============================================================ */
.conv-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  width: 100%;
}

.conv-sidebar {
  width: 300px;
  background: #141425;
  border-right: 1px solid #2a2a3e;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid #2a2a3e;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-header h4 {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.filter-tabs {
  display: flex;
  gap: 4px;
}

.filter-btn {
  padding: 4px 10px;
  border: 1px solid #2a2a3e;
  border-radius: 4px;
  background: transparent;
  color: #888;
  font-size: 11px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
}

.filter-btn.active {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}

.filter-btn:hover:not(.active) {
  border-color: #6366f1;
  color: #c0c0c0;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: #555;
  font-size: 13px;
}

.conv-item {
  padding: 12px 16px;
  border-bottom: 1px solid #1e1e35;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.conv-item:hover { background: #1e1e35; }

.conv-item.active {
  background: #252545;
  border-left: 3px solid #6366f1;
}

.conv-item.escalated {
  border-left: 3px solid #ef4444;
}

.conv-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #2a2a3e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.conv-info {
  flex: 1;
  min-width: 0;
}

.conv-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.conv-room {
  font-weight: 600;
  font-size: 13px;
  color: #fff;
}

.conv-time {
  font-size: 10px;
  color: #666;
}

.conv-preview {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.conv-badges {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.badge-lang { background: #1e1e35; color: #e0e0e0; }
.badge-intent { color: #fff; }

.badge-unread {
  background: #6366f1;
  color: #fff;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.badge-channel {
  background: #1e1e35;
  color: #aaa;
  font-size: 9px;
}

/* ===== Chat Panel ===== */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.placeholder-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #555;
}

.placeholder-state h3 {
  font-size: 16px;
  color: #888;
  margin-bottom: 4px;
}

.placeholder-state p {
  font-size: 13px;
  color: #555;
}

.placeholder-state.small {
  font-size: 13px;
}

.chat-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  padding: 10px 16px;
  background: #1a1a2e;
  border-bottom: 1px solid #2a2a3e;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-badge {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 15px;
  color: #2dd4bf;
}

.lang-badge { font-size: 13px; }

.channel-badge {
  font-size: 11px;
  color: #888;
  background: #2a2a3e;
  padding: 2px 8px;
  border-radius: 4px;
}

.takeover-status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
}

.takeover-status.human {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: scroll;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.msg-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-group.guest { align-items: flex-end; }
.msg-group.bot,
.msg-group.staff,
.msg-group.system { align-items: flex-start; }

.msg-speaker {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px;
}

.msg-speaker.guest { color: #2dd4bf; }
.msg-speaker.bot { color: #6b7280; }
.msg-speaker.staff { color: #818cf8; }
.msg-speaker.system { color: #eab308; }

.msg-bubble {
  max-width: 85%;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
}

.msg-group.guest .msg-bubble {
  background: #0d3d36;
  border: 1px solid #145a4e;
  color: #d0f5ee;
}

.msg-group.bot .msg-bubble {
  background: #262626;
  border: 1px solid #3a3a3a;
  color: #e0e0e0;
}

.msg-group.staff .msg-bubble {
  background: #1e1a4a;
  border: 1px solid #3730a3;
  color: #c7c3f7;
}

.msg-group.system .msg-bubble {
  background: #2a2515;
  border: 1px solid #4a3f1e;
  color: #d4c85a;
  font-size: 12px;
  text-align: center;
}

/* Main Thai text */
.msg-main-text {
  margin-bottom: 2px;
  line-height: 1.5;
}

/* Chevron toggle */
.msg-expand-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 2px 0;
  cursor: pointer;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  user-select: none;
  transition: color 0.15s;
}

.msg-expand-toggle:hover {
  color: rgba(255, 255, 255, 0.6);
}

.msg-expand-toggle.open {
  color: #6366f1;
}

.chevron-icon {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.msg-expand-toggle.open .chevron-icon {
  transform: rotate(180deg);
}

/* Collapsible translations block */
.msg-translations-collapsible {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 0;
}

.msg-translations-collapsible.open {
  max-height: 300px;
  opacity: 1;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.msg-trans-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 6px;
}

.msg-trans-row:last-child {
  margin-bottom: 0;
}

.msg-trans-flag {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  font-weight: 500;
}

.msg-trans-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.4;
}

.msg-audio-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 12px;
  color: #e0e0e0;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.msg-audio-btn:hover { background: rgba(255, 255, 255, 0.2); }

.msg-intent-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  margin-top: 4px;
}

.msg-action-badge {
  margin-top: 6px;
  padding: 4px 8px;
  background: rgba(245, 158, 11, 0.12);
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  font-size: 11px;
  color: #fbbf24;
}

.msg-time {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 4px;
}

/* Reply Area */
.reply-area {
  background: #1a1a2e;
  padding: 12px 16px;
  border-top: 1px solid #2a2a3e;
  flex-shrink: 0;
}

.reply-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.reply-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

#staff-input,
#dept-reply-input {
  flex: 1;
  padding: 10px 14px;
  background: #262640;
  border: 1px solid #3a3a5e;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
}

#staff-input:focus,
#dept-reply-input:focus {
  border-color: #6366f1;
}

.recording-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  color: #ef4444;
  font-size: 12px;
}

.pulse {
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

/* ===== Info Panel ===== */
.info-panel {
  width: 270px;
  background: #141425;
  border-left: 1px solid #2a2a3e;
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 16px;
}

.info-section {
  margin-bottom: 20px;
}

.info-section h4 {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #1e1e35;
}

.info-label {
  font-size: 12px;
  color: #888;
}

.info-value {
  font-size: 13px;
  font-weight: 600;
  color: #e0e0e0;
}

.intent-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.intent-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #1e1e35;
  border-radius: 4px;
  font-size: 11px;
}

.intent-item .intent-icon { font-size: 14px; }

.intent-item .intent-count {
  margin-left: auto;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: #888;
}

.no-data {
  font-size: 12px;
  color: #555;
}

.guest-facts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fact-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  gap: 8px;
}

.fact-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 500;
  white-space: nowrap;
  min-width: 80px;
}

.fact-value {
  font-size: 12px;
  color: #e0e0e0;
  text-align: right;
  word-break: break-word;
}

.actions-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-item {
  padding: 8px;
  background: rgba(99, 102, 241, 0.08);
  border-left: 3px solid #6366f1;
  border-radius: 4px;
}

.action-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #a5b4fc;
  text-transform: capitalize;
  margin-bottom: 3px;
}

.action-time {
  font-size: 10px;
  color: #666;
  font-weight: 400;
}

.action-summary {
  font-size: 12px;
  color: #e0e0e0;
  line-height: 1.4;
}

/* ============================================================
   DEPARTMENTS / TICKETS TAB
   ============================================================ */
.dept-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  width: 100%;
}

.dept-sidebar {
  width: 220px;
  background: #141425;
  border-right: 1px solid #2a2a3e;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.department-list {
  flex: 1;
  overflow-y: auto;
}

.dept-item {
  padding: 10px 16px;
  border-bottom: 1px solid #1e1e35;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-left: 3px solid transparent;
}

.dept-item:hover { background: #1e1e35; }
.dept-item.active { background: #252545; }

.dept-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dept-color {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dept-name {
  font-size: 12px;
  color: #e0e0e0;
  font-weight: 500;
}

.dept-name-th {
  font-size: 10px;
  color: #666;
}

.dept-count {
  min-width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #3a3a5e;
}

.dept-count.has-tickets { background: #f59e0b; color: #000; }

/* Ticket List Panel */
.ticket-list-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid #2a2a3e;
}

.ticket-list {
  flex: 1;
  overflow-y: auto;
}

.ticket-card {
  padding: 12px 16px;
  border-bottom: 1px solid #1e1e35;
  cursor: pointer;
  transition: background 0.15s;
}

.ticket-card:hover { background: #1e1e35; }
.ticket-card.active { background: #252545; border-left: 3px solid #6366f1; }

.ticket-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.ticket-card-id {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: #6366f1;
  font-weight: 600;
}

.ticket-card-time {
  font-size: 10px;
  color: #666;
}

.ticket-card-summary {
  font-size: 12px;
  color: #e0e0e0;
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ticket-card-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ticket-card-room {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: #2dd4bf;
  font-weight: 600;
}

/* Badges */
.status-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-badge.open { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.status-badge.in_progress { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.status-badge.resolved { background: rgba(16, 185, 129, 0.15); color: #10b981; }

.priority-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.priority-badge.normal { background: rgba(107, 114, 128, 0.15); color: #9ca3af; }
.priority-badge.high { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.priority-badge.urgent { background: rgba(239, 68, 68, 0.2); color: #ef4444; animation: urgentPulse 2s infinite; }

@keyframes urgentPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.dept-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: #1e1e35;
  color: #aaa;
}

/* Detail Panel */
.detail-panel {
  width: 360px;
  background: #141425;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.detail-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.detail-header {
  padding: 14px 16px;
  border-bottom: 1px solid #2a2a3e;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  background: #1a1a2e;
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ticket-id-badge {
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: #6366f1;
}

.detail-section {
  padding: 14px 16px;
  border-bottom: 1px solid #1e1e35;
}

.detail-section h4 {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 10px;
  color: #666;
}

.detail-value {
  font-size: 13px;
  font-weight: 600;
  color: #e0e0e0;
}

.detail-guest-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.guest-info-tag {
  padding: 3px 8px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 4px;
  font-size: 11px;
  color: #a5b4fc;
}

.guest-info-tag.critical {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-weight: 600;
}

.detail-request-hero {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 8px;
  padding: 12px !important;
}

.detail-request-hero .request-summary {
  margin-bottom: 0;
}

.detail-value-lg {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.request-summary {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 10px;
  line-height: 1.4;
}

.request-translations {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.request-trans-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.trans-label {
  font-size: 10px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  min-width: 28px;
  padding-top: 2px;
}

.trans-text {
  font-size: 12px;
  color: #ccc;
  line-height: 1.4;
}

.response-relayed {
  font-size: 10px;
  color: #34d399;
  margin-top: 4px;
  font-style: italic;
}

/* Suggested Responses */
.suggested-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.suggested-btn {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #2a2a3e;
  background: #1a1a2e;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.suggested-btn:hover {
  border-color: #6366f1;
  background: #252545;
}

.suggested-btn-th {
  font-size: 13px;
  color: #e0e0e0;
  margin-bottom: 3px;
}

.suggested-btn-en {
  font-size: 11px;
  color: #888;
}

.suggested-btn-type {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  margin-bottom: 4px;
}

.type-confirm { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.type-clarify { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.type-alternative { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.type-acknowledge { background: rgba(107, 114, 128, 0.15); color: #9ca3af; }
.type-delay { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* Responses */
.response-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.response-item {
  padding: 8px 10px;
  background: rgba(99, 102, 241, 0.08);
  border-left: 3px solid #6366f1;
  border-radius: 4px;
}

.response-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.response-staff {
  font-size: 11px;
  font-weight: 600;
  color: #a5b4fc;
}

.response-time {
  font-size: 10px;
  color: #666;
}

.response-text {
  font-size: 12px;
  color: #e0e0e0;
  margin-bottom: 2px;
}


/* Reply section in detail */
.reply-section {
  padding: 12px 16px !important;
}

/* Detail action buttons */
.detail-actions {
  padding: 14px 16px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  border-top: 1px solid #2a2a3e;
  background: #1a1a2e;
}

/* ============================================================
   CONFIGURATION TAB
   ============================================================ */
.config-layout {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
}

.config-panel {
  max-width: 700px;
  width: 100%;
}

.config-panel > h3 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 24px;
}

.config-section {
  background: #141425;
  border: 1px solid #2a2a3e;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.config-section h4 {
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

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

.config-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.config-item-label {
  font-size: 11px;
  color: #666;
}

.config-item-value {
  font-size: 14px;
  font-weight: 600;
  color: #e0e0e0;
}

.config-codes {
  display: flex;
  gap: 20px;
  margin-bottom: 14px;
}

.config-code-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.config-code-label {
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.config-code-value {
  font-family: 'Space Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  color: #2dd4bf;
  letter-spacing: 4px;
}

.config-code-dim {
  color: #6b7280;
  font-size: 20px;
}

.config-dept-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.config-dept-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
}

.config-dept-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.config-dept-info {
  flex: 1;
}

.config-dept-name {
  font-size: 13px;
  font-weight: 600;
  color: #e0e0e0;
}

.config-dept-name-th {
  font-size: 11px;
  color: #666;
}

.config-dept-meta {
  font-size: 11px;
  color: #888;
  text-align: right;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
}

.btn-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #6366f1;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  padding: 0;
  flex-shrink: 0;
}

.btn-send:hover { background: #5558e6; }

.btn-mic {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #262640;
  color: #ef4444;
  border: 1px solid #3a3a5e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  padding: 0;
  flex-shrink: 0;
}

.btn-mic.recording {
  background: #ef4444;
  color: #fff;
  animation: pulse 1s infinite;
}

.btn-takeover { background: #ef4444; color: #fff; }
.btn-takeover:hover { background: #dc2626; }

.btn-release { background: #10b981; color: #fff; }
.btn-release:hover { background: #059669; }

.btn-claim { flex: 1; background: #3b82f6; color: #fff; }
.btn-claim:hover { background: #2563eb; }

.btn-resolve { flex: 1; background: #10b981; color: #fff; }
.btn-resolve:hover { background: #059669; }

.btn-reopen { flex: 1; background: #f59e0b; color: #000; }
.btn-reopen:hover { background: #d97706; }

.btn-outline {
  background: transparent;
  border: 1px solid #3a3a5e;
  color: #888;
}

.btn-outline:hover {
  border-color: #6366f1;
  color: #c0c0c0;
}

.btn-sm { padding: 4px 10px; font-size: 11px; }

.btn-mobile-back {
  display: none;
  background: none;
  border: none;
  color: #6366f1;
  cursor: pointer;
  padding: 4px;
  align-items: center;
  justify-content: center;
}

.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-full { width: 100%; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast {
  position: fixed;
  top: 70px;
  right: 20px;
  background: #1a1a2e;
  border: 1px solid #6366f1;
  border-radius: 8px;
  padding: 12px 16px;
  z-index: 1000;
  animation: slideIn 0.3s ease-out;
  max-width: 300px;
}

.toast-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.toast-body {
  font-size: 12px;
  color: #aaa;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ============================================================
   RESPONSIVE — TABLET (≤1024px)
   ============================================================ */
@media (max-width: 1024px) {
  /* Hide info panel on tablet */
  .info-panel { display: none; }

  /* Shrink detail panel */
  .detail-panel { width: 300px; }

  /* Shrink conv sidebar */
  .conv-sidebar { width: 240px; }

  /* Shrink dept sidebar */
  .dept-sidebar { width: 180px; }

  /* Dashboard panels stack */
  .dashboard-panels { grid-template-columns: 1fr; }

  /* Stats grid tighter */
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤768px)
   ============================================================ */
@media (max-width: 768px) {
  body { overflow: auto; }

  #app {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  /* Nav becomes horizontal bottom bar */
  .app-nav {
    width: 100%;
    height: 56px;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid #1e1e35;
    order: 2;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 100;
    background: #0a0a18;
  }

  .nav-logo { display: none; }

  .nav-items {
    flex-direction: row;
    justify-content: space-around;
    padding: 0;
    width: 100%;
  }

  .nav-item {
    width: auto;
    padding: 6px 12px;
  }

  .nav-item.active::before { display: none; }

  .nav-bottom { display: none; }

  .nav-badge {
    top: 0;
    right: 0;
  }

  /* Main area fills screen above bottom nav */
  .app-main {
    order: 1;
    height: calc(100vh - 56px);
    overflow: hidden;
  }

  /* Header compact */
  .header { padding: 8px 12px; }
  .code-badge { display: none; }
  .hotel-name { font-size: 13px; }

  /* Tab content fills available space */
  .tab-content.active {
    flex-direction: column;
    height: 100%;
  }

  /* Dashboard */
  .dashboard { padding: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-card-value { font-size: 24px; }

  /* Conversations — single panel mode */
  .conv-layout { flex-direction: column; }
  .conv-sidebar { width: 100%; max-height: 35vh; border-right: none; border-bottom: 1px solid #2a2a3e; }
  .chat-panel { min-height: 0; flex: 1; }

  /* Departments — single panel mode */
  .dept-layout { flex-direction: column; }
  .dept-sidebar { width: 100%; max-height: none; border-right: none; border-bottom: 1px solid #2a2a3e; flex-shrink: 0; }
  .department-list { display: flex; overflow-x: auto; overflow-y: hidden; gap: 4px; padding: 8px; }
  .dept-item { border-bottom: none; border-radius: 6px; padding: 8px 12px; white-space: nowrap; flex-shrink: 0; }
  .ticket-list-panel { flex: 1; min-height: 0; }

  /* Detail panel becomes overlay on mobile */
  .detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 56px;
    width: 100%;
    z-index: 50;
    transform: translateX(100%);
    transition: transform 0.25s ease;
  }
  .detail-panel.mobile-open { transform: translateX(0); }

  /* Config */
  .config-grid { grid-template-columns: 1fr; }
  .config-codes { flex-direction: column; gap: 12px; }

  /* Show mobile back button */
  .btn-mobile-back { display: flex; }

  /* Buttons bigger for touch */
  .btn { padding: 10px 16px; font-size: 14px; min-height: 44px; }
  .btn-send, .btn-mic { width: 44px; height: 44px; }
  .filter-btn { padding: 6px 12px; font-size: 12px; min-height: 36px; }

  /* Reply area safe zone for bottom nav */
  .reply-area { padding-bottom: 16px; }

  /* Toast repositioned */
  .toast { top: auto; bottom: 70px; right: 12px; left: 12px; max-width: none; }
}
