/* Premium Glassmorphic Dark Theme Styling */
:root {
  --bg-primary: #0b0f19;
  --bg-sidebar: #111827;
  --bg-card: #1f2937;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #374151;
  
  --accent-color: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --accent-incoming: #1f2937;
  --accent-outgoing: #1e3a8a;
  
  --success-color: #10b981;
  --danger-color: #ef4444;
  --transition-speed: 0.25s;
}

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

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Utility classes */
.hidden {
  display: none !important;
}

/* Authentication Overlay */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #1e293b 0%, #090d16 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity var(--transition-speed);
}

.auth-card {
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 40px;
  width: 420px;
  text-align: center;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.logo-icon {
  font-size: 48px;
  color: var(--accent-color);
  margin-bottom: 20px;
  filter: drop-shadow(0 0 10px var(--accent-glow));
}

.auth-header h2 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 30px;
}

.auth-body input {
  width: 100%;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  text-align: center;
  letter-spacing: 4px;
  margin-bottom: 20px;
  transition: border var(--transition-speed);
}

.auth-body input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.auth-body button {
  width: 100%;
  padding: 14px;
  background: var(--accent-color);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-weight: 500;
  font-size: 16px;
  cursor: pointer;
  transition: background var(--transition-speed);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.auth-body button:hover {
  background: #2563eb;
}

.error-msg {
  color: var(--danger-color);
  font-size: 14px;
  margin-top: 15px;
}

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

/* Sidebar Styling */
.sidebar {
  width: 380px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.logo {
  display: flex;
  align-items: center;
  font-size: 20px;
  font-weight: 600;
  gap: 10px;
}

.logo i {
  color: var(--accent-color);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-speed), color var(--transition-speed);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

/* Controls */
.sidebar-controls {
  padding: 15px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
}

.search-box {
  position: relative;
  width: 100%;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 13px;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 10px 10px 10px 38px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.filter-box {
  position: relative;
}

.filter-box i {
  position: absolute;
  left: 12px;
  top: 13px;
  color: var(--text-muted);
}

.filter-box select {
  width: 100%;
  padding: 10px 10px 10px 38px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  appearance: none;
  cursor: pointer;
}

.filter-box select:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* Thread List */
.thread-list {
  flex: 1;
  overflow-y: auto;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 15px;
}

.empty-state i {
  font-size: 40px;
}

.thread-item {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background var(--transition-speed);
}

.thread-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.thread-item.active {
  background: rgba(59, 130, 246, 0.08);
  border-left: 3px solid var(--accent-color);
}

.thread-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.thread-sender {
  font-weight: 500;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.thread-time {
  font-size: 11px;
  color: var(--text-muted);
}

.thread-subject {
  font-size: 13px;
  color: var(--text-main);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.thread-subdomain {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 12px;
  font-weight: 500;
}

.status-badge.incoming {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.status-badge.replied {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

/* Message Pane Styling */
.message-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
}

.unselected-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  gap: 15px;
}

.unselected-pane i {
  font-size: 64px;
}

.unselected-pane h3 {
  color: #fff;
  font-weight: 500;
}

.unselected-pane p {
  max-width: 380px;
  font-size: 14px;
  line-height: 1.5;
}

/* Selected Pane Layout */
.selected-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.thread-header {
  padding: 20px 30px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-sidebar);
}

.thread-meta h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.thread-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.client-badge {
  color: #60a5fa;
}

.arrow-icon {
  color: var(--text-muted);
}

.subdomain-badge {
  color: #34d399;
}

/* Button variants */
.btn {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity var(--transition-speed);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  opacity: 0.9;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-primary {
  background: var(--accent-color);
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* Message History Scroll list */
.message-history {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Message bubble */
.message-item {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

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

.message-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.message-item.incoming .message-meta {
  justify-content: flex-start;
}

.message-item.outgoing .message-meta {
  justify-content: flex-end;
}

.message-bubble {
  padding: 18px 22px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  position: relative;
  word-wrap: break-word;
}

.message-item.incoming .message-bubble {
  background: var(--accent-incoming);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-top-left-radius: 4px;
}

.message-item.outgoing .message-bubble {
  background: var(--accent-outgoing);
  color: #fff;
  border-top-right-radius: 4px;
}

.message-body-html {
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
}

/* Reply Composer Styling */
.reply-composer {
  padding: 20px 30px 30px 30px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-color);
}

.composer-header {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.composer-body textarea {
  width: 100%;
  height: 120px;
  padding: 15px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  margin-bottom: 12px;
  transition: border-color var(--transition-speed);
}

.composer-body textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

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

.status-msg {
  font-size: 13px;
  font-weight: 500;
}

.status-msg.info {
  color: var(--accent-color);
}

.status-msg.success {
  color: var(--success-color);
}

.status-msg.error {
  color: var(--danger-color);
}

/* Navigation Tabs */
.nav-tabs {
  padding: 10px 20px;
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
}

.nav-tab-btn {
  flex: 1;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  transition: all var(--transition-speed);
}

.nav-tab-btn i {
  font-size: 16px;
}

.nav-tab-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

.nav-tab-btn.active {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--border-focus);
  color: #60a5fa;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.15);
}

/* Agents Pane */
.agents-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  overflow-y: auto;
  padding: 30px;
}

.agents-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.agents-header h2 {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(45deg, #60a5fa, #3b82f6, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
  text-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

.agents-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.agents-controls {
  display: flex;
  gap: 15px;
  width: 500px;
}

/* Stats Grid */
.agents-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: rgba(31, 41, 55, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #60a5fa;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.10);
}

.stat-card:nth-child(2) .stat-icon {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.stat-card:nth-child(3) .stat-icon {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* Divisions Grid */
.divisions-container {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.division-block {
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(5px);
  position: relative;
  overflow: hidden;
}

.division-block::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6, #10b981);
}

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

.division-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.division-title h3 {
  font-size: 18px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #fff;
}

.division-badge {
  font-size: 11px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #34d399;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.division-stats-small {
  font-size: 13px;
  color: var(--text-muted);
}

/* Grid of Units */
.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.unit-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-speed);
  text-align: center;
  position: relative;
}

.unit-card:hover {
  background: rgba(59, 130, 246, 0.05);
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.15);
}

.unit-icon {
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.unit-card:hover .unit-icon {
  color: #60a5fa;
}

.unit-name {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
}

.unit-rank {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 4px;
  border-radius: 3px;
}

/* Rank themes */
.unit-card[data-rank-type="commander"] .unit-rank {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.unit-card[data-rank-type="officer"] .unit-rank {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.2);
}
.unit-card[data-rank-type="sergeant"] .unit-rank {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.unit-card[data-rank-type="specialist"] .unit-rank {
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}
.unit-card[data-rank-type="agent"] .unit-rank {
  background: rgba(156, 163, 175, 0.1);
  color: #d1d5db;
  border: 1px solid rgba(156, 163, 175, 0.2);
}

.unit-card.active-threads {
  border-color: rgba(16, 185, 129, 0.2);
  background: rgba(16, 185, 129, 0.02);
}

.unit-card.active-threads::before {
  content: '';
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.unit-card.active-threads:hover {
  background: rgba(16, 185, 129, 0.05);
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.unit-card.active-threads .unit-icon {
  color: #34d399;
}

/* Tooltip for unit email */
.unit-card::after {
  content: attr(data-email);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  background: #090d16;
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: 4px;
  color: #fff;
  font-size: 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed);
  z-index: 10;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.unit-card:hover::after {
  opacity: 1;
}

/* Database Email Pane Styling */
.database-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  overflow-y: auto;
  padding: 40px;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.pane-header h2 {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(45deg, #60a5fa, #3b82f6, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
  text-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

.pane-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.db-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 25px;
}

.db-controls .search-box {
  width: 400px;
}

.db-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(17, 24, 39, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.db-table th {
  background: rgba(255, 255, 255, 0.02);
  padding: 16px 24px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.db-table td {
  padding: 18px 24px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.db-row:last-child td {
  border-bottom: none;
}

.db-row {
  transition: background var(--transition-speed);
}

.db-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.db-name-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.excel-icon {
  font-size: 18px;
  color: var(--success-color);
  filter: drop-shadow(0 0 5px rgba(16, 185, 129, 0.3));
}

.db-time-cell {
  color: var(--text-muted);
}

/* Action button variants */
.btn-secondary-icon {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.btn-secondary-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-rename, .btn-secondary-icon {
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.15);
  background: rgba(96, 165, 250, 0.03);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-speed);
  margin-right: 8px;
}

.btn-rename:hover {
  background: rgba(96, 165, 250, 0.1);
  border-color: #60a5fa;
  color: #fff;
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.15);
}

.btn-delete {
  color: var(--danger-color);
  border: 1px solid rgba(239, 68, 68, 0.15);
  background: rgba(239, 68, 68, 0.03);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.btn-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger-color);
  color: #fff;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
}

