:root {
  --bg-main: #070A12;
  --bg-surface: #0E1322;
  --bg-surface-elevated: #151D33;
  --bg-surface-hover: #1C2642;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #00D06C;
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --brand-green: #00D06C;
  --brand-green-hover: #00B75E;
  --brand-green-glow: rgba(0, 208, 108, 0.25);
  --brand-green-subtle: rgba(0, 208, 108, 0.12);
  --accent-blue: #38BDF8;
  --accent-purple: #A855F7;
  --accent-amber: #F59E0B;
  --accent-rose: #F43F5E;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px var(--brand-green-glow);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Header */
.app-header {
  height: 64px;
  background: rgba(14, 19, 34, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
  flex-shrink: 0;
}

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

.header-brand img {
  height: 32px;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-green-subtle);
  color: var(--brand-green);
  border: 1px solid rgba(0, 208, 108, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--brand-green);
  box-shadow: 0 0 8px var(--brand-green);
  animation: pulseGlow 2s infinite;
}

.pulse-dot.warning {
  background-color: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
}

.pulse-dot.danger {
  background-color: var(--accent-rose);
  box-shadow: 0 0 8px var(--accent-rose);
}

@keyframes pulseGlow {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

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

/* Switch */
.switch-container {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #334155;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--brand-green);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Main Layout */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar Nav */
.sidebar-nav {
  width: 240px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 12px;
  flex-shrink: 0;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--brand-green-subtle);
  color: var(--brand-green);
  border-color: rgba(0, 208, 108, 0.25);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent-rose);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

/* Content Area */
.content-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.tab-pane {
  display: none;
  flex: 1;
  height: 100%;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
}

/* Inbox / Chat Layout */
.inbox-view {
  display: flex;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.conversations-panel {
  width: 360px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  gap: 8px;
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  width: 100%;
}

.filter-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.pill-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.pill-btn:hover {
  color: var(--text-primary);
}

.pill-btn.active {
  background: var(--brand-green);
  color: #070A12;
  border-color: var(--brand-green);
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.conversation-card {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.15s ease;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
}

.conversation-card:hover {
  background: var(--bg-surface-hover);
}

.conversation-card.active {
  background: var(--bg-surface-elevated);
  border-left: 3px solid var(--brand-green);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1E293B, #0F172A);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--brand-green);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.card-body {
  flex: 1;
  min-width: 0;
}

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

.contact-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.time-stamp {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.last-msg-preview {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.card-tags {
  display: flex;
  gap: 6px;
  align-items: center;
}

.tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.tag-bot {
  background: rgba(0, 208, 108, 0.15);
  color: var(--brand-green);
  border: 1px solid rgba(0, 208, 108, 0.3);
}

.tag-waiting {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
  animation: pulseGlow 2s infinite;
}

.tag-human {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.tag-resolved {
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-muted);
}

/* Chat Main Pane */
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  position: relative;
}

.chat-header {
  height: 68px;
  padding: 0 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-contact-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-contact-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chat-contact-phone {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--brand-green);
  color: #070A12;
}
.btn-primary:hover {
  background: var(--brand-green-hover);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.3);
}
.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

.btn-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border-color: rgba(245, 158, 11, 0.3);
}

/* Escalation Ticket Alert Bar */
.escalation-bar {
  background: linear-gradient(90deg, rgba(244, 63, 94, 0.2), rgba(245, 158, 11, 0.1));
  border-bottom: 1px solid rgba(244, 63, 94, 0.3);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.825rem;
  color: #FECDD3;
}

.escalation-badge {
  background: var(--accent-rose);
  color: white;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  margin-right: 8px;
}

/* Chat Messages Feed */
.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message-bubble {
  max-width: 65%;
  display: flex;
  flex-direction: column;
  position: relative;
  animation: fadeInMsg 0.25s ease-out;
}

@keyframes fadeInMsg {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-bubble.incoming {
  align-self: flex-start;
}

.message-bubble.outgoing {
  align-self: flex-end;
}

.bubble-meta {
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.incoming .bubble-meta {
  color: var(--text-muted);
}

.outgoing .bubble-meta {
  color: var(--brand-green);
  justify-content: flex-end;
}

.outgoing.human .bubble-meta {
  color: var(--accent-blue);
}

.bubble-content {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  word-break: break-word;
}

.incoming .bubble-content {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.outgoing .bubble-content {
  background: linear-gradient(135deg, rgba(0, 208, 108, 0.15), rgba(0, 208, 108, 0.05));
  border: 1px solid rgba(0, 208, 108, 0.3);
  color: #E2E8F0;
  border-bottom-right-radius: 4px;
}

.outgoing.human .bubble-content {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(56, 189, 248, 0.05));
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #E2E8F0;
}

.bubble-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.outgoing .bubble-time {
  justify-content: flex-end;
}

/* Chat Input Footer */
.chat-footer {
  padding: 16px 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-input-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.chat-input-row textarea {
  flex: 1;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  resize: none;
  height: 44px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-row textarea:focus {
  border-color: var(--brand-green);
}

/* KPI Metrics Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 24px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand-green);
  opacity: 0.6;
}

.metric-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-primary);
}

.metric-footer {
  font-size: 0.75rem;
  color: var(--brand-green);
}

/* Tables */
.table-container {
  padding: 0 24px 24px 24px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

tr:hover td {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* Simulator Pane */
.simulator-layout {
  display: flex;
  height: 100%;
  padding: 24px;
  gap: 24px;
}

.phone-mockup {
  width: 380px;
  height: 640px;
  background: #000;
  border-radius: 40px;
  border: 10px solid #1E293B;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 30px var(--brand-green-glow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.phone-notch {
  height: 24px;
  background: #1E293B;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notch-speaker {
  width: 50px;
  height: 4px;
  background: #334155;
  border-radius: 2px;
}

.phone-screen {
  flex: 1;
  background: #0B141B;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.phone-header {
  background: #1F2C34;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
}

.phone-chat {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.phone-input-bar {
  background: #1F2C34;
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.phone-input-bar input {
  flex: 1;
  background: #2A3942;
  border: none;
  outline: none;
  color: white;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
}

.diagnostics-panel {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}
