/* ─── CSS Variables / Design Tokens ─────────────────────────────── */
:root {
  /* Primary palette */
  --primary-50: #eef2ff;
  --primary-100: #dceafc;
  --primary-200: #b9d5f9;
  --primary-300: #96c0f6;
  --primary-400: #74abf3;
  --primary-500: #0A81F5;
  --primary-600: #086bcc;
  --primary-700: #0655a3;
  --primary-800: #04407a;
  --primary-900: #022b52;

  /* Accent */
  --accent-400: #34d399;
  --accent-500: #10b981;
  --accent-600: #059669;

  /* Neutrals */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Functional */
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  /* Surfaces */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.9);

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  /* Borders */
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-light: rgba(0, 0, 0, 0.12);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 30px rgba(10, 129, 245, 0.2);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Font */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ─── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Background mesh gradient */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(10, 129, 245, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(8, 107, 204, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ─── App Layout ─────────────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.header__logo {
  width: 48px;
  height: 48px;
  background: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.header__logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header__title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-500);
}

.header__subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ─── Connection Status ──────────────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  margin-bottom: 32px;
  width: fit-content;
  transition: var(--transition-base);
}

.status-bar--connected {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.08);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-500);
  transition: var(--transition-base);
}

.status-dot--waiting {
  background: var(--warning);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot--connected {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.status-dot--error {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.status-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ─── Main Content Layout ────────────────────────────────────────── */
.main-content {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 32px;
  align-items: start;
}

@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

/* ─── Card Styles ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition-base);
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-lg);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.card__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card__badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-600);
  color: white;
}

.card__body {
  padding: 24px;
}

/* ─── Upload Zone ────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-base);
  position: relative;
  overflow: hidden;
}

.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(10, 129, 245, 0.06) 0%, transparent 70%);
  opacity: 0;
  transition: var(--transition-base);
}

.upload-zone:hover {
  border-color: var(--primary-400);
  background: rgba(10, 129, 245, 0.04);
}

.upload-zone:hover::before {
  opacity: 1;
}

.upload-zone--dragover {
  border-color: var(--primary-400);
  background: rgba(10, 129, 245, 0.08);
  transform: scale(1.01);
}

.upload-zone--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.upload-zone__icon {
  font-size: 3rem;
  margin-bottom: 16px;
  display: block;
  filter: grayscale(0.2);
}

.upload-zone__text {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.upload-zone__hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.upload-zone__input {
  display: none;
}

/* ─── File List ──────────────────────────────────────────────────── */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
  max-height: 500px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-700) transparent;
}

.file-list::-webkit-scrollbar {
  width: 6px;
}

.file-list::-webkit-scrollbar-track {
  background: transparent;
}

.file-list::-webkit-scrollbar-thumb {
  background: var(--gray-700);
  border-radius: 3px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  animation: slideIn 0.3s ease-out;
}

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

.file-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-light);
}

.file-item__icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 129, 245, 0.1);
  border-radius: var(--radius-sm);
}

.file-item__info {
  flex: 1;
  min-width: 0;
}

.file-item__name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item__size {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.file-item__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.file-item__progress {
  width: 100%;
  height: 4px;
  background: var(--gray-700);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.file-item__progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-500), var(--accent-400));
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

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

.btn--primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: white;
  box-shadow: 0 2px 8px rgba(10, 129, 245, 0.3);
}

.btn--primary:hover {
  background: linear-gradient(135deg, var(--primary-400), var(--primary-500));
  box-shadow: 0 4px 16px rgba(10, 129, 245, 0.4);
  transform: translateY(-1px);
}

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

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn--danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn--danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn--send {
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  color: white;
  padding: 8px 16px;
  font-size: 0.8rem;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn--send:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
}

.btn--send:disabled,
.btn--primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn--download {
  background: linear-gradient(135deg, var(--info), var(--primary-600));
  color: white;
  padding: 8px 16px;
  font-size: 0.8rem;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn--download:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
}

/* ─── QR Code Section ────────────────────────────────────────────── */
.qr-section {
  text-align: center;
}

.qr-section__label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-weight: 500;
}

.qr-section__canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: white;
  border-radius: var(--radius-lg);
  margin: 0 auto 16px;
  width: fit-content;
  box-shadow: var(--shadow-lg);
}

.qr-section__canvas canvas,
.qr-section__canvas img {
  display: block;
  max-width: 240px;
  height: auto;
}

.qr-section__pool-id {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'Courier New', monospace;
  padding: 8px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  display: inline-block;
  letter-spacing: 2px;
}

/* ─── Empty State ────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state__icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state__text {
  font-size: 0.9rem;
}

/* ─── Toast Notification ─────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease-out;
  max-width: 380px;
  font-size: 0.875rem;
  color: var(--text-primary);
}

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

.toast--error {
  border-left: 3px solid var(--danger);
}

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

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

/* ─── Mobile Specific ────────────────────────────────────────────── */
.scanner-section {
  text-align: center;
}

.scanner-section__video-container {
  position: relative;
  width: 280px;
  height: 280px;
  margin: 0 auto 20px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid var(--border-light);
}

.scanner-section__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-section__overlay {
  position: absolute;
  inset: 0;
  border: 3px solid var(--primary-400);
  border-radius: var(--radius-lg);
  pointer-events: none;
  animation: scanPulse 2s ease-in-out infinite;
}

@keyframes scanPulse {
  0%, 100% { border-color: var(--primary-400); }
  50% { border-color: var(--accent-400); }
}

.scanner-section__instruction {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Manual pool ID input */
.manual-input {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.manual-input__field {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition-fast);
  text-align: center;
  letter-spacing: 2px;
}

.manual-input__field::placeholder {
  letter-spacing: normal;
  color: var(--text-muted);
}

.manual-input__field:focus {
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(10, 129, 245, 0.15);
}

/* ─── Received Files (Mobile) ────────────────────────────────────── */
.received-files {
  margin-top: 32px;
}

.received-files__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.received-file-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: var(--transition-base);
  animation: slideIn 0.4s ease-out;
}

.received-file-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
}

.received-file-card__preview {
  width: 100%;
  height: 160px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.received-file-card__preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.received-file-card__preview-icon {
  font-size: 3rem;
  opacity: 0.6;
}

.received-file-card__info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.received-file-card__name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.received-file-card__size {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.received-file-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ─── Connected State Styles ─────────────────────────────────────── */
.connected-info {
  text-align: center;
  padding: 32px 24px;
}

.connected-info__icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.connected-info__title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--success);
  margin-bottom: 4px;
}

.connected-info__subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app {
    padding: 16px;
  }

  .header__title {
    font-size: 1.35rem;
  }

  .main-content {
    grid-template-columns: 1fr;
  }

  .upload-zone {
    padding: 32px 20px;
  }

  .received-files__grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Skeleton Loading ───────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-glass) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    var(--bg-glass) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ─── Divider ────────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}


/* ─── Footer ─────────────────────────────────────────────────────── */
.footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: center;
  align-items: center;
}

.footer__links {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer__link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: var(--transition-fast);
}

.footer__link:hover {
  color: var(--primary-500);
}

.footer__link svg {
  opacity: 0.7;
}

@media (max-width: 600px) {
  .footer__links {
    flex-direction: column;
    gap: 16px;
    align-items: center;
  }
}
