@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap");

:root {
  /* Vibrant Color Palette */
  --primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --primary-solid: #667eea;
  --primary-dark: #5568d3;
  --accent: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --success: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --success-solid: #00f2fe;
  --danger: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --danger-solid: #fa709a;
  --warning: #fbc02d;

  /* Dark Theme */
  --bg-dark: #0f0f23;
  --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  --surface: rgba(255, 255, 255, 0.05);
  --surface-glass: rgba(255, 255, 255, 0.08);
  --surface-hover: rgba(255, 255, 255, 0.12);

  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.5);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(102, 126, 234, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--bg-dark);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
      circle at 20% 50%,
      rgba(102, 126, 234, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 80%,
      rgba(245, 87, 108, 0.1) 0%,
      transparent 50%
    );
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 1;
}

/* HEADER */
header {
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 20px 28px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

header h1 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #f093fb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* AUTH OVERLAY */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 15, 35, 0.95);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.login-overlay.hidden {
  display: none;
}

.login-box {
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 48px;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  width: 100%;
  max-width: 420px;
  animation: scaleIn 0.4s ease-out;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.login-box h2 {
  margin-bottom: 32px;
  font-size: 2rem;
  font-weight: 700;
  background: var(--primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-box input {
  width: 100%;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  margin-bottom: 20px;
  font-size: 16px;
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.login-box input:focus {
  outline: none;
  border-color: var(--primary-solid);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.login-box input::placeholder {
  color: var(--text-muted);
}

.login-box button {
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
}

.login-box button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.login-box button:active {
  transform: translateY(0);
}

.error-msg {
  color: var(--danger-solid);
  margin-top: 16px;
  font-size: 14px;
  display: none;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

/* MAIN APP */
.app-content {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 28px;
  animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1024px) {
  .app-content {
    grid-template-columns: 1fr;
  }
}

/* CARDS */
.card {
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow-md);
  margin-bottom: 28px;
  transition: all 0.3s ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-lg);
}

.card h2 {
  margin-top: 0;
  font-size: 1.4rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 16px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #667eea 0%, #f093fb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* SESSION LIST */
.session-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.session-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 4px;
  background: var(--primary);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.session-item:hover {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateX(4px);
}

.session-item:hover::before {
  transform: scaleY(1);
}

.session-item.selected {
  background: rgba(102, 126, 234, 0.15);
  border-color: var(--primary-solid);
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.2);
}

.session-item.selected::before {
  transform: scaleY(1);
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.session-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}

.session-status {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.session-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.status-logged {
  color: var(--success-solid);
}

.status-logged::before {
  background: var(--success-solid);
  box-shadow: 0 0 10px var(--success-solid);
}

.status-disconnected {
  color: var(--danger-solid);
}

.status-disconnected::before {
  background: var(--danger-solid);
}

.status-qrcode {
  color: var(--warning);
}

.status-qrcode::before {
  background: var(--warning);
}

/* SESSION ACTIONS */
.session-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.btn-delete {
  background: rgba(250, 112, 154, 0.1);
  border-color: rgba(250, 112, 154, 0.3);
  color: var(--danger-solid);
}

.btn-delete:hover {
  background: rgba(250, 112, 154, 0.2);
  border-color: var(--danger-solid);
}

/* NEW SESSION FORM */
.new-session-form {
  display: flex;
  gap: 12px;
}

.new-session-form input {
  flex: 1;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 15px;
  transition: all 0.3s ease;
}

.new-session-form input:focus {
  outline: none;
  border-color: var(--primary-solid);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.new-session-form input::placeholder {
  color: var(--text-muted);
}

/* BUTTONS */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

button {
  font-family: "Inter", sans-serif;
}

button[style*="transparent"] {
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: var(--text-primary) !important;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 500;
  transition: all 0.3s ease;
}

button[style*="transparent"]:hover {
  background: rgba(255, 255, 255, 0.15) !important;
  transform: translateY(-2px);
}

/* QR DISPLAY */
.qr-display {
  text-align: center;
  margin-bottom: 24px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 32px;
  position: relative;
  overflow: hidden;
}

.qr-display::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(102, 126, 234, 0.1) 0%,
    transparent 70%
  );
  animation: rotate 20s linear infinite;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.qr-display img {
  max-width: 280px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  background: white;
  padding: 16px;
}

.qr-display p {
  position: relative;
  z-index: 1;
}

#statusText {
  margin-top: 16px;
  font-weight: 600;
  font-size: 1.1rem;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* FORM GROUPS */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-solid);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.form-group input[type="file"] {
  padding: 12px;
  cursor: pointer;
}

/* ACTIONS GRID */
.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

@media (max-width: 768px) {
  .actions-grid {
    grid-template-columns: 1fr;
  }
}

.actions-grid > div {
  background: rgba(255, 255, 255, 0.03);
  padding: 24px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-block {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
}

/* BADGES */
.badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* HR */
hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 20px 0;
}

/* SCROLLBAR */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* TABS NAVIGATION */
.nav-tabs {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.tab-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--primary);
  border-color: transparent;
  color: white;
  box-shadow: var(--shadow-glow);
}

/* VIEWS PANEL */
.view-content {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.view-content.active {
  display: block;
}

/* LOGS VIEWER PANEL */
.logs-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 240px);
  min-height: 500px;
}

.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 16px;
}

.log-filters {
  display: flex;
  align-items: center;
  gap: 12px;
}

.log-console {
  flex: 1;
  background: #070a13;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 20px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-y: auto;
  color: #e2e8f0;
  box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 600px;
}

.log-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  padding-bottom: 4px;
}

.log-time {
  color: #64748b;
  flex-shrink: 0;
  user-select: none;
}

.log-session-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  flex-shrink: 0;
}

.log-level {
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
}

.level-info {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.level-success {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.level-warn {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.level-error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.log-msg {
  word-break: break-all;
}

/* TOAST NOTIFICATIONS */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 99999;
}

.toast {
  background: rgba(19, 26, 38, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 450px;
  animation: slideInRight 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transition: all 0.3s ease;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.toast-success {
  border-left: 4px solid #10b981;
}

.toast.toast-error {
  border-left: 4px solid #ef4444;
}

.toast.toast-warn {
  border-left: 4px solid #f59e0b;
}

.toast.toast-info {
  border-left: 4px solid #3b82f6;
}

.toast.hide {
  opacity: 0;
  transform: translateX(100px);
}

/* WEBHOOK TABLE */
.webhook-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
}

.webhook-table th, .webhook-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.webhook-table th {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
  font-size: 14px;
}

.webhook-table tbody tr:hover {
  background: var(--surface-hover);
}

.webhook-table td {
  font-size: 14px;
  color: var(--text-secondary);
}

.webhook-table td button {
  padding: 6px 12px !important;
  font-size: 13px !important;
}
