/* Modern Dark Theme with Animated Gradients + Grain */
:root {
  /* Neon-ish dark gradients */
  --primary-gradient: linear-gradient(135deg, #6ee7ff 0%, #7c5cff 50%, #2f2bff 100%);
  --secondary-gradient: linear-gradient(135deg, #ff7ac6 0%, #ff4d6d 100%);
  --success-gradient: linear-gradient(135deg, #00e6a8 0%, #37ffcf 100%);
  --warning-gradient: linear-gradient(135deg, #ffb86b 0%, #ffd56b 100%);
  --danger-gradient: linear-gradient(135deg, #ff6b6b 0%, #ff3b3b 100%);

  /* Deep dark surfaces */
  --bg-primary: #0a0c12;
  --bg-secondary: #0f1422;
  --bg-tertiary: #121a2b;
  --bg-card: rgba(20, 26, 43, 0.7);
  --bg-hover: rgba(40, 48, 78, 0.6);

  --text-primary: #f7f8fd;
  --text-secondary: #b6bfd6;
  --text-muted: #7f8aa8;

  --border-color: rgba(114, 137, 218, 0.18);
  --border-hover: rgba(114, 137, 218, 0.35);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-md: 0 6px 16px rgba(0,0,0,0.35);
  --shadow-lg: 0 14px 34px rgba(0,0,0,0.45);
  --shadow-xl: 0 24px 60px rgba(0,0,0,0.55);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(120deg, #070a12, #0c1020, #070a12);
  background-size: 200% 200%;
  animation: gradientShift 22s ease-in-out infinite;
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Animated glow blobs */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(600px 600px at 15% 85%, rgba(108, 97, 255, 0.18), transparent 60%),
    radial-gradient(700px 700px at 85% 15%, rgba(255, 98, 174, 0.16), transparent 65%),
    radial-gradient(500px 500px at 60% 60%, rgba(0, 200, 255, 0.14), transparent 60%);
  filter: saturate(120%);
  animation: blobsMove 40s ease-in-out infinite;
  pointer-events: none;
  z-index: -2;
}

/* Film grain overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  animation: grainShift 1.8s steps(6) infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes blobsMove {
  0%, 100% { transform: translate3d(0,0,0) scale(1); }
  50% { transform: translate3d(0,-2%,0) scale(1.05); }
}

@keyframes grainShift {
  0% { transform: translate3d(0,0,0); }
  100% { transform: translate3d(-3%, 2%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
  body::before { animation: none; }
  body::after { animation: none; }
}

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 3rem;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(14px) saturate(120%);
  box-shadow: 0 10px 40px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.04);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

/* Forms */
.form-group { margin-bottom: 1.5rem; }
.form-label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
}
.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.3s ease;
}
.form-input:focus {
  outline: none;
  border-color: #7c5cff;
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.12);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.btn i { margin-right: 0.5rem; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1.125rem; }

.btn-primary { background: var(--primary-gradient); color: #fff; box-shadow: 0 8px 20px rgba(104,84,255,0.35); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(104,84,255,0.45); }
.btn-secondary { background: var(--secondary-gradient); color: #fff; }
.btn-success { background: var(--success-gradient); color: #fff; }
.btn-warning { background: var(--warning-gradient); color: #000; }
.btn-danger { background: var(--danger-gradient); color: #fff; }

/* Dashboard Layout */
.dashboard-container {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 280px;
  background: linear-gradient(180deg, rgba(18, 26, 43, 0.75) 0%, rgba(10, 12, 18, 0.75) 100%);
  border-right: 1px solid var(--border-color);
  padding: 2rem 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  backdrop-filter: blur(10px);
}

/* Sidebar Content */
.sidebar-header {
  padding: 0 1.5rem 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}
.sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.sidebar-nav { padding: 0 0.75rem; }
.nav-item { padding: 0.25rem 0.75rem; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease;
}
.nav-link i { width: 18px; text-align: center; }
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active { background: rgba(124, 92, 255, 0.15); color: #d2d0ff; border: 1px solid var(--border-hover); }

/* Main Content Layout */
.main-content {
  margin-left: 280px;
  padding: 2rem;
  width: calc(100% - 280px);
}

/* Top Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.header h1 {
  font-size: 1.6rem;
  margin: 0;
}
.header p { color: var(--text-muted); margin-top: 0.25rem; }
.user-menu { display: flex; align-items: center; gap: 1rem; }
.user-name { font-weight: 600; }
.user-role { color: var(--text-muted); font-size: 0.85rem; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* Titles */
.card-title { font-weight: 700; color: var(--text-primary); margin-bottom: 0.25rem; }
.card-subtitle { color: var(--text-muted); font-size: 0.9rem; }

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mb-2 { margin-bottom: 0.5rem; }
.fa-2x { font-size: 2em; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(12px) saturate(120%);
  box-shadow: var(--shadow-md);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-hover);
}

/* ... rest of the code remains the same ... */
.stat-number {
  margin-bottom: 0.5rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Tables */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

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

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

.table th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table td {
  color: var(--text-secondary);
}

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

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-ready {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-qr_ready {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-initializing {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-disconnected {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-auth_failed {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* QR Code Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-xl);
}

.modal-header {
  margin-bottom: 1.5rem;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.modal-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.qr-code {
  margin: 1.5rem 0;
  padding: 1rem;
  background: white;
  border-radius: 10px;
  display: inline-block;
}

.qr-code img {
  max-width: 200px;
  height: auto;
}

/* Forms */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border: 1px solid;
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #22c55e;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: #f59e0b;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  border-top-color: #667eea;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .table-container {
    overflow-x: auto;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

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

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

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

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

/* View-specific styles */
.content-header {
  margin-bottom: 2rem;
}

.content-header h2 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.content-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.content-actions {
  margin-bottom: 2rem;
}

/* Grid layouts for different views */
.webhooks-grid,
.messages-grid,
.logs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.webhook-account-card,
.message-account-card,
.log-account-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

.card-header h3 {
  color: var(--text-primary);
  margin: 0;
  font-size: 1.1rem;
}

.card-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Message and log items */
.message-list,
.log-list {
  max-height: 400px;
  overflow-y: auto;
}

.message-item,
.log-item {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border-color);
}

.message-header,
.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.message-direction,
.log-direction {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.message-direction.incoming,
.log-direction.incoming {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.message-direction.outgoing,
.log-direction.outgoing {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.message-direction.webhook,
.log-direction.webhook {
  background: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

.message-time,
.log-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.message-content,
.log-content {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.message-status,
.log-status {
  margin-top: 0.5rem;
}

.log-error {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 4px;
  color: #ef4444;
  font-size: 0.85rem;
}

/* Table styles for accounts view */
.table-container {
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

.data-table th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.data-table tr:hover {
  background: var(--bg-secondary);
}

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

/* Webhook secret styles */
.webhook-secret {
  margin: 0.5rem 0;
  font-size: 0.9rem;
}

.webhook-secret code {
  background: var(--bg-secondary);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  margin-right: 0.5rem;
}

.btn-xs {
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
}

/* Loading state */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  font-size: 16px;
  color: var(--text-secondary);
} 