/* MyVideoWall Sender Styles */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --text-primary: #eaeaea;
  --text-secondary: #a0a0a0;
  --accent: #e94560;
  --success: #4ade80;
  --warning: #fbbf24;
  --error: #ef4444;
  --border-radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 30px;
}

header h1 {
  font-size: 2.5rem;
  color: var(--accent);
  margin-bottom: 5px;
}

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

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 1.2rem;
  margin-bottom: 15px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card h3 {
  font-size: 1rem;
  margin: 15px 0 10px;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1rem;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn.secondary {
  background: var(--bg-secondary);
  border: 1px solid var(--text-secondary);
}

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

.btn.success {
  background: var(--success);
  color: #000;
}

.btn.small {
  padding: 5px 12px;
  font-size: 0.85rem;
}

.btn.large {
  padding: 15px 40px;
  font-size: 1.1rem;
}

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

/* Input groups */
.input-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.input-group label {
  color: var(--text-secondary);
  min-width: 150px;
}

.input-group input {
  flex: 1;
  min-width: 150px;
  padding: 10px 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Command code */
code.command {
  display: block;
  background: var(--bg-secondary);
  padding: 12px 15px;
  border-radius: var(--border-radius);
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  margin: 10px 0;
  color: var(--success);
}

/* Pair code display */
.pair-code-display {
  display: flex;
  align-items: center;
  gap: 15px;
  justify-content: center;
  margin: 20px 0;
}

.pair-code-display span#pair-code {
  font-size: 3rem;
  font-weight: bold;
  letter-spacing: 8px;
  color: var(--accent);
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

.hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Status grid */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
}

.status-label {
  color: var(--text-secondary);
}

.status-value {
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
}

.status-value.connected {
  background: rgba(74, 222, 128, 0.2);
  color: var(--success);
}

.status-value.connecting {
  background: rgba(251, 191, 36, 0.2);
  color: var(--warning);
}

.status-value.disconnected {
  background: rgba(239, 68, 68, 0.2);
  color: var(--error);
}

/* Layout Selector */
.layout-selector {
  margin-bottom: 20px;
}

.layout-selector label {
  display: block;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.layout-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.layout-option {
  padding: 10px;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
  position: relative;
}

.layout-option svg {
  display: block;
}

.layout-option:hover {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
}

.layout-option.active {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.2);
}

/* Tooltip on hover */
.layout-option[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 0.75rem;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}

.layout-option[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}

.layout-option[data-tooltip]:hover::after,
.layout-option[data-tooltip]:hover::before {
  opacity: 1;
}

/* Grid Preview */
.grid-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  overflow: hidden;
  margin: 20px 0;
}

.grid-slot {
  position: absolute;
  background: rgba(0, 0, 0, 0.5);
  border: 2px dashed var(--text-secondary);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
}

.grid-slot:hover {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
}

.grid-slot.active {
  border-style: solid;
  border-color: var(--success);
}

.grid-slot.active:hover {
  border-color: var(--error);
}

.grid-slot .slot-number {
  font-size: 2rem;
  font-weight: bold;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.grid-slot .slot-status {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.grid-slot.active .slot-status {
  color: var(--success);
}

.grid-slot .slot-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
}

.grid-slot .slot-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.2s;
}

.grid-slot:hover .slot-overlay {
  opacity: 1;
}

/* Drag-and-drop styles */
.grid-slot.dragging {
  opacity: 0.4;
  border: 2px dashed #4CAF50 !important;
  cursor: grabbing;
}

.grid-slot.dragging .slot-overlay {
  opacity: 0;
}

.grid-slot.drag-over {
  border: 3px solid #2196F3 !important;
  background: rgba(33, 150, 243, 0.15);
  box-shadow: inset 0 0 20px rgba(33, 150, 243, 0.3);
}

.grid-slot.active {
  cursor: grab;
}

.grid-slot.active:active {
  cursor: grabbing;
}

/* Ghost preview element */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  opacity: 0.85;
  z-index: 1000;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transform: scale(0.85);
  border: 2px solid #4CAF50;
  overflow: hidden;
}

.drag-ghost .slot-overlay {
  display: none;
}

.slot-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.slot-action-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  transition: transform 0.15s, background-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-action-btn.crop-btn {
  background: rgba(255, 255, 255, 0.15);
}

.slot-action-btn.crop-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

.slot-action-btn.remove-btn {
  background: rgba(239, 68, 68, 0.3);
}

.slot-action-btn.remove-btn:hover {
  background: rgba(239, 68, 68, 0.5);
  transform: scale(1.1);
}

/* Streams List */
.streams-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stream-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px 15px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
}

.stream-card .stream-slot-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
}

.stream-card .stream-info {
  flex: 1;
}

