:root {
  /* Color system */
  --bg-color: #080c14;
  --panel-bg: rgba(16, 22, 37, 0.7);
  --panel-border: rgba(255, 255, 255, 0.06);
  --panel-border-hover: rgba(139, 92, 246, 0.3);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --color-primary: #8b5cf6;
  --color-primary-rgb: 139, 92, 246;
  --color-secondary: #06b6d4;
  --color-secondary-rgb: 6, 182, 212;
  
  --color-success: #10b981;
  --color-success-glow: rgba(16, 185, 129, 0.2);
  --color-danger: #f43f5e;
  --color-danger-glow: rgba(244, 63, 94, 0.2);
  --color-info: #3b82f6;
  
  --font-sans: 'Outfit', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  
  --transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius: 16px;
}

/* Reset & Basics */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Mesh Background Gradient */
body::before {
  content: "";
  position: absolute;
  top: -20%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: radial-gradient(circle at 20% 20%, rgba(139, 92, 246, 0.12) 0%, transparent 40%),
              radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.12) 0%, transparent 45%),
              radial-gradient(circle at 50% 50%, rgba(8, 12, 20, 1) 0%, rgba(8, 12, 20, 0.8) 100%);
  z-index: -1;
  pointer-events: none;
}

/* Main Container */
.app-container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header */
.app-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding-bottom: 1.5rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-svg {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.4));
  transition: var(--transition-smooth);
}

.logo-area:hover .logo-svg {
  transform: rotate(15deg) scale(1.05);
}

.title-text h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, var(--text-primary) 30%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.2));
  color: #c084fc;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  border: 1px solid rgba(168, 85, 247, 0.2);
  margin-top: 0.2rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 300;
}

/* Alert Boxes */
.alert-box {
  display: flex;
  gap: 1rem;
  padding: 1.25rem;
  border-radius: var(--border-radius);
  background: rgba(16, 22, 37, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: var(--transition-smooth);
}

.alert-box.info {
  border-left: 4px solid var(--color-info);
}

.alert-box.warning {
  border-left: 4px solid #f59e0b;
  background: rgba(245, 158, 11, 0.05);
  border-color: #f59e0b;
}

.alert-box.success {
  border-left: 4px solid var(--color-success);
  background: rgba(16, 185, 129, 0.05);
  border-color: var(--color-success);
}

.alert-icon {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
}

.alert-content h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.alert-content p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 1.5rem;
}

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

/* Card Styling */
.card {
  position: relative;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.card:hover {
  border-color: var(--panel-border-hover);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 20px -5px rgba(139, 92, 246, 0.1);
}

.card-glow {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-primary), var(--color-secondary), transparent);
  opacity: 0;
  transition: var(--transition-smooth);
}

.card:hover .card-glow {
  opacity: 0.8;
}

.card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Scanner zone & Radar */
.scanner-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem 0;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius);
  border: 1px dashed rgba(255, 255, 255, 0.05);
  min-height: 240px;
}

.radar-container {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.radar-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  z-index: 5;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
  transition: var(--transition-smooth);
}

.radar-container.scanning .radar-icon {
  background: linear-gradient(135deg, var(--color-success), var(--color-secondary));
  box-shadow: 0 0 25px var(--color-success-glow);
}

.radar-icon svg {
  width: 32px;
  height: 32px;
}

/* Radar Ripples */
.ripple {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--color-primary);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

.radar-container.scanning .ripple {
  animation: radar-pulse 2.5s infinite linear;
  background: var(--color-success);
}

.r2 { animation-delay: 0.8s !important; }
.r3 { animation-delay: 1.6s !important; }

@keyframes radar-pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.8;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

.scanner-instruction {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 80%;
  font-weight: 400;
  transition: var(--transition-smooth);
}

.radar-container.scanning + .scanner-instruction {
  color: var(--color-success);
  font-weight: 500;
  animation: pulse-text 1.5s infinite ease-in-out;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Button systems */
.button-group {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.btn {
  width: 100%;
  padding: 0.9rem 1.5rem;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  box-shadow: 0 4px 15px var(--color-danger-glow);
}

.btn-danger:hover {
  transform: translateY(-2px);
  background: #e11d48;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

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

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

.hidden {
  display: none !important;
}

/* Result Display */
.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 240px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: var(--border-radius);
  border: 1px dashed rgba(255, 255, 255, 0.03);
  padding: 2rem;
  color: var(--text-muted);
}

.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.result-placeholder p {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.help-text {
  font-size: 0.8rem;
  max-width: 250px;
  line-height: 1.4;
}

/* Decoded payload output styling */
.result-display {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slide-up {
  from { transform: translateY(15px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.success-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #34d399;
  padding: 0.35rem 0.8rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.success-badge .dot {
  width: 8px;
  height: 8px;
  background-color: var(--color-success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--color-success);
  animation: blink-dot 1.5s infinite alternate;
}

@keyframes blink-dot {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.metadata-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.meta-item {
  background: rgba(0, 0, 0, 0.15);
  padding: 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.meta-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  font-weight: 600;
}

.meta-value {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 600;
}

.font-mono {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* Code block styles */
.code-block-wrapper {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.code-header {
  background: rgba(255, 255, 255, 0.02);
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.code-block-wrapper pre {
  padding: 1rem;
  overflow-x: auto;
  max-height: 180px;
}

.code-block-wrapper code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #34d399;
  white-space: pre-wrap;
  word-break: break-all;
}

/* History Section */
.history-card {
  gap: 1rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-actions {
  display: flex;
  gap: 0.5rem;
}

.table-container {
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.1);
}

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

.history-table th {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.history-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
}

.history-table tr:hover td {
  background: rgba(255, 255, 255, 0.01);
  color: var(--text-primary);
}

.empty-row td {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-muted);
  font-style: italic;
}

.history-payload-btn {
  color: var(--color-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline;
  font-size: 0.8rem;
}

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

/* Footer styling */
.app-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 1.5rem;
}

.compatibility-notice {
  background: rgba(255, 255, 255, 0.02);
  padding: 0.4rem 1rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

/* Scrollbar styles */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}
