:root {
  --primary: #4361ee;
  --secondary: #3f37c9;
  --success: #4caf50;
  --text: #333;
  --light-bg: #f8f9fa;
  --border: #ddd;
  --accent: #6610f2;
  --danger: #e63946;
  --card-bg: #ffffff;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
  --transition: all 0.3s ease;
}

body {
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  margin: 0;
  padding: 0;
  color: var(--text);
  background-color: var(--light-bg);
  line-height: 1.6;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0.4rem;
}

h2 {
  color: var(--primary);
  margin-bottom: 1.5rem;
  text-align: center;
  font-weight: 600;
}

h3 {
  color: var(--secondary);
  margin-bottom: 1rem;
  font-weight: 500;
}

h4 {
  margin: 0;
  font-weight: 500;
  color: var(--secondary);
}

/* Card styling */
.card {
  background-color: var(--card-bg);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

/* Improved tab styling */
.tabs {
  display: flex;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  justify-content: center;
  position: relative;
  gap: 8px;
}

.tab {
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  border: none;
  background: transparent;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  position: relative;
  transition: var(--transition);
  border-radius: 8px 8px 0 0;
}

.tab.active {
  color: var(--primary);
  background: rgba(67, 97, 238, 0.05);
}

.tab.active:after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 3px;
  background-color: var(--primary);
  border-radius: 3px 3px 0 0;
}

.tab-content {
  display: none;
  padding: 1rem 0;
  margin-bottom: 0; /* Remove bottom margin */
}

.tab-content.active {
  display: block;
}

/* Enhanced file input styling - UPDATED */
.file-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin-bottom: 1rem;
  flex-wrap: nowrap;
}

.file-input-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: var(--secondary);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  text-align: center;
  flex: 0 0 auto;
  min-width: 100px;
  height: 18px;
  white-space: nowrap;
}

.file-input-label .icon {
  font-size: 1.2rem;
}

.file-input-label:hover {
  background-color: var(--accent);
  transform: translateY(-2px);
}

