/* Base Reset and Colors */
:root {
  --bg-dark: #090a0f;
  --bg-card: rgba(18, 20, 29, 0.7);
  --border-light: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --color-primary: #0071e3; /* Premium Apple Blue */
  --color-primary-hover: #0077ed;
  --color-success: #10b981;
  --color-error: #ef4444;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* Background floating glow circles */
.background-decor {
  position: fixed;
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.4;
}

.circle-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #0071e3 0%, rgba(0,0,0,0) 70%);
  top: -10%;
  left: -10%;
  animation: float-slow 20s infinite alternate;
}

.circle-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #7928ca 0%, rgba(0,0,0,0) 70%);
  bottom: -15%;
  right: -10%;
  animation: float-slow 25s infinite alternate-reverse;
}

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

/* App Container */
.app-container {
  width: 100%;
  max-width: 900px;
  padding: 24px;
  z-index: 2;
}

/* Header */
.app-header {
  text-align: center;
  margin-bottom: 32px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.logo svg {
  width: 36px;
  height: 36px;
  color: var(--color-primary);
}

.logo h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

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

/* Glass Card */
.card-glass {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-light);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  padding: 40px;
  position: relative;
  overflow: hidden;
}

/* Views Management */
.view {
  transition: var(--transition-smooth);
}

.hidden {
  display: none !important;
}

/* --- SETUP VIEW / PAIRING STYLE --- */
.pairing-grid {
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  align-items: stretch;
}

.pairing-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.col-header {
  margin-bottom: 24px;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.badge-receive {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.badge-send {
  background-color: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
}

.badge-clipboard {
  background-color: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.pairing-col h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.pairing-col p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Divider */
.pairing-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.divider-line {
  flex-grow: 1;
  width: 1px;
  background: var(--border-light);
}

.divider-text {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 8px;
  border-radius: 50%;
  margin: 16px 0;
  border: 1px solid var(--border-light);
}

/* Buttons */
.btn {
  font-family: var(--font-sans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  width: 100%;
  border: none;
  outline: none;
  text-decoration: none;
}

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

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
}

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

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

.btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-smooth);
}

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

.btn-text svg {
  width: 16px;
  height: 16px;
}

/* Code Display Box */
.code-box {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.digits-container {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.digit-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  width: 20%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-success);
}

/* QR Code Container */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 16px;
  gap: 8px;
}

#qrcode {
  background: white;
  padding: 10px;
  border-radius: 12px;
}

#qrcode img {
  display: block;
  max-width: 120px;
}

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

/* Send Side Input Box */
.code-input-box {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-wrapper {
  position: relative;
}

#join-code-input {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  color: white;
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.2em;
  outline: none;
  transition: var(--transition-smooth);
}

#join-code-input:focus {
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.08);
}

#join-code-input::placeholder {
  letter-spacing: normal;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.3);
}

/* --- CONNECTED / TRANSFER SCREEN STYLE --- */
.transfer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.connection-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(16, 185, 129, 0.1);
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #34d399;
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: var(--color-success);
  border-radius: 50%;
}

.pulsing {
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 1.8s infinite;
}

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

/* Drag & Drop */
.transfer-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.85fr);
  gap: 20px;
  align-items: stretch;
}

.drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--color-primary);
  background: rgba(0, 113, 227, 0.05);
}

.drop-icon {
  margin-bottom: 16px;
  color: var(--color-primary);
}

.drop-icon svg {
  width: 48px;
  height: 48px;
}

.drop-zone h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.drop-zone p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.highlight {
  color: var(--color-primary);
  font-weight: 500;
}

.file-limits {
  display: block;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.25);
}

/* Universal Clipboard */
.clipboard-panel {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.clipboard-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.clipboard-panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.clipboard-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.clipboard-icon svg {
  width: 20px;
  height: 20px;
}

.clipboard-textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border-radius: 14px;
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.5;
  padding: 14px;
  outline: none;
  transition: var(--transition-smooth);
}

.clipboard-textarea:focus {
  border-color: rgba(168, 85, 247, 0.65);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.12);
}

.clipboard-textarea::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.clipboard-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
}

.clipboard-message-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 12px;
}

.clipboard-message-card.incoming {
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.06);
}

.clipboard-message-card.outgoing {
  border-color: rgba(0, 113, 227, 0.22);
  background: rgba(0, 113, 227, 0.055);
}

.clipboard-message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.clipboard-message-label {
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.clipboard-copy-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  border-radius: 9px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 6px 10px;
  transition: var(--transition-smooth);
}

.clipboard-copy-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.clipboard-message-text {
  color: var(--text-primary);
  font-size: 0.86rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Progress card */
.progress-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 20px;
  margin-top: 24px;
}

.progress-info {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.file-icon-placeholder {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-primary);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.progress-details {
  flex-grow: 1;
  min-width: 0;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-details h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.meta-row {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.speed-indicator {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-success);
}

.progress-bar-wrapper {
  background: rgba(255, 255, 255, 0.08);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar-fill {
  background-color: var(--color-primary);
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width 0.1s ease;
}

.progress-percentage {
  text-align: right;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Completed Card */
.completed-card {
  background: rgba(16, 185, 129, 0.04);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.success-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.success-icon {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.success-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

.completed-file-info {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 20px;
  width: 100%;
  max-width: 320px;
}

#completed-file-name {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#completed-file-size {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.action-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.action-buttons .btn {
  padding: 10px 16px;
  font-size: 0.85rem;
}

/* Toast Notifications */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  animation: slide-down 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-content {
  background: #1f1215;
  border: 1px solid #4a1921;
  color: #fca5a5;
  padding: 12px 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  font-size: 0.9rem;
  font-weight: 500;
}

.icon-error {
  width: 18px;
  height: 18px;
  color: var(--color-error);
}

@keyframes slide-down {
  0% { transform: translate(-50%, -20px); opacity: 0; }
  100% { transform: translate(-50%, 0); opacity: 1; }
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .card-glass {
    padding: 24px;
  }
  
  .pairing-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  
  .pairing-divider {
    flex-direction: row;
    margin: 12px 0;
  }
  
  .divider-line {
    height: 1px;
    width: 100%;
  }
  
  .divider-text {
    margin: 0 16px;
  }

  .transfer-tools {
    grid-template-columns: 1fr;
  }

  .drop-zone {
    padding: 32px 22px;
  }

  .action-buttons {
    flex-direction: column;
  }
}
