:root {
  --bg-color: #0b0f19;
  --bg-gradient: linear-gradient(135deg, #0b0f19 0%, #111827 100%);
  --card-bg: rgba(22, 28, 45, 0.45);
  --card-border: rgba(255, 255, 255, 0.06);
  --card-hover-border: rgba(255, 255, 255, 0.12);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --success-color: #10b981;
  --success-hover: #059669;
  --warning-color: #f59e0b;
  --warning-hover: #d97706;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --secondary-color: #4b5563;
  --secondary-hover: #374151;
  
  --font-family: 'Outfit', sans-serif;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  font-family: var(--font-family);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--card-border);
}

.app-header h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #ffffff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-disconnected {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}
.status-disconnected .status-dot {
  background: var(--danger-color);
  box-shadow: 0 0 10px var(--danger-color);
}

.status-connecting {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}
.status-connecting .status-dot {
  background: var(--primary-color);
  box-shadow: 0 0 10px var(--primary-color);
  animation: pulse 1.5s infinite;
}

.status-scan-qr {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: #fde047;
}
.status-scan-qr .status-dot {
  background: var(--warning-color);
  box-shadow: 0 0 10px var(--warning-color);
  animation: pulse 1.5s infinite;
}

.status-authenticating {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: #fde047;
}
.status-authenticating .status-dot {
  background: var(--warning-color);
  box-shadow: 0 0 10px var(--warning-color);
  animation: pulse 1.5s infinite;
}

.status-ready {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}
.status-ready .status-dot {
  background: var(--success-color);
  box-shadow: 0 0 10px var(--success-color);
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 2rem;
  align-items: start;
}

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

/* Glassmorphism Cards */
.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.75rem;
  margin-bottom: 2rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
}

.glass-card:hover {
  border-color: var(--card-hover-border);
}

.glass-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: #fff;
  border-left: 3px solid var(--primary-color);
  padding-left: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  color: #fff;
  text-decoration: none;
  outline: none;
}

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

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

.btn-success { background-color: var(--success-color); }
.btn-success:hover { background-color: var(--success-hover); }

.btn-secondary { background-color: var(--secondary-color); }
.btn-secondary:hover { background-color: var(--secondary-hover); }

.btn-block {
  display: flex;
  width: 100%;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.button-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Form Styling */
.tabs-header {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: rgba(17, 24, 39, 0.4);
  padding: 0.25rem;
  border-radius: 8px;
  border: 1px solid var(--card-border);
}

.tab-link {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.tab-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.03);
}

.tab-link.active {
  color: #fff;
  background: rgba(59, 130, 246, 0.25);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
}

.form-group-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.form-group-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.form-group input[type="text"],
.form-group select,
.form-group textarea {
  width: 100%;
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.form-group input[type="text"]:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.input-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* File Upload Drag & Drop Zone */
.file-drop-zone {
  position: relative;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  background: rgba(17, 24, 39, 0.4);
  cursor: pointer;
  transition: var(--transition);
}

.file-drop-zone:hover {
  border-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.05);
}

.file-drop-zone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-zone-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.upload-icon {
  font-size: 2rem;
}

.file-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* Connection Manager Specifics */
.connection-info {
  background: rgba(17, 24, 39, 0.6);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--card-border);
}

.connection-info p {
  font-size: 0.95rem;
}

.qr-container {
  margin-top: 1rem;
  text-align: center;
  border-top: 1px solid var(--card-border);
  padding-top: 1rem;
}

.qr-instruction {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.qr-wrapper {
  display: inline-block;
  background: #fff;
  padding: 0.75rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

.qr-wrapper img {
  display: block;
  width: 180px;
  height: 180px;
}

.status-message {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--success-color);
  font-weight: 500;
}

.hidden {
  display: none !important;
}

/* Right Column (Logs) Layout */
.logs-card {
  height: calc(100vh - 150px);
  min-height: 550px;
  display: flex;
  flex-direction: column;
}

.card-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.card-header-actions h2 {
  margin-bottom: 0;
}

.table-container {
  flex-grow: 1;
  overflow-y: auto;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.5);
}

.logs-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.logs-table th {
  background: rgba(17, 24, 39, 0.9);
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logs-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-primary);
  vertical-align: middle;
}

.logs-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
}

/* Table Badge Styling */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  cursor: help;
}

.badge-type {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.log-time {
  white-space: nowrap;
  color: var(--text-secondary);
}

.media-preview-info {
  display: flex;
  flex-direction: column;
}

.media-filename {
  font-weight: 500;
  color: #fff;
}

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

.message-preview {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toast System */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  border: 1px solid var(--card-border);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateY(0);
  opacity: 1;
}

.toast.hidden {
  opacity: 0;
  transform: translateY(1rem);
  pointer-events: none;
}

.toast-success {
  border-color: var(--success-color);
  background: rgba(16, 185, 129, 0.9);
}

.toast-error {
  border-color: var(--danger-color);
  background: rgba(239, 68, 68, 0.9);
}

/* Animations */
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

/* Recipient Type Selectors & Segmented Controls */
.recipient-type-selector {
  margin-bottom: 1.25rem;
}

.segmented-control {
  display: flex;
  background: rgba(17, 24, 39, 0.6);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
}

.segmented-control input[type="radio"] {
  display: none;
}

.segmented-control label {
  flex: 1;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 0;
}

.segmented-control label:hover {
  color: #fff;
}

.segmented-control input[type="radio"]:checked + label {
  color: #fff;
  background: rgba(59, 130, 246, 0.25);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
}

.label-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.label-with-action label {
  margin-bottom: 0;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-text:hover {
  color: var(--primary-hover);
  background: rgba(59, 130, 246, 0.1);
}

#text-group-custom,
#media-group-custom,
#config-group-custom {
  margin-top: 0.75rem;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2rem !important;
}

select option {
  background-color: #111827;
  color: var(--text-primary);
}

/* API Key Wrapper */
.api-key-wrapper input {
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  outline: none;
  width: 180px;
  transition: var(--transition);
}

.api-key-wrapper input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Navigation Tabs */
.app-nav {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0.5rem;
}

.nav-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.nav-tab.active {
  color: #fff;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

/* Dashboard View Switcher */
.dashboard-view.hidden {
  display: none !important;
}

.dashboard-view.active {
  display: block;
}

/* Custom Scrollbar for tables */
.table-container::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.table-container::-webkit-scrollbar-track {
  background: rgba(17, 24, 39, 0.3);
}

.table-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Delete button custom styling */
.btn-delete-agent {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: var(--transition);
}

.btn-delete-agent:hover {
  background: var(--danger-color);
  color: #fff;
  border-color: var(--danger-hover);
}



