@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-main: #090d16;
  --bg-card: rgba(18, 24, 38, 0.7);
  --bg-card-hover: rgba(26, 35, 54, 0.85);
  --bg-sidebar: #0d121f;
  --bg-header: rgba(13, 18, 31, 0.85);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.5);
  
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.25);
  
  --accent-cyan: #06b6d4;
  --accent-indigo: #6366f1;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-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.25);
}

/* App Container Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  user-select: none;
}

.sidebar-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.logo-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #10b981, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--primary-glow);
  font-weight: 700;
  font-size: 20px;
  color: #fff;
}

.logo-text h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(to right, #fff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: #fff;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
  font-weight: 600;
}

.nav-item.active svg {
  color: var(--primary);
}

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

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}

.system-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
  display: inline-block;
  margin-right: 6px;
}

.user-profile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #334155;
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.user-details h4 {
  font-size: 12.5px;
  font-weight: 600;
}

.user-details span {
  font-size: 11px;
  color: var(--text-subtle);
}

.btn-icon-logout {
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-icon-logout:hover {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(circle at 85% 15%, rgba(16, 185, 129, 0.04) 0%, transparent 40%),
              radial-gradient(circle at 15% 85%, rgba(6, 182, 212, 0.04) 0%, transparent 40%),
              var(--bg-main);
}

.topbar {
  height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-left h1 {
  font-size: 17px;
  font-weight: 600;
}

.tenant-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-pill {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-connected {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-ai {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Page Container */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* Glass Cards */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.emerald { background: rgba(16, 185, 129, 0.12); color: var(--primary); }
.stat-icon.cyan { background: rgba(6, 182, 212, 0.12); color: var(--accent-cyan); }
.stat-icon.indigo { background: rgba(99, 102, 241, 0.12); color: var(--accent-indigo); }
.stat-icon.amber { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }

.stat-content h3 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.stat-content p {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
}

.btn-primary {
  background: var(--primary);
  color: #042f22;
}

.btn-primary:hover {
  background: #34d399;
  box-shadow: 0 0 16px var(--primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

th {
  background: rgba(0, 0, 0, 0.25);
  padding: 12px 16px;
  color: var(--text-subtle);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Inbox 3-Column Layout */
.inbox-wrapper {
  display: flex;
  height: calc(100vh - 120px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  background: var(--bg-card);
}

.inbox-sidebar {
  width: 320px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: rgba(13, 18, 31, 0.6);
  flex-shrink: 0;
}

.inbox-search-box {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.inbox-search-box input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.inbox-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
}

.inbox-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-subtle);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.inbox-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(16, 185, 129, 0.05);
}

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

.conversation-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.15s;
}

.conversation-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.conversation-item.active {
  background: rgba(16, 185, 129, 0.08);
  border-left: 3px solid var(--primary);
}

.conv-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.conv-item-name {
  font-weight: 600;
  font-size: 13.5px;
}

.conv-item-time {
  font-size: 11px;
  color: var(--text-subtle);
}

.conv-item-snippet {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item-badges {
  margin-top: 6px;
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Chat View */
.inbox-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(9, 13, 22, 0.4);
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(13, 18, 31, 0.8);
}

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

.message-bubble {
  max-width: 65%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.message-bubble.inbound {
  align-self: flex-start;
  background: #1e293b;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.message-bubble.outbound-ai {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-bottom-right-radius: 4px;
}

.message-bubble.outbound-agent {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(168, 85, 247, 0.25));
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-bottom-right-radius: 4px;
}

.msg-sender-tag {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
  display: block;
}

.msg-sender-tag.ai { color: var(--primary); }
.msg-sender-tag.agent { color: #a5b4fc; }
.msg-sender-tag.customer { color: #94a3b8; }

.msg-meta {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-subtle);
  margin-top: 4px;
}

.chat-input-bar {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(13, 18, 31, 0.8);
  display: flex;
  gap: 12px;
}

.chat-input-bar input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-size: 13.5px;
  outline: none;
}

.chat-input-bar input:focus {
  border-color: var(--border-focus);
}

/* Info Sidebar */
.inbox-info {
  width: 280px;
  border-left: 1px solid var(--border-subtle);
  padding: 20px;
  overflow-y: auto;
  background: rgba(13, 18, 31, 0.6);
  flex-shrink: 0;
}

.info-field {
  margin-bottom: 16px;
}

.info-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 4px;
}

.info-value {
  font-size: 13.5px;
  color: var(--text-main);
  font-weight: 500;
}

/* Auth / Login Modal View */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.95);
  backdrop-filter: blur(20px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  margin: auto;
}

.quick-login-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.quick-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.quick-btn span {
  color: var(--primary);
  font-weight: 600;
  font-size: 11px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  width: 100%;
  max-width: 540px;
  background: #131b2e;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-size: 13.5px;
  outline: none;
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--border-focus);
}