.stream-card .stream-info .stream-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.stream-card .stream-info .stream-details {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stream-card .stream-status {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.stream-card .stream-status.streaming {
  background: rgba(74, 222, 128, 0.2);
  color: var(--success);
}

.stream-card .stream-status.waiting {
  background: rgba(251, 191, 36, 0.2);
  color: var(--warning);
}

/* Logs */
.logs {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 15px;
  max-height: 200px;
  overflow-y: auto;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 0.85rem;
}

.log-entry {
  margin-bottom: 5px;
  word-break: break-word;
}

.log-time {
  color: var(--text-secondary);
  margin-right: 8px;
}

.log-info {
  color: var(--text-primary);
}

.log-warn {
  color: var(--warning);
}

.log-error {
  color: var(--error);
}

/* Warning banner */
.warning {
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid var(--warning);
  color: var(--warning);
  padding: 15px;
  border-radius: var(--border-radius);
  margin-bottom: 20px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 25px;
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h3 {
  margin-bottom: 20px;
  color: var(--text-primary);
}

#modal-preview-container {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: var(--border-radius);
  overflow: hidden;
  margin-bottom: 15px;
}

#modal-preview-video {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
}

#modal-selection-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: crosshair;
}

#modal-selection-box {
  position: absolute;
  border: 2px dashed #fff;
  background: rgba(233, 69, 96, 0.2);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

#modal-selection-box.active {
  border-color: var(--accent);
  border-style: solid;
}

/* Magnifier */
#modal-magnifier {
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  overflow: hidden;
  pointer-events: none;
  z-index: 100;
  background: #000;
}

#magnifier-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.magnifier-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.magnifier-crosshair::before,
.magnifier-crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.8);
}

.magnifier-crosshair::before {
  /* Horizontal line */
  width: 20px;
  height: 2px;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

.magnifier-crosshair::after {
  /* Vertical line */
  width: 2px;
  height: 20px;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}

.modal-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 15px;
  margin-top: 15px;
}

.stream-info {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 10px 0;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

/* Saved Crops Container */
.saved-crops-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

#saved-crops-btn {
  min-width: 110px;
}

#saved-crops-btn.active {
  background: var(--accent);
  color: white;
}

.saved-crops-dropdown {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  border-radius: var(--border-radius);
  min-width: 320px;
  max-width: 400px;
  max-height: 360px;
  overflow-y: auto;
  z-index: 2001;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99, 102, 241, 0.3);
  /* Position will be set by JavaScript to appear above the button */
}

/* Arrow pointing down to button */
.saved-crops-dropdown::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--accent);
}

.saved-crops-header {
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.saved-crops-domain {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.9rem;
  gap: 10px;
  transition: background 0.15s;
}

.saved-crops-domain:hover {
  background: rgba(255, 255, 255, 0.03);
}

.saved-crops-domain:last-child {
  border-bottom: none;
}

.saved-crops-domain .nav-arrow {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.saved-crops-domain .nav-arrow:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.4);
  border-color: var(--accent);
  transform: scale(1.05);
}

.saved-crops-domain .nav-arrow:active:not(:disabled) {
  transform: scale(0.95);
}

.saved-crops-domain .nav-arrow:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.1);
}

.saved-crops-domain .domain-info {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 0 4px;
}

