/* Agent Portal Premium Light-Mode Stylesheet */
html {
  font-size: 90%;
}

:root {
  --agent-bg: #f8fafc; /* Slate 50 */
  --agent-surface: #ffffff;
  --agent-surface-light: #f1f5f9; /* Slate 100 */
  --agent-border: #e2e8f0; /* Slate 200 */
  --agent-border-light: rgba(0, 0, 0, 0.04);
  --agent-text: #0f172a; /* Slate 900 */
  --agent-text-muted: #64748b; /* Slate 500 */
  --agent-primary: #6366f1; /* Indigo 500 */
  --agent-primary-hover: #4f46e5; /* Indigo 600 */
  --agent-success: #10b981; /* Emerald 500 */
  --agent-warning: #f59e0b; /* Amber 500 */
  --agent-danger: #ef4444; /* Red 500 */
  --agent-sidebar-width: 290px;
  --agent-right-sidebar-width: 270px;
  --shadow-premium: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03), 0 0 0 1px rgba(0, 0, 0, 0.02);
  --shadow-dropdown: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--agent-bg);
  color: var(--agent-text);
  overflow: hidden;
  height: 100vh;
  display: flex;
}

/* Login Screen View */
.login-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, #e0e7ff 0%, #f8fafc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 2rem;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.login-screen.hidden {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}

.login-card {
  background: #ffffff;
  border: 1px solid var(--agent-border);
  border-radius: 1.5rem;
  padding: 3rem;
  width: 100%;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
}

.login-card h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--agent-primary), #d946ef);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card p {
  color: var(--agent-text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* Main Dashboard Layout */
.dashboard-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  background-color: var(--agent-bg);
}

.dashboard-container.visible {
  opacity: 1;
  pointer-events: all;
}

/* Left Utility Navigation (Slim) */
.left-util-nav {
  width: 70px;
  background-color: #f1f5f9; /* cool grey light */
  border-right: 1px solid var(--agent-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 0;
  justify-content: space-between;
}

.nav-brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, var(--agent-primary), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 900;
  font-size: 1.35rem;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.nav-bottom-actions {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
}

.active-agent-avatar-wrapper {
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.active-agent-avatar-wrapper:hover {
  transform: scale(1.05);
}

.active-agent-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--agent-primary);
  object-fit: cover;
}

.active-status-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--agent-success);
  border: 2.5px solid #f1f5f9;
}

.active-status-indicator.away { background: var(--agent-warning); }
.active-status-indicator.busy { background: var(--agent-danger); }
.active-status-indicator.offline { background: var(--agent-text-muted); }

/* Status Menu Dropup */
.status-dropdown-container {
  position: relative;
}

.status-dropup-menu {
  position: absolute;
  bottom: 55px;
  left: 10px;
  background: var(--agent-surface);
  border: 1px solid var(--agent-border);
  border-radius: 0.75rem;
  width: 160px;
  padding: 0.4rem;
  box-shadow: var(--shadow-dropdown);
  display: none;
  z-index: 100;
  animation: slide-up 0.2s ease;
}

.status-dropup-menu.active {
  display: block;
}

.status-menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: none;
  background: transparent;
  color: var(--agent-text);
  cursor: pointer;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  text-align: left;
  transition: background 0.2s ease;
}

.status-menu-item:hover {
  background: var(--agent-surface-light);
}

.status-menu-item .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--agent-success);
}
.status-menu-item .status-dot.away { background: var(--agent-warning); }
.status-menu-item .status-dot.busy { background: var(--agent-danger); }
.status-menu-item .status-dot.offline { background: var(--agent-text-muted); }

.btn-logout {
  background: transparent;
  border: none;
  color: var(--agent-text-muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  color: var(--agent-danger);
  background: rgba(239, 68, 68, 0.08);
}

/* Sidebar Column */
.sidebar-chats {
  width: var(--agent-sidebar-width);
  background-color: var(--agent-surface);
  border-right: 1px solid var(--agent-border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1.5rem 1.25rem 0.75rem 1.25rem;
}

.sidebar-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 1rem;
  color: #0f172a;
}

.queue-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--agent-border);
  padding-bottom: 1px;
}

.queue-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--agent-text-muted);
  padding: 0.75rem 0;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  position: relative;
  transition: color 0.2s ease;
}

.queue-tab-btn.active {
  color: var(--agent-primary);
}

.queue-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--agent-primary);
}

.queue-count {
  background: #f1f5f9;
  border: 1px solid var(--agent-border);
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
  margin-left: 0.25rem;
  font-weight: 600;
  color: var(--agent-text-muted);
}

.queue-tab-btn.active .queue-count {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.2);
  color: var(--agent-primary);
}