.selected-file-name {
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.3rem 0.5rem;
  background-color: rgba(67, 97, 238, 0.05);
  border-radius: 4px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-selected {
  font-weight: 500;
  color: var(--primary);
}

input[type="file"] {
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}

/* Enhanced button styling - UPDATED */
.action-button {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  border: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  min-width: 120px;
  text-align: center;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  font-size: 0.9rem;
}

.action-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.action-button:hover::before {
  transform: translateX(0);
}

.action-button:active {
  transform: translateY(1px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.full-width {
  width: 100%;
  display: block;
  max-width: none;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
}

.primary-button:hover {
  background: linear-gradient(135deg, var(--secondary), var(--accent));
  transform: translateY(-2px);
}

.secondary-button {
  background: linear-gradient(135deg, var(--success), #3d9640);
  color: white;
}

.secondary-button:hover {
  background: linear-gradient(135deg, #3d9640, #2e7230);
  transform: translateY(-2px);
}

.stop-button {
  background: linear-gradient(135deg, var(--danger), #d72638);
  color: white;
}

.stop-button:hover {
  background: linear-gradient(135deg, #d72638, #b01b2a);
}

.accent-button {
  background: linear-gradient(135deg, var(--accent), #5107c7);
  color: white;
}

.accent-button:hover {
  background: linear-gradient(135deg, #5107c7, #41059e);
  transform: translateY(-2px);
}

/* Button container for receiver actions - UPDATED */
.button-container {
  padding: 1rem;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

/* Button container for sender actions */
.sender-buttons {
  width: 100%;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.sender-buttons .action-button {
  flex: 1;
  min-width: 30%;
}

@media (max-width: 768px) {
  .sender-buttons {
    flex-direction: column;
  }
  
  .sender-buttons .action-button {
    width: 100%;
  }
}

/* Canvas and video styling */
.qr-display {
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.qr-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  aspect-ratio: 1/1;
  max-width: 100%;
  max-height: 70vh;
  margin: 0 auto;
}

canvas, video {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

#sendCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  box-shadow: 0 0 20px rgba(0,0,0,0.15);
}

/* Fullscreen QR Display */
.qr-display.fullscreen {
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: var(--light-bg);
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: calc(100vh - 150px);
}

.fullscreen-controls {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 101;
  background: var(--card-bg);
  padding: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  display: flex;
  justify-content: center;
}

.fullscreen-buttons {
  display: flex;
  gap: 6px;
  max-width: 800px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.fullscreen-buttons .action-button {
  flex: 1;
  min-width: 80px;
  max-width: 140px;
  height: 36px;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
}

/* Progress container */
.progress-container {
  padding: 1rem;
}

/* Progress bar styling */
#progressBarContainer {
  margin: 0.5rem auto;
  width: 100%;
  background: #eee;
  border-radius: 20px;
  overflow: hidden;
  height: 12px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

#progressBar {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(255,255,255,0.3) inset;
}

/* Chunk progress bar styling */
#chunkProgressBarContainer {
  margin: 0.5rem auto 1rem;
  width: 100%;
  background: #eee;
  border-radius: 20px;
  overflow: hidden;
  height: 12px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
  position: relative;
}

#chunkProgressBar {
  position: relative;
  height: 100%;
  width: 100%;
  border-radius: 20px;
  background-color: rgba(230, 57, 70, 0.6); /* Red background for not-yet-decoded chunks */
}

#chunkProgressOverlay {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%; /* Will be updated via JavaScript as chunks are decoded */
  border-radius: 20px;
  background: linear-gradient(90deg, #4caf50, #2e7d32); /* Green gradient for decoded chunks */
  transition: width 0.2s ease;
}

/* Chunk progress label */
.chunk-progress-label {
  font-size: 0.8rem;
  color: var(--text);
  margin-bottom: 0.2rem;
  display: flex;
  justify-content: space-between;
}

/* Results display */
#result {
  margin: 1rem auto;
  max-width: 100%;
}

#result pre, #fileContent pre {
  text-align: left;
  padding: 1rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap;
  overflow-x: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

#result iframe, #result img, #fileContent iframe, #fileContent img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

#result iframe, #fileContent iframe {
  min-height: 400px;
  width: 100%;
}

/* Status display */
.status {
  margin: 1rem 0;
  font-weight: 500;
  color: var(--primary);
  text-align: center;
  padding: 0.5rem;
  border-radius: 8px;
  background-color: rgba(67, 97, 238, 0.05);
}

/* Debug container */
.debug-container {
  margin-top: 1.5rem;
}

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

#debug {
  font-size: 12px;
  text-align: left;
  margin: 1rem auto;
  padding: 1rem;
  background: rgba(248, 249, 250, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Transfer statistics */
.transfer-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.5rem 0;
  width: 100%;
  font-size: 0.9rem;
  color: var(--secondary);
  padding: 0.5rem 0;
}

.speed-indicator {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  background-color: rgba(67, 97, 238, 0.15);
  font-weight: bold;
  color: var(--primary);
}

/* Advanced settings */
.advanced-settings {
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.setting-row {
  margin-bottom: 1.25rem;
  width: 100%;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-row label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--secondary);
}

.setting-row input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  appearance: none;
  background: #eee;
}

.setting-row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-wrapper input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

details summary {
  cursor: pointer;
  padding: 0.8rem;
  background-color: rgba(67, 97, 238, 0.05);
  border-radius: 8px;
  margin: 1rem 0;
  font-weight: 500;
  color: var(--secondary);
  position: relative;
  transition: var(--transition);
}

details summary:hover {
  background-color: rgba(67, 97, 238, 0.1);
}

details summary::marker {
  color: var(--primary);
}

/* Tooltip styling */
.tooltip {
  cursor: help;
  margin-left: 5px;
  position: relative;
  display: inline-block;
}

.tooltip:hover::after {
  content: attr(title);
  position: absolute;
  left: 50%;
  top: -40px;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Toggle switch for debug info */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  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: #ccc;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Send Text toggle and textarea */
.send-text-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
}

.send-text-toggle-label {
  font-weight: 500;
  color: var(--secondary);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#sendTextArea {
  display: block;
  width: 100%;
  min-height: 90px;
  max-height: 220px;
  resize: vertical;
  margin-bottom: 1rem;
  margin-top: 0.2rem;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.04);
  transition: border-color 0.2s;
  box-sizing: border-box;
}

#sendTextArea:focus {
  outline: none;
  border-color: var(--primary);
  background: #f4f8ff;
}

/* Responsive styles */
@media (max-width: 768px) {
  .container {
    padding: 0.75rem;
  }

  .tabs {
    gap: 0;
  }

  .tab {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    flex: 1;
    text-align: center;
  }

  canvas, video {
    max-height: 60vh;
    width: auto;
  }

  h2 {
    font-size: 1.4rem;
  }

  h3 {
    font-size: 1.2rem;
  }
  
  .button-row {
    flex-direction: column;
    align-items: center;
    width: 100%;
  }
  
  .action-button {
    width: 100%;
    max-width: 250px;
  }
  
  /* Keep file input row as row even on mobile */
  .file-input-row {
    flex-direction: row;
    align-items: center;
    overflow: hidden;
  }
  
  .file-input-label {
    flex: 0 0 auto;
    min-width: 80px;
  }
  
  .selected-file-name {
    flex: 1;
    min-width: 0;
  }
}

    .chunk-marker {
      position: absolute;
      width: 2px;
      height: 100%;
      background-color: #00ff00; /* Bright green for visibility */
      z-index: 10;
    }
    
    #chunkProgressBar {
      position: relative;
      overflow: visible; /* Allow markers to be visible outside the bar */
    }
    
    /* Share button styles */
    .header-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 15px;
    }
    
    .share-button {
      background-color: #4285f4;
      color: white;
      border: none;
      border-radius: 4px;
      padding: 6px 12px;
      display: flex;
      align-items: center;
      gap: 5px;
      cursor: pointer;
      font-size: 14px;
      transition: background-color 0.2s;
    }

    .share-button:hover {
      background-color: #3367d6;
    }

    /* Install button styles */
    .install-button {
      background-color: #4caf50;
      color: white;
      border: none;
      border-radius: 4px;
      padding: 6px 12px;
      display: flex;
      align-items: center;
      gap: 5px;
      cursor: pointer;
      font-size: 14px;
      margin-right: 8px;
      transition: background-color 0.2s;
    }

    .install-button:hover {
      background-color: #3d8b40;
    }
    
    /* Heart button styles */
    .heart-button {
      background-color: #ffb300;
      color: white;
      border: none;
      border-radius: 4px;
      padding: 6px 12px;
      display: flex;
      align-items: center;
      gap: 5px;
      cursor: pointer;
      font-size: 14px;
      margin-left: 8px;
      transition: background-color 0.2s;
      text-decoration: none;
    }
    .heart-button:hover {
      background-color: #ff9800;
      color: white;
      text-decoration: none;
    }
    
    /* Modal styles for fallback share */
    .share-modal {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(0, 0, 0, 0.5);
      display: flex;
      justify-content: center;
      align-items: center;
      z-index: 1000;
    }
    
    .modal-content {
      background-color: white;
      padding: 20px;
      border-radius: 8px;
      width: 90%;
      max-width: 400px;
    }
    
    .modal-header {
      font-weight: bold;
      font-size: 18px;
      margin-bottom: 10px;
    }
    
    .url-container {
      position: relative;
      margin: 15px 0;
    }
    
    .url-input {
      width: 100%;
      padding: 8px;
      padding-right: 60px;
      border: 1px solid #ccc;
      border-radius: 4px;
      background-color: #f5f5f5;
    }
    
    .copy-btn {
      position: absolute;
      right: 5px;
      top: 5px;
      background-color: #4285f4;
      color: white;
      border: none;
      border-radius: 4px;
      padding: 4px 8px;
      font-size: 12px;
      cursor: pointer;
    }
    
    .close-btn {
      width: 100%;
      background-color: #4caf50;
      color: white;
      border: none;
      border-radius: 4px;
      padding: 8px;
      margin-top: 10px;
      cursor: pointer;
    }
    
    /* Reduce spacing between tabs and content */
    .tabs {
      margin-bottom: 10px; /* Reduced from default */
    }
    
    .tab-content h3 {
      margin-top: 0; /* Remove top margin from h3 in tab content */
      margin-bottom: 10px; /* Add a small bottom margin */
    }
    
    /* Make the tabs stick closer to content */
    .tab-content {
      padding-top: 5px; /* Add small padding at top of content */
    }
    
    /* New styles for send mode toggle switch - updated to segmented control style */
    .send-mode-toggle {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      margin-bottom: 15px;
      border-radius: 8px;
      border: 1px solid #4285f4;
      overflow: hidden;
      width: fit-content;
      min-width: 200px;
    }
    
    .send-mode-label {
      padding: 8px 16px;
      font-size: 14px;
      color: #4285f4;
      transition: all 0.3s ease;
      cursor: pointer;
      text-align: center;
      flex: 1;
      background-color: white;
      margin: 0;
    }
    
    .send-mode-label.active {
      color: white;
      background-color: #4285f4;
    }
    
    /* Hide the default checkbox/toggle */
    .mode-switch {
      display: none;
    }
    
    #sendTextArea {
      width: 100%;
      min-height: 120px;
      border: 1px solid #ddd;
      border-radius: 4px;
      padding: 10px;
      font-family: inherit;
      margin-bottom: 15px;
      resize: vertical;
    }
    
    /* Hide the file input row by default */
    .file-input-row {
      display: none;
    }
    
    /* Show the file input row when in Send File mode */
    #sendModeToggle:not(:checked) + .file-input-row {
      display: flex;
    }
    
    /* Show the text area when in Send Text mode */
    #sendModeToggle:checked ~ #sendTextArea {
      display: block;
    }
    
    /* Limit max height for result and file content containers, show scrollbar if needed */
    #result, #fileContent {
      max-height: 300px;
      overflow: auto;
      scrollbar-width: thin;
      scrollbar-color: #4285f4 #e0e0e0;
    }
    #result::-webkit-scrollbar, #fileContent::-webkit-scrollbar {
      width: 8px;
      background: #e0e0e0;
    }
    #result::-webkit-scrollbar-thumb, #fileContent::-webkit-scrollbar-thumb {
      background: #4285f4;
      border-radius: 4px;
    }

    /* Footer styles */
    footer {
      text-align: center;
      margin-top: 1rem; /* Reduce this value */
      padding-bottom: 1rem; /* Adjust as needed */
      opacity: 0.85;
      font-size: 15px;
      color: #222;
      background: none;
    }
    
    footer div {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
    }
    
    footer a {
      color: #4285f4;
      text-decoration: underline;
      margin-left: 4px;
    }
    
    footer p {
      font-size: 13px;
      margin: 0.5em 0 0 0;
      opacity: 0.7;
    }
@media (max-width: 480px) {
  h2 {
    font-size: 1.3rem;
  }

  .tab {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
  
  .advanced-settings {
    padding: 1rem;
  }
  
  .card {
    padding: 0.75rem;
  }
}

/* Compact buttons for small screens */
@media (max-width: 480px) {
  .action-button {
    padding: 0.4rem 0.8rem;
    min-width: 100px;
    height: 36px;
    font-size: 0.85rem;
  }
  
  .fullscreen-buttons .action-button {
    min-width: 70px;
    max-width: 110px;
    height: 34px;
    font-size: 0.8rem;
    padding: 0.3rem 0.5rem;
  }
  
  .fullscreen-buttons {
    gap: 4px;
    padding: 0 4px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .file-input-label {
    min-width: 120px;
  }
}