/* ===== Variables ===== */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a24;
  --bg-card-hover: #22222e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #6b6b7a;
  --accent-primary: #6366f1;
  --accent-secondary: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --get-color: #10b981;
  --post-color: #6366f1;
  --put-color: #f59e0b;
  --delete-color: #ef4444;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

code,
pre {
  font-family: "JetBrains Mono", "Fira Code", monospace;
}

/* ===== Layout ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== Header ===== */
.header {
  margin-bottom: 32px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-secondary)
  );
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--accent-glow);
}

.logo-icon svg {
  width: 28px;
  height: 28px;
  color: white;
}

.logo h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo .accent {
  color: var(--accent-primary);
}

.session-badge {
  padding: 4px 10px;
  background: var(--accent-primary);
  color: white;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.new-session-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.new-session-btn:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
}

.new-session-btn svg {
  width: 16px;
  height: 16px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-card);
  border-radius: 50px;
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 2s infinite;
}

.connection-status.connected .status-dot {
  background: var(--success);
  animation: none;
}

.connection-status.disconnected .status-dot {
  background: var(--error);
  animation: none;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.status-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===== Webhook URL Section ===== */
.webhook-url-section {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.url-display {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--bg-secondary);
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
}

.url-display code {
  flex: 1;
  font-size: 14px;
  color: var(--accent-secondary);
  word-break: break-all;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-secondary)
  );
  color: white;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.copy-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.copy-btn svg {
  width: 16px;
  height: 16px;
}

.url-hint {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Stats Section ===== */
.stats-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.stat-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
}

.stat-icon.get {
  background: var(--get-color);
}
.stat-icon.post {
  background: var(--post-color);
}
.stat-icon.other {
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-secondary)
  );
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Webhooks Section ===== */
.webhooks-section {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 24px;
  border: 1px solid var(--border-color);
}

.clear-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.clear-btn:hover {
  color: var(--error);
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

.clear-btn svg {
  width: 16px;
  height: 16px;
}

.webhooks-list {
  margin-top: 16px;
  max-height: 600px;
  overflow-y: auto;
}

/* ===== Empty State ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-icon {
  width: 80px;
  height: 80px;
  background: var(--bg-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.empty-icon svg {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== Webhook Item ===== */
.webhook-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius-sm);
  margin-bottom: 12px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.webhook-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

.webhook-method {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: white;
  min-width: 70px;
  text-align: center;
}

.webhook-method.get {
  background: var(--get-color);
}
.webhook-method.post {
  background: var(--post-color);
}
.webhook-method.put {
  background: var(--put-color);
}
.webhook-method.delete {
  background: var(--delete-color);
}
.webhook-method.patch {
  background: var(--warning);
}
.webhook-method.options {
  background: var(--text-muted);
}

.webhook-info {
  flex: 1;
  min-width: 0;
}

.webhook-path {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
  word-break: break-all;
}

.webhook-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.webhook-preview {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  max-height: 80px;
  overflow: hidden;
  word-break: break-all;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.modal.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.modal-close svg {
  width: 20px;
  height: 20px;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-section h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.detail-section pre {
  background: var(--bg-secondary);
  padding: 16px;
  border-radius: var(--border-radius-sm);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .container {
    padding: 8px;
  }

  /* Hide header, URL section, and stats on mobile */
  .header {
    margin-bottom: 8px;
  }

  .logo {
    display: flex;
  }

  .logo-icon,
  .logo h1 {
    display: none;
  }

  .session-badge {
    font-size: 10px;
    padding: 3px 8px;
  }

  .header-actions {
    gap: 8px;
  }

  .new-session-btn {
    display: none;
  }

  .connection-status {
    padding: 4px 10px;
    font-size: 11px;
  }

  .status-dot {
    width: 6px;
    height: 6px;
  }

  .status-text {
    font-size: 11px;
  }

  .webhook-url-section {
    display: none;
  }

  .stats-section {
    display: none;
  }

  /* Minimal webhooks section */
  .webhooks-section {
    padding: 8px;
    border-radius: 8px;
  }

  .section-header {
    margin-bottom: 8px;
  }

  .section-header h2 {
    font-size: 13px;
  }

  .clear-btn {
    padding: 4px 8px;
    font-size: 11px;
  }

  .clear-btn svg {
    width: 12px;
    height: 12px;
  }

  .webhooks-list {
    margin-top: 8px;
    max-height: calc(100vh - 100px);
  }

  /* Compact webhook items */
  .webhook-item {
    padding: 8px;
    margin-bottom: 6px;
    gap: 8px;
    flex-direction: row;
    align-items: center;
  }

  .webhook-method {
    padding: 3px 6px;
    font-size: 9px;
    min-width: 40px;
    border-radius: 4px;
  }

  .webhook-info {
    min-width: 0;
  }

  .webhook-path {
    font-size: 11px;
    margin-bottom: 2px;
  }

  .webhook-meta {
    font-size: 9px;
    gap: 8px;
  }

  .webhook-preview {
    margin-top: 6px;
    padding: 6px;
    font-size: 9px;
    max-height: 60px;
    line-height: 1.3;
  }

  /* Empty state compact */
  .empty-state {
    padding: 30px 10px;
  }

  .empty-icon {
    width: 50px;
    height: 50px;
    margin-bottom: 12px;
  }

  .empty-icon svg {
    width: 24px;
    height: 24px;
  }

  .empty-state h3 {
    font-size: 13px;
  }

  .empty-state p {
    font-size: 11px;
  }

  /* Modal compact */
  .modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .modal-header {
    padding: 12px 16px;
  }

  .modal-header h3 {
    font-size: 13px;
  }

  .modal-close {
    width: 28px;
    height: 28px;
  }

  .modal-close svg {
    width: 16px;
    height: 16px;
  }

  .modal-body {
    padding: 12px;
  }

  .detail-section {
    margin-bottom: 12px;
  }

  .detail-section h4 {
    font-size: 10px;
    margin-bottom: 4px;
  }

  .detail-section pre {
    padding: 8px;
    font-size: 10px;
    line-height: 1.4;
  }

  /* Scrollbar thinner on mobile */
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }
}
