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

:root {
  --primary: #00d084;
  --primary-dark: #00a366;
  --secondary: #1e293b;
  --secondary-light: #334155;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --border-color: #334155;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
}

html,
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
    'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-dark);
  color: var(--text-primary);
}

.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 2rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header-content {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--primary);
}

.header-right {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.version {
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: var(--border-color);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--success);
  border-radius: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status-dot.disconnected {
  background: var(--error);
  animation: none;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.status-text {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Main Content */
.main-content {
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}

/* Connection Controls */
.connection-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.connection-controls .btn {
  flex: 1;
  max-width: 300px;
  padding: 1rem;
  font-size: 1rem;
}

/* Metrics Section */
.metrics-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  transition: all 0.3s ease;
}

.metric-card:hover {
  border-color: var(--primary);
  background: rgba(0, 208, 132, 0.05);
}

.metric-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Grid Layout */
.grid-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

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

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 208, 132, 0.02);
}

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.card-content {
  padding: 1.5rem;
  flex: 1;
  overflow: auto;
  max-height: 600px;
}

.badge-info {
  background: var(--info);
  color: white;
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-weight: 500;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-field label {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.input-field {
  padding: 0.75rem 1rem;
  background: var(--secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all 0.3s ease;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(0, 208, 132, 0.05);
  box-shadow: 0 0 0 3px rgba(0, 208, 132, 0.1);
}

.form-field small {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 208, 132, 0.4);
}

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

.btn-success:hover:not(:disabled) {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

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

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-secondary {
  background: var(--secondary-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
  background: rgba(0, 208, 132, 0.05);
}

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

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0, 208, 132, 0.05);
}

.btn-lg {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  width: 100%;
  justify-content: center;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-small {
  padding: 0.5rem 0.875rem;
  font-size: 0.75rem;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* Response Container */
.response-container {
  background: var(--secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}

.response-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 208, 132, 0.05);
}

.response-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
}

.response-content {
  padding: 1rem;
  background: var(--secondary);
  color: var(--primary);
  font-size: 0.75rem;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  overflow-x: auto;
  line-height: 1.5;
}

.status-container {
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Live Events */
.live-events {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.event-item {
  display: flex;
  gap: 1rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.75rem;
  align-items: center;
}

.event-item.success {
  border-left-color: var(--success);
  background: rgba(16, 185, 129, 0.05);
}

.event-item.error {
  border-left-color: var(--error);
  background: rgba(239, 68, 68, 0.05);
}

.event-item.warning {
  border-left-color: var(--warning);
  background: rgba(245, 158, 11, 0.05);
}

.event-item.info {
  border-left-color: var(--info);
  background: rgba(59, 130, 246, 0.05);
}

.event-time {
  color: var(--text-secondary);
  min-width: 70px;
}

.event-type {
  font-weight: 600;
  min-width: 50px;
  padding: 0.25rem 0.5rem;
  background: var(--border-color);
  border-radius: 3px;
  text-transform: uppercase;
  font-size: 0.65rem;
}

.event-message {
  color: var(--text-primary);
  flex: 1;
  word-break: break-word;
}

/* Action Buttons */
.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.action-buttons .btn {
  justify-content: center;
}

.icon {
  font-size: 1rem;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.toast {
  background: var(--secondary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--info);
  border-radius: 6px;
  padding: 1rem 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
  min-width: 300px;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--error);
}

.toast.warning {
  border-left-color: var(--warning);
}

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

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

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

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

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 208, 132, 0.05);
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.modal-body {
  padding: 2rem;
}

.modal-instruction {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.qr-container {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
  padding: 2rem;
  background: white;
  border-radius: 8px;
}

.qr-image {
  max-width: 300px;
  width: 100%;
  height: auto;
}

.qr-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--text-secondary);
  text-align: center;
}

.qr-loading p {
  animation: spin 2s linear infinite;
}

.modal-steps {
  background: rgba(0, 208, 132, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
}

.modal-steps h4 {
  margin-top: 0;
  color: var(--primary);
  font-size: 0.875rem;
}

.modal-steps ol {
  padding-left: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0;
}

.modal-steps li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.modal-steps strong {
  color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
  .main-content {
    padding: 1rem;
  }

  .metrics-section {
    grid-template-columns: 1fr 1fr;
  }

  .header h1 {
    font-size: 1.25rem;
  }

  .card-content {
    max-height: 400px;
  }

  .connection-controls {
    flex-direction: column;
  }

  .connection-controls .btn {
    max-width: none;
  }

  .modal-content {
    max-width: 90%;
  }
}