.saved-crops-domain .domain-name {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-crops-domain .crop-index {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 3px;
  letter-spacing: 0.5px;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

/* Source Picker Modal */
.source-picker-content {
  max-width: 500px;
}

.source-picker-options {
  margin-bottom: 20px;
}

.source-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 20px;
  font-size: 1rem;
  text-align: left;
}

.source-icon {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.recent-sources-section h4 {
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.recent-sources-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.recent-source-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.recent-source-item:hover {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
}

.recent-source-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.recent-source-info {
  flex: 1;
  min-width: 0;
}

.recent-source-url-display {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-source-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Capture loading overlay */
.capture-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.capture-loading-content {
  text-align: center;
  color: var(--text-primary);
}

.capture-loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--bg-card);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.capture-loading-content p {
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.capture-loading-hint {
  font-size: 0.9rem !important;
  color: var(--text-secondary);
}

/* Click to continue overlay */
.click-to-continue-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: pointer;
}

.click-to-continue-content {
  text-align: center;
  color: var(--text-primary);
}

.click-to-continue-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  animation: pulse 1.5s ease-in-out infinite;
}

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

.click-to-continue-title {
  font-size: 1.5rem;
  color: var(--text-primary);
}

.recent-source-name {
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-source-url {
  font-size: 0.8rem;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  display: block;
}

.recent-source-url:hover {
  text-decoration: underline;
}

.recent-source-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: right;
}

/* Save Source Modal */
.save-source-content {
  max-width: 450px;
}

.save-source-content .input-group {
  margin-bottom: 15px;
  flex-direction: column;
  align-items: stretch;
}

.save-source-content .input-group label {
  margin-bottom: 5px;
}

/* Manage Sources Modal */
.manage-sources-content {
  max-width: 600px;
}

.manage-sources-list {
  max-height: 400px;
  overflow-y: auto;
}

.manage-source-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  margin-bottom: 8px;
}

.manage-source-info {
  flex: 1;
  min-width: 0;
}

.manage-source-name {
  font-weight: 600;
  margin-bottom: 2px;
}

.manage-source-url {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.manage-source-url.no-url {
  font-style: italic;
  opacity: 0.6;
}

.manage-source-region {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.manage-source-actions {
  display: flex;
  gap: 8px;
}

.manage-source-actions .btn {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.empty-sources-message {
  text-align: center;
  padding: 30px;
  color: var(--text-secondary);
}

/* Quality Settings */
.slot-action-btn.quality-btn {
  background: rgba(255, 255, 255, 0.15);
}

.slot-action-btn.quality-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

/* Quality Badge - shows on hover in top-left */
.quality-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 10;
}

.grid-slot:hover .quality-badge {
  opacity: 1;
}

/* Quality Menu - centered over tile (appended to body with fixed positioning) */
.quality-menu {
  position: fixed;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  min-width: 240px;
  overflow: hidden;
}

.quality-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 600;
}

.quality-menu-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.quality-menu-close:hover {
  color: var(--text-primary);
}

.quality-menu-content {
  display: flex;
  gap: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.quality-menu-column {
  flex: 1;
  background: var(--bg-card);
  padding: 10px;
}

.quality-menu-column-title {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  padding: 0 5px;
}

.quality-option {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 4px;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.quality-option:last-child {
  margin-bottom: 0;
}

.quality-option:hover:not(.disabled) {
  border-color: var(--accent);
}

.quality-option.selected {
  background: rgba(233, 69, 96, 0.2);
  border-color: var(--accent);
}

.quality-option.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.quality-menu-footer {
  padding: 12px 15px;
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.quality-menu-apply {
  width: 100%;
  padding: 10px 20px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.quality-menu-apply:hover {
  opacity: 0.9;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 15px;
  }

  header h1 {
    font-size: 2rem;
  }

  .pair-code-display span#pair-code {
    font-size: 2rem;
    letter-spacing: 5px;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .input-group label {
    min-width: auto;
  }

  .layout-options {
    flex-direction: column;
  }

  .modal-content {
    padding: 15px;
  }

  .modal-controls,
  .modal-actions {
    flex-direction: column;
  }
}

/* ========== HDMI Capture Styles ========== */

/* Enhanced Source Picker Modal */
.source-picker-modal-enhanced .source-picker-content-enhanced {
  max-width: 520px;
  padding: 0;
  overflow: hidden;
}

.source-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.source-picker-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.source-picker-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.source-picker-close-btn:hover {
  color: var(--text-primary);
}

.source-picker-body {
  padding: 16px 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.source-picker-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Source Picker Sections */
.source-picker-section {
  margin-bottom: 20px;
}

.source-picker-section:last-child {
  margin-bottom: 0;
}

.source-picker-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding: 0 4px;
}

/* Source Items */
.source-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.source-item:last-child {
  margin-bottom: 0;
}

.source-item:hover {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.08);
}

.source-item-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  flex-shrink: 0;
}

.source-item-icon.browser-icon {
  background: rgba(99, 102, 241, 0.15);
}

.source-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.source-item-label {
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-item-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-item-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Source Type Badges */
.source-type-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.hdmi-type-badge {
  background: rgba(233, 69, 96, 0.2);
  color: var(--accent);
}

.camera-type-badge {
  background: rgba(74, 222, 128, 0.2);
  color: var(--success);
}

/* Permission Section */
.source-picker-permission {
  text-align: center;
  padding: 30px 20px;
}

.source-picker-permission .permission-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

.source-picker-permission h4 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.source-picker-permission p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Devices Loading/Empty States */
.devices-loading,
.devices-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.devices-loading .loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--bg-card);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.devices-empty .empty-icon {
  font-size: 1.5rem;
  opacity: 0.5;
}

/* HDMI Badge on Tiles */
.hdmi-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  color: white;
  z-index: 15;
  pointer-events: none;
}

.hdmi-badge.connected {
  background: rgba(0, 0, 0, 0.75);
}

.hdmi-badge.no-signal {
  background: rgba(239, 68, 68, 0.9);
  animation: badge-pulse 2s ease-in-out infinite;
}

.hdmi-badge.error {
  background: rgba(239, 68, 68, 0.9);
}

.hdmi-badge-icon {
  font-size: 0.9rem;
}

.hdmi-badge-label {
  font-weight: 600;
  letter-spacing: 0.5px;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* No Signal Overlay */
.no-signal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}

.no-signal-overlay .no-signal-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.6;
}

.no-signal-overlay .no-signal-text {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.no-signal-overlay .no-signal-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Error Display in Source Picker */
.source-picker-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.5);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
}

.source-picker-error .error-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.source-picker-error .error-message {
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 12px;
  white-space: pre-wrap;
}

.source-picker-error .error-retry-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.source-picker-error .error-retry-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Source Type Label in stream cards */
.source-type-label {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Refresh Button */
.source-picker-footer .refresh-btn {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.source-picker-footer .refresh-btn:hover {
  border-color: var(--accent);
}

.source-picker-footer .refresh-btn:disabled {
  opacity: 0.5;
}
