/* style.css */
/* Core Tokens and Design System */
:root {
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Color Palette */
  --bg-dark: #0a0c16;
  --card-bg: rgba(18, 22, 41, 0.65);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-hover: rgba(99, 102, 241, 0.3);
  
  --primary: #6366f1; /* Indigo */
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  
  --success: #10b981; /* Emerald */
  --success-glow: rgba(16, 185, 129, 0.15);
  
  --danger: #ef4444; /* Rose */
  --danger-hover: #dc2626;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Background Animated Glow Spheres */
.glow-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.glow-sphere {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.45;
}

.glow-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  top: -10%;
  right: 15%;
  animation: float-slow 20s infinite alternate;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
  bottom: 5%;
  left: -10%;
  animation: float-slow 25s infinite alternate-reverse;
}

@keyframes float-slow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(60px, 40px) scale(1.1); }
}

/* App Header */
.app-header {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px;
  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: 32px;
  height: 32px;
  color: var(--primary);
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 40%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  font-size: 11px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(99, 102, 241, 0.25);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Room Pill sharing */
.room-share-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.room-pill {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 6px 6px 14px;
  border-radius: 100px;
  gap: 10px;
  backdrop-filter: blur(10px);
  transition: var(--transition-smooth);
}

.room-pill:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.room-pill span {
  font-family: monospace;
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
}

.room-pill button {
  background: var(--primary);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.room-pill button:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.room-pill button svg {
  width: 14px;
  height: 14px;
}

/* App Main Content */
.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Glassmorphic Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Status Card styling */
.status-card {
  transition: var(--transition-smooth);
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.user-identity {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar-ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  padding: 2px;
}

.avatar-ring.pulsing {
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.avatar {
  background: #181d33;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

.peer-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.connection-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 12px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.connection-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.connection-indicator.online .dot {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: blink-soft 2s infinite alternate;
}

.connection-indicator.offline .dot {
  background-color: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.status-text {
  font-size: 13px;
  font-weight: 600;
}

@keyframes blink-soft {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

/* Peer Grid Section */
.peer-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title-bar h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.peer-count-badge {
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 20px;
}

.peer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  min-height: 200px;
}

/* Empty State */
.empty-peers-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
}

.empty-icon-container {
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: 50%;
  margin-bottom: 16px;
}

.empty-icon {
  width: 36px;
  height: 36px;
  color: var(--text-secondary);
}

.empty-peers-state h4 {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-peers-state p {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 400px;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Peer Item / Card */
.peer-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  position: relative;
  transition: var(--transition-smooth);
  cursor: pointer;
}

.peer-card:hover {
  border-color: var(--card-border-hover);
  transform: translateY(-4px);
  box-shadow: 0 12px 30px 0 rgba(99, 102, 241, 0.08);
}

.peer-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: white;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.3);
}

.peer-card.active .peer-avatar {
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.peer-name {
  font-size: 16px;
  font-weight: 600;
}

.peer-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: -10px;
}

/* Buttons */
.btn {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 20px var(--primary-glow);
}

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

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

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

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

.btn-wide {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* Modals & Popups styling */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(6, 8, 16, 0.8);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  max-width: 440px;
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  background: rgba(20, 24, 45, 0.95);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  padding: 28px;
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-backdrop.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-icon.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.modal-icon svg {
  width: 24px;
  height: 24px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-body p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.file-info-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
}

.file-icon {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-icon svg {
  width: 22px;
  height: 22px;
}

.file-details {
  flex: 1;
  overflow: hidden;
}

.file-details h4 {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.file-details p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}

.justify-center {
  justify-content: center;
}

/* Progress / Transfer Modal styling */
.transfer-card {
  text-align: center;
  max-width: 400px;
}

.transfer-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: -10px;
}

.progress-container {
  margin: 10px 0;
}

.linear-progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}

.linear-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #a78bfa 100%);
  border-radius: 10px;
  width: 0%;
  transition: width 0.1s linear;
}

.progress-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.percentage {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.metrics {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 10px;
  border-radius: 20px;
}

.transfer-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: left;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.toast {
  background: rgba(18, 22, 41, 0.9);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(20px);
  opacity: 0;
  animation: slide-up-fade 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-info {
  border-left: 4px solid var(--primary);
}

/* App Footer */
.app-footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.app-footer p {
  font-size: 12px;
  color: var(--text-muted);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .room-share-container {
    width: 100%;
    justify-content: space-between;
  }
  
  .room-pill {
    flex-grow: 1;
    justify-content: space-between;
  }
  
  .peer-grid {
    grid-template-columns: 1fr;
  }
}

/* iOS-style toggle switch */
.relay-toggle-container {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.08);
  transition: .3s;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: var(--primary);
  border-color: var(--primary);
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
}

/* QR Code & Transfer History Layouts */
.top-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
}

.qr-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
}

.qr-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.qr-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.qr-container {
  background: white;
  padding: 10px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  margin: 0 auto;
}

#qr-code-canvas {
  width: 130px;
  height: 130px;
  display: block;
}

.btn-muted-action {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
}

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

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Custom scrollbar for history list */
.history-list::-webkit-scrollbar {
  width: 6px;
}
.history-list::-webkit-scrollbar-track {
  background: transparent;
}
.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
.history-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.empty-history {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  transition: var(--transition-smooth);
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.history-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-icon-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.history-icon-badge.sent {
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
}

.history-icon-badge.received {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
}

.history-details h4 {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  color: var(--text-primary);
  word-break: break-all;
}

.history-details p {
  font-size: 11px;
  color: var(--text-secondary);
}

.history-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.history-status {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-status.completed {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.history-status.cancelled {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

@media (max-width: 768px) {
  .top-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}
