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

:root {
  --primary: #25D366;
  --primary-dark: #128C7E;
  --primary-light: #DCF8C6;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --success: #10b981;
  --purple: #8b5cf6;

  --bg-dark: #0a0a0a;
  --bg-card: #141414;
  --bg-hover: #1a1a1a;
  --bg-input: #1f1f1f;

  --border: #2a2a2a;
  --border-light: #333;

  --text: #ffffff;
  --text-secondary: #a0a0a0;
  --text-muted: #666;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);

  --transition: all 0.2s ease;
}

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

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

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

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.logo-icon svg {
  width: 24px;
  height: 24px;
}

.logo span {
  font-weight: 600;
  font-size: 18px;
}

.nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  margin-bottom: 4px;
}

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

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

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

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* System Status in Sidebar */
.system-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.connecting {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

.status-dot.disconnected {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Main Content */
.main {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  transition: margin-right 0.3s ease;
}

.main.panel-open {
  margin-right: 400px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-title h1 {
  font-size: 24px;
  font-weight: 600;
}

.header-title p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 2px;
}

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

/* Content */
.content {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

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

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

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

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

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.green {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.stat-icon.blue {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
}

.stat-icon.orange {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.stat-icon.purple {
  background: rgba(139, 92, 246, 0.1);
  color: var(--purple);
}

.stat-info {
  flex: 1;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  display: block;
}

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

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

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

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-header h4 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 16px;
  margin-bottom: 12px;
}

.card-header h4:first-child {
  margin-top: 0;
}

.card-body {
  padding: 20px;
}

/* Search Input */
.search-input {
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  width: 200px;
  transition: var(--transition);
}

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

.search-input::placeholder {
  color: var(--text-muted);
}

/* Select Input */
.select-input {
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.select-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

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

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

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

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  background: none;
  border: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Channels List */
.channels-list {
  max-height: 600px;
  overflow-y: auto;
}

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

.channels-empty svg,
.chats-empty svg {
  margin-bottom: 16px;
  opacity: 0.3;
}

.channels-empty .hint,
.chats-empty .hint {
  font-size: 13px;
  margin-top: 8px;
}

/* Channel Card */
.channel-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

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

.channel-card:last-child {
  border-bottom: none;
}

.channel-status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.channel-status-indicator.connected {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.channel-status-indicator.connecting {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

.channel-status-indicator.disconnected {
  background: var(--danger);
}

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

.channel-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.channel-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.channel-phone {
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
}

.channel-dept {
  padding: 2px 8px;
  background: var(--bg-input);
  border-radius: 10px;
  font-size: 11px;
}

.channel-stats-mini {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.channel-actions {
  flex-shrink: 0;
}

/* Detail Panel (slides from right) */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.detail-panel.open {
  transform: translateX(0);
}

.detail-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-hover);
}

.detail-panel-header h3 {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.detail-section {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.detail-section:last-child {
  border-bottom: none;
}

.detail-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* QR Container */
.qr-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.qr-placeholder {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

.qr-image {
  max-width: 200px;
  border-radius: var(--radius-sm);
  padding: 8px;
  background: white;
}

.qr-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Info List */
.info-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.info-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.info-label {
  color: var(--text-secondary);
  font-size: 14px;
}

.info-value {
  font-weight: 500;
  font-size: 14px;
}

.info-value.status-connected {
  color: var(--success);
}

.info-value.status-connecting,
.info-value.status-qr {
  color: var(--warning);
}

.info-value.status-disconnected {
  color: var(--danger);
}

/* Mini Stats */
.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.mini-stat {
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.mini-stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

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

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

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* Settings Grid */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* Analytics Grid */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.chart-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

/* Chats List */
.chats-list {
  max-height: 600px;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.chat-item:hover {
  background: var(--bg-hover);
}

.chat-item:last-child {
  border-bottom: none;
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}

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

.chat-name {
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-preview {
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.chat-channel-badge {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--bg-input);
  border-radius: 10px;
  color: var(--text-secondary);
}

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

.chat-unread {
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* API Docs */
.api-docs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-docs h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 20px;
  margin-bottom: 12px;
}

.api-docs h4:first-child {
  margin-top: 0;
}

.api-endpoint {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
}

.api-endpoint .method {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.api-endpoint .method.get {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.api-endpoint .method.post {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
}

.api-endpoint .method.delete {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.api-endpoint code {
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 13px;
  color: var(--primary);
}

.api-endpoint .desc {
  flex: 1;
  text-align: right;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 450px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal form {
  padding: 20px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

.toast-warning {
  border-left: 4px solid var(--warning);
}

.toast-info {
  border-left: 4px solid var(--info);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}

.toast-close:hover {
  color: var(--text);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* Responsive */
@media (max-width: 1400px) {
  .detail-panel {
    width: 350px;
  }
}

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .detail-panel {
    width: 100%;
    max-width: 400px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: var(--transition);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .header {
    padding: 16px 20px;
  }

  .content {
    padding: 16px 20px;
  }

  .header-title h1 {
    font-size: 20px;
  }

  .detail-panel {
    width: 100%;
    max-width: none;
  }
}

/* Webhook Styles */
.webhook-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.webhook-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

.webhook-indicator.enabled {
  background: var(--success);
}

.webhook-indicator.disabled {
  background: var(--text-muted);
}

.webhook-form .form-group {
  margin-bottom: 12px;
}

.webhook-form .form-group input {
  padding: 10px 12px;
  font-size: 13px;
}

.webhook-events {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
}

.checkbox-label:hover {
  background: var(--bg-card);
}

.checkbox-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.form-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

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

.btn-danger:hover {
  background: #c53030;
}

/* Settings Toggle */
.settings-toggle {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.toggle-text {
  font-size: 14px;
  color: var(--text);
}

/* Auth Method Tabs */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-hover);
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.auth-tab:first-child {
  border-right: 1px solid var(--border);
}

.auth-tab:hover {
  background: var(--bg-input);
  color: var(--text);
}

.auth-tab.active {
  background: var(--primary);
  color: white;
}

/* Auth Method Containers */
.auth-method {
  margin-bottom: 16px;
}

/* Phone Auth Form */
.phone-auth-form {
  padding: 16px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
}

.phone-auth-form .form-group {
  margin-bottom: 12px;
}

.phone-auth-form .form-group:last-child {
  margin-bottom: 0;
}

/* Pairing Code Display */
.pairing-code-display {
  padding: 20px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  text-align: center;
}

.pairing-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.pairing-code {
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--primary);
  padding: 16px 24px;
  background: var(--bg-card);
  border: 2px dashed var(--primary);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.pairing-instructions {
  text-align: left;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.pairing-instructions p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-left: 8px;
  border-left: 2px solid var(--primary);
}

.pairing-instructions p:last-child {
  margin-bottom: 0;
}

/* API Key Button */
.api-key-btn {
  width: 100%;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
}

/* API Key Modal */
#apiKeyModal .modal-content {
  max-width: 400px;
}

.api-key-form {
  padding: 20px;
}

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

.api-key-form .form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.error-message {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 16px;
  font-size: 14px;
}

.modal.show {
  display: flex;
}

/* Analytics Styles */
.analytics-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card-large {
  padding: 24px;
}

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

.stat-trend {
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
}

.stat-trend.up {
  color: var(--success);
}

.stat-trend.down {
  color: var(--danger);
}

.stat-trend.neutral {
  color: var(--text-muted);
}

.analytics-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.period-selector {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.period-btn {
  padding: 10px 20px;
  background: var(--bg-hover);
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border-right: 1px solid var(--border);
}

.period-btn:last-child {
  border-right: none;
}

.period-btn:hover {
  background: var(--bg-input);
  color: var(--text);
}

.period-btn.active {
  background: var(--primary);
  color: white;
}

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

.card-chart {
  grid-column: span 1;
}

.card-chart-small {
  grid-column: span 1;
}

.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

.chart-container-small {
  position: relative;
  height: 200px;
  width: 100%;
}

.chart-container canvas,
.chart-container-small canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Channels Analytics Table */
.channels-table-wrapper {
  overflow-x: auto;
}

.channels-table {
  width: 100%;
  border-collapse: collapse;
}

.channels-table th,
.channels-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.channels-table th {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-hover);
}

.channels-table tbody tr {
  transition: var(--transition);
}

.channels-table tbody tr:hover {
  background: var(--bg-hover);
}

.channels-table tbody tr:last-child td {
  border-bottom: none;
}

.channels-table .loading {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

.channel-analytics-name {
  font-weight: 500;
}

.channel-analytics-phone {
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

.activity-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.activity-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Responsive Analytics */
@media (max-width: 1400px) {
  .analytics-overview {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1200px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .card-chart,
  .card-chart-small {
    grid-column: span 1;
  }
}

@media (max-width: 768px) {
  .analytics-overview {
    grid-template-columns: 1fr;
  }

  .analytics-controls {
    flex-direction: column;
    gap: 16px;
  }

  .period-selector {
    width: 100%;
  }

  .period-btn {
    flex: 1;
    text-align: center;
  }
}

/* Documentation Section */
.docs-header {
  text-align: center;
  margin-bottom: 24px;
}

.docs-header h2 {
  font-size: 28px;
  margin-bottom: 8px;
  color: var(--text);
}

.docs-header p {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.docs-links {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.docs-info {
  font-size: 14px;
  line-height: 1.8;
}

.docs-info p {
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.docs-info pre {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  overflow-x: auto;
  margin-bottom: 12px;
}

.docs-info code {
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 13px;
  color: var(--primary);
}

.docs-examples {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.example-block {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.example-block h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 12px;
}

.example-block pre {
  background: transparent;
  margin: 0;
  padding: 0;
  overflow-x: auto;
}

.example-block code {
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

/* API Docs in Admin Panel */
.api-docs {
  font-size: 14px;
}

.api-section {
  margin-bottom: 24px;
}

.api-section h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--info);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  text-transform: capitalize;
}

.api-endpoint {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.api-endpoint:last-child {
  border-bottom: none;
}

.api-method {
  font-weight: 700;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  min-width: 60px;
  text-align: center;
  flex-shrink: 0;
}

.api-method.get { background: var(--success); color: #000; }
.api-method.post { background: var(--info); color: #fff; }
.api-method.put, .api-method.patch { background: var(--warning); color: #000; }
.api-method.delete { background: var(--danger); color: #fff; }

.api-path {
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 13px;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.api-desc {
  color: var(--text-secondary);
  font-size: 12px;
  flex: 1.5;
  min-width: 0;
}

/* Responsive docs */
@media (max-width: 768px) {
  .api-endpoint {
    flex-direction: column;
    gap: 6px;
  }
  
  .api-method {
    min-width: 50px;
  }
  
  .docs-links {
    flex-direction: column;
  }
}