/* Chat Item Lists */
.chat-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chat-list-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  padding: 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.chat-list-item:hover {
  background: #f8fafc;
}

.chat-list-item.selected {
  background: rgba(99, 102, 241, 0.05);
  border-color: rgba(99, 102, 241, 0.15);
}

.chat-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.visitor-name-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: #1e293b;
}

.chat-time {
  font-size: 0.75rem;
  color: var(--agent-text-muted);
}

.chat-item-snippet {
  font-size: 0.8rem;
  color: var(--agent-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.25rem;
}

.department-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.department-badge.sales { color: #db2777; border: 1px solid #fbcfe8; background: #fdf2f8; }
.department-badge.support { color: #0284c7; border: 1px solid #bae6fd; background: #f0f9ff; }
.department-badge.billing { color: #e11d48; border: 1px solid #fecdd3; background: #fff1f2; }

.unread-badge-agent {
  background: var(--agent-primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9999px;
  padding: 0 0.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.claim-chat-btn-inline {
  background: var(--agent-primary);
  border: none;
  color: white;
  padding: 0.3rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.claim-chat-btn-inline:hover {
  background: var(--agent-primary-hover);
  transform: translateY(-1px);
}

/* Empty States */
.empty-queue-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--agent-text-muted);
  gap: 0.75rem;
  text-align: center;
  padding: 1.5rem;
}

.empty-queue-message svg {
  width: 40px;
  height: 40px;
  color: #cbd5e1;
}

.empty-queue-message p {
  font-size: 0.82rem;
}

/* Central Chat Pane */
.main-chat-pane {
  flex: 1;
  background-color: #f8fafc;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--agent-border);
}

.chat-pane-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--agent-text-muted);
  background: #f8fafc;
}

.chat-pane-placeholder svg {
  width: 56px;
  height: 56px;
  color: #cbd5e1;
}

.chat-pane-placeholder h3 {
  font-size: 1.1rem;
  font-weight: 750;
  color: #1e293b;
}

.chat-pane-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--agent-border);
  background: var(--agent-surface);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-pane-header-left {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.header-visitor-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
}

.header-visitor-meta {
  font-size: 0.8rem;
  color: var(--agent-text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-pane-header-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-danger-action {
  background: #fef2f2;
  border: 1px solid #fee2e2;
  color: var(--agent-danger);
  padding: 0.45rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger-action:hover {
  background: var(--agent-danger);
  color: white;
  border-color: var(--agent-danger);
}

.btn-primary-action {
  background: var(--agent-primary);
  border: none;
  color: white;
  padding: 0.45rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary-action:hover {
  background: var(--agent-primary-hover);
}

/* Chat History (Agent view) */
.agent-chat-history {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #f8fafc;
}

/* Message Styles (Dashboard Specific override) */
.agent-chat-history .message-bubble {
  max-width: 65%;
  display: flex;
  flex-direction: column;
  animation: slide-up 0.25s ease forwards;
}

.agent-chat-history .message-bubble.visitor {
  align-self: flex-start;
}

.agent-chat-history .message-bubble.agent {
  align-self: flex-end;
}

.agent-chat-history .message-bubble.system {
  align-self: center;
  max-width: 90%;
}

.agent-chat-history .visitor .msg-text-wrapper {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid var(--agent-border);
  border-radius: 1rem;
  border-bottom-left-radius: 0.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.agent-chat-history .agent .msg-text-wrapper {
  background: linear-gradient(135deg, var(--agent-primary), #4f46e5);
  color: white;
  border-radius: 1rem;
  border-bottom-right-radius: 0.25rem;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.15);
}

.agent-chat-history .system .msg-text-wrapper {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: var(--agent-text-muted);
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  text-align: center;
}

.agent-chat-history .msg-sender {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--agent-text-muted);
  margin-bottom: 0.2rem;
  margin-left: 0.25rem;
}

.agent-chat-history .agent .msg-sender {
  text-align: right;
  margin-left: 0;
  margin-right: 0.25rem;
}

.agent-chat-history .msg-text-wrapper {
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
}

.agent-chat-history .msg-meta {
  font-size: 0.68rem;
  color: var(--agent-text-muted);
  margin-top: 0.25rem;
  display: block;
}

.agent-chat-history .agent .msg-meta {
  text-align: right;
}

/* Typing indicator for Agent window */
.agent-chat-history .typing-bubble {
  background: #ffffff;
  border: 1px solid var(--agent-border);
}

/* Chat Input Composer */
.agent-chat-composer {
  padding: 1rem 1.25rem 1.25rem 1.25rem;
  background: var(--agent-surface);
  border-top: 1px solid var(--agent-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.composer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.canned-dropdown-wrapper {
  position: relative;
}

.btn-canned-trigger {
  background: #f8fafc;
  border: 1px solid var(--agent-border);
  color: var(--agent-text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.btn-canned-trigger:hover {
  border-color: var(--agent-primary);
  color: var(--agent-primary);
  background: rgba(99, 102, 241, 0.04);
}

.canned-dropup {
  position: absolute;
  bottom: 38px;
  left: 0;
  background: #ffffff;
  border: 1px solid var(--agent-border);
  border-radius: 0.75rem;
  width: 320px;
  max-height: 250px;
  overflow-y: auto;
  box-shadow: var(--shadow-dropdown);
  display: none;
  z-index: 100;
  padding: 0.4rem;
}

.canned-dropup.active {
  display: block;
  animation: slide-up 0.2s ease;
}

.canned-category-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--agent-primary);
  text-transform: uppercase;
  padding: 0.35rem 0.5rem;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
  border-bottom: 1px dashed var(--agent-border);
}

.canned-item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.5rem;
  text-align: left;
  color: var(--agent-text);
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 0.375rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  transition: background 0.15s ease;
}

.canned-item:hover {
  background: var(--agent-surface-light);
}

.canned-item-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 550;
}

.canned-item-shortcut {
  font-size: 0.7rem;
  color: var(--agent-text-muted);
}

.composer-input-area {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.composer-textarea-wrapper {
  flex: 1;
  background: #f8fafc;
  border: 1px solid var(--agent-border);
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.composer-textarea-wrapper:focus-within {
  border-color: var(--agent-primary);
  background: #ffffff;
}

.composer-textarea-wrapper textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--agent-text);
  font-family: inherit;
  font-size: 0.88rem;
  resize: none;
  height: 48px;
  overflow-y: auto;
  line-height: 1.4;
}

.btn-send-agent {
  background: var(--agent-primary);
  color: white;
  border: none;
  height: 40px;
  width: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

.btn-send-agent:hover {
  background: var(--agent-primary-hover);
  transform: translateY(-1px);
}

/* Right Details Sidebar */
.right-sidebar-details {
  width: var(--agent-right-sidebar-width);
  background-color: var(--agent-surface);
  border-left: 1px solid var(--agent-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.right-sidebar-section {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--agent-border);
}

.right-sidebar-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--agent-text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

/* Metadata Card */
.metadata-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.metadata-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
}

.metadata-label {
  color: var(--agent-text-muted);
}

.metadata-val {
  font-weight: 600;
  color: #1e293b;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Internal Notes */
.notes-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.notes-textarea {
  background: #f8fafc;
  border: 1px solid var(--agent-border);
  border-radius: 0.5rem;
  color: var(--agent-text);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.5rem;
  height: 90px;
  resize: none;
  outline: none;
  transition: all 0.2s ease;
}

.notes-textarea:focus {
  border-color: var(--agent-primary);
  background: #ffffff;
}

.btn-save-notes {
  align-self: flex-end;
  background: #f8fafc;
  border: 1px solid var(--agent-border);
  color: var(--agent-text);
  padding: 0.35rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-save-notes:hover {
  background: var(--agent-primary);
  border-color: var(--agent-primary);
  color: white;
}

/* Quick Actions (Transfer / Close) */
.actions-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.select-transfer {
  background: #f8fafc;
  border: 1px solid var(--agent-border);
  color: var(--agent-text);
  padding: 0.45rem;
  border-radius: 0.5rem;
  outline: none;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.select-transfer:focus {
  border-color: var(--agent-primary);
}

.select-transfer option {
  background: #ffffff;
  color: var(--agent-text);
}

/* Sound and Alert Utility Settings */
.sidebar-footer-settings {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--agent-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  background: #f8fafc;
}

.sound-toggle-btn {
  background: transparent;
  border: none;
  color: var(--agent-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}

.sound-toggle-btn.active {
  color: var(--agent-primary);
}

/* Animations */
@keyframes slide-up {
  from { transform: translateY(5px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Typing Indicator styling for Agent Dashboard */
.typing-indicator-container {
  padding: 0.5rem 1.5rem;
  display: none;
  align-items: center;
  background: transparent;
}

.typing-indicator-container.active {
  display: flex;
}

.typing-bubble {
  background: #ffffff;
  border: 1px solid var(--agent-border);
  padding: 0.5rem 0.75rem;
  border-radius: 1rem;
  border-bottom-left-radius: 0.25rem;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.typing-text {
  font-size: 0.75rem;
  color: var(--agent-text-muted);
  font-weight: 550;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--agent-primary);
  animation: dot-bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-of-type(1) { animation-delay: -0.32s; }
.typing-dot:nth-of-type(2) { animation-delay: -0.16s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

@media (max-width: 1024px) {
  .right-sidebar-details {
    display: none;
  }
}
