@tailwind components;
@tailwind utilities;

html,
body {
  width: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  height: 100vh;
  color: white;
  background-color: #111;
  display: flex;
  flex-direction: column;
}

input {
  margin: auto;
  /* nice thing of auto margin if display:flex; it center both horizontal and vertical :) */
}

canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

#main-container {
  display: flex;
  flex: 1;
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* Updated Peer List Container Styles */
#peer-list-container {
  position: fixed;
  left: -400px;
  top: 0;
  height: 100%;
  width: 400px;
  background-color: #242526;
  color: white;
  transition: left 0.3s ease;
  z-index: 20;
  overflow-y: auto;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

#peer-list-container.visible {
  left: 0;
  visibility: visible;
}

/* Shared sidebar styles */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border-bottom: 1px solid #3a3b3c;
}

.sidebar-content {
  padding: 15px;
}

h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

h3 {
  margin: 20px 0 10px 0;
  font-size: 16px;
  font-weight: 500;
  color: #e4e6eb;
}

.close-button {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.search-container {
  margin-bottom: 15px;
}

.search-input {
  width: 100%;
  padding: 10px;
  border-radius: 5px;
  border: none;
  background-color: #3a3b3c;
  color: white;
  box-sizing: border-box;
}

.attendants-section {
  margin-top: 10px;
}

.peer-list {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0;
}

.peer-list ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

.peer-list li {
  margin-top: 10px;
  height: 40px;
  font-size: 16px;
  border-radius: 5px;
  overflow: hidden;
}

.peer_item{
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 5px;
  transition: background-color 0.2s;
}

.peer_item:hover {
  background-color: #3a3b3c;
}

.peer_item_icon {
  flex-shrink: 0;
}

.peer_item_text {
  flex-grow: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 10px;
}

#grid-container {
  /* Basic grid setup */
  display: grid;
  width: 100%;
  height: 100%;
  
  /* Default auto-fill grid that prevents horizontal overflow, acts as fallback */
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  grid-auto-rows: minmax(150px, 1fr); /* Default row sizing */
  
  /* Set reasonable gaps and padding */
  gap: 10px;
  padding: 16px;
  box-sizing: border-box;
  
  /* Ensure content is centered */
  justify-items: center;
  align-items: center;
  overflow: auto; /* Allow scrolling if content overflows, e.g. many participants on small screen */
}

.grid-item {
  /* Item sizing */
  width: 100%;
  height: 100%;
  min-height: 150px; /* Minimum height for a video item */
  
  /* Center content within grid item */
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden; /* Prevent content like oversized canvas from breaking layout */
  background-color: #2d2d2d; /* Slightly different background for items */
  border-radius: 8px;
}

/* --- Layouts for specific number of peers --- */

/* 1 peer: Full width/height for the single peer */
#grid-container[data-peers="1"] {
  grid-template-columns: 1fr;
  grid-auto-rows: minmax(150px, calc(100vh - 32px - 80px)); /* 100vh minus padding and approx host video height */
}

/* 2 peers: Two columns, one row */
#grid-container[data-peers="2"] {
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(150px, calc(100vh - 32px - 80px));
}

/* 3 peers: Pyramid style (2 top, 1 centered below) */
#grid-container[data-peers="3"] {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, minmax(150px, calc((100vh - 32px - 10px - 80px) / 2))); /* 2 rows */
  grid-template-areas: 
    "peer1 peer2"
    "peer3 peer3";
}
#grid-container[data-peers="3"] .grid-item:nth-child(1) { grid-area: peer1; }
#grid-container[data-peers="3"] .grid-item:nth-child(2) { grid-area: peer2; }
#grid-container[data-peers="3"] .grid-item:nth-child(3) { 
  grid-area: peer3;
  max-width: 75%; /* Make bottom item not stretch full width */
  justify-self: center;
}

/* 4 peers: 2x2 grid */
#grid-container[data-peers="4"] {
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(150px, calc((100vh - 32px - 10px - 80px) / 2)); /* 2 rows */
}

/* 5 peers: 2 columns, 3 rows (bottom right empty) */
#grid-container[data-peers="5"] {
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(150px, calc((100vh - 32px - 20px - 80px) / 3)); /* 3 rows */
}

/* 6 peers: 2x3 grid (full) */
#grid-container[data-peers="6"] {
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(150px, calc((100vh - 32px - 20px - 80px) / 3)); /* 3 rows */
}

/* 7 peers: 2 columns, 4 rows (bottom right empty) */
#grid-container[data-peers="7"] {
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(150px, calc((100vh - 32px - 30px - 80px) / 4)); /* 4 rows */
}

/* 8 peers: 2x4 grid (full) */
#grid-container[data-peers="8"] {
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(150px, calc((100vh - 32px - 30px - 80px) / 4)); /* 4 rows */
}

/* Desktop Grid for 9+ Peers: Maintain item height from 4-row layout, allow more columns based on width */
#grid-container[data-peers="9"],
#grid-container[data-peers^="1"],
#grid-container[data-peers="20"] /* Added to include 20 peers */ {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
  grid-auto-rows: minmax(150px, calc((100vh - 32px - 30px - 80px) / 4)); 
}

/* Mobile override: Single column, items take significant height */
@media (max-width: 600px) {
  #grid-container:not(.force-desktop-grid) {
    grid-template-columns: 1fr !important; /* Force single column */
    /* Simplified and more robust row height for default mobile stacking */
    grid-auto-rows: minmax(180px, auto) !important; 
    padding: 8px !important; /* Reduce padding on mobile */
    gap: 8px !important; /* Reduce gap on mobile */
  }

  /* Reset grid areas and specific placements for mobile to ensure stacking, unless desktop grid is forced */
  #grid-container[data-peers="3"]:not(.force-desktop-grid) {
    grid-template-areas: unset !important;
  }
  #grid-container[data-peers="3"]:not(.force-desktop-grid) .grid-item {
    grid-area: auto !important;
    max-width: 100% !important; /* Allow full width */
    justify-self: stretch !important;
  }

  /* For other specific peer counts, they will naturally fall into single column due to the above :not(.force-desktop-grid) rule */
  #grid-container[data-peers="1"]:not(.force-desktop-grid) .grid-item,
  #grid-container[data-peers="2"]:not(.force-desktop-grid) .grid-item,
  #grid-container[data-peers="4"]:not(.force-desktop-grid) .grid-item,
  #grid-container[data-peers="5"]:not(.force-desktop-grid) .grid-item,
  #grid-container[data-peers="6"]:not(.force-desktop-grid) .grid-item,
  #grid-container[data-peers="7"]:not(.force-desktop-grid) .grid-item,
  #grid-container[data-peers="8"]:not(.force-desktop-grid) .grid-item {
     max-width: 100% !important;
     height: auto !important; /* Let content or grid-auto-rows define height */
  }
  
  /* This rule is the fallback for .force-desktop-grid on mobile.
     It will apply to data-peers = 0, 1, 2 (stacking them) */
  #grid-container.force-desktop-grid {
    grid-template-columns: 1fr !important; /* Default to single column (stacking) for 0,1,2 peers */
    grid-auto-rows: minmax(180px, auto) !important;   
    padding: 8px !important;
    gap: 8px !important;
  }

  /* Specific 2-column layouts for .force-desktop-grid on mobile when peer count is 3+ */
  #grid-container.force-desktop-grid[data-peers="3"] { /* 4 attendees total */
    grid-template-columns: repeat(2, 1fr) !important;
    /* Re-apply row calculation from desktop pyramid rule, ensuring high precedence */
    grid-template-rows: repeat(2, minmax(150px, calc((100vh - 32px - 10px - 80px) / 2))) !important;
    /* Ensure grid-areas are active for pyramid if they were unset by :not selector */
    grid-template-areas: 
      "peer1 peer2"
      "peer3 peer3" !important;
  }
  
  #grid-container.force-desktop-grid[data-peers="4"] {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-auto-rows: minmax(150px, calc((100vh - 32px - 10px - 80px) / 2)) !important;
  }
  
  #grid-container.force-desktop-grid[data-peers="5"] {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-auto-rows: minmax(150px, calc((100vh - 32px - 20px - 80px) / 3)) !important;
  }
  
  /* Add specific 2-column rules for data-peers=6,7,8 in forced mobile mode */
  #grid-container.force-desktop-grid[data-peers="6"] {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-auto-rows: minmax(150px, calc((100vh - 32px - 20px - 80px) / 3)) !important; /* Consistent with 2x3 desktop row height */
  }

  #grid-container.force-desktop-grid[data-peers="7"] {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-auto-rows: minmax(150px, calc((100vh - 32px - 30px - 80px) / 4)) !important; /* Consistent with 2x4 desktop row height */
  }

  #grid-container.force-desktop-grid[data-peers="8"] {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-auto-rows: minmax(150px, calc((100vh - 32px - 30px - 80px) / 4)) !important; /* Consistent with 2x4 desktop row height */
  }
  
  /* Specific override for data-peers=9+ in forced mobile mode to ensure 2 columns and consistent row height */
  #grid-container.force-desktop-grid[data-peers="9"],
  #grid-container.force-desktop-grid[data-peers^="1"],
  #grid-container.force-desktop-grid[data-peers="20"] /* Added to include 20 peers */ {
    grid-template-columns: repeat(2, 1fr) !important; /* Explicitly 2 columns */
    grid-auto-rows: minmax(150px, calc((100vh - 32px - 30px - 80px) / 4)) !important; /* Row height from 8-peer layout */
  }
  
  .host { /* Make host video smaller and ensure it doesn't overlap too much on mobile */
    width: 25% !important;
    max-width: 120px !important; 
    bottom: 78px !important; /* Adjust position from bottom - increased from 8px */
    right: 8px !important; /* Adjust position from right */
  }

  /* Hide the top bar on mobile screens */
  .top-bar {
    display: none !important;
  }

  /* Mobile Modal Styles for Sidebars */
  /* Peer List Modal */
  #peer-list-container {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: #242526 !important;
    color: white !important;
    transition: transform 0.3s ease !important;
    z-index: 1000 !important;
    overflow-y: auto !important;
    transform: translateX(-100%) !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  #peer-list-container.visible {
    transform: translateX(0) !important;
    visibility: visible !important;
  }

  /* Diagnostics Modal */
  #diagnostics-sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: #242526 !important;
    color: white !important;
    transition: transform 0.3s ease !important;
    z-index: 1000 !important;
    overflow-y: auto !important;
    transform: translateX(100%) !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  #diagnostics-sidebar.visible {
    transform: translateX(0) !important;
    visibility: visible !important;
  }

  /* Make headers more prominent on mobile */
  #peer-list-container .sidebar-header,
  #diagnostics-sidebar .sidebar-header {
    padding: 20px !important;
    background-color: #18191a !important;
    border-bottom: 2px solid #3a3b3c !important;
  }

  #peer-list-container .sidebar-header h2,
  #diagnostics-sidebar .sidebar-header h2 {
    font-size: 20px !important;
    font-weight: 600 !important;
  }

  /* Larger close button for mobile */
  #peer-list-container .close-button,
  #diagnostics-sidebar .close-button {
    font-size: 28px !important;
    padding: 5px 10px !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Better content spacing for mobile */
  #peer-list-container .sidebar-content,
  #diagnostics-sidebar .sidebar-content {
    padding: 20px !important;
  }

  /* Improve peer list items for mobile */
  .peer_item {
    padding: 15px !important;
    margin-bottom: 8px !important;
    border-radius: 8px !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
  }

  .peer_item_text {
    font-size: 16px !important;
    padding: 0 15px !important;
  }

  /* Better diagnostics display on mobile */
  #diagnostics-sidebar .diagnostics-section {
    margin-bottom: 25px !important;
    padding: 15px !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-radius: 8px !important;
  }

  #diagnostics-sidebar .diagnostics-data pre {
    font-size: 12px !important;
    padding: 15px !important;
    max-height: 30vh !important;
  }
}


.canvas-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Host camera frame rendered in the bottom right corner */
.host {
  position: absolute;
  bottom: 16px; /* Default spacing from bottom */
  right: 16px; /* Default spacing from right */
  width: 20%; /* Default width */
  max-width: 240px; /* Max width to prevent it from being too large on wide screens */
  min-width: 150px; /* Min width to ensure it's usable, increased to accommodate selectors */
  /* height: auto; */ /* Let content dictate height with flex */
  /* aspect-ratio: 16/9; */ /* Aspect ratio might be tricky with added selectors, manage via video element */
  border: 2px solid #444;
  border-radius: 8px;
  /* overflow: hidden; */ /* Remove to prevent clipping, flexbox will manage layout */
  z-index: 10; /* Make sure it's above the grid items if any overlap occurs */
  background-color: #1c1c1c; /* Slightly different background for the host box */
  display: flex; /* ADDED for layout */
  flex-direction: column; /* ADDED: Stack video and selectors vertically */
}

.host canvas, /* Target canvas if used directly by video encoder */
.host .self-camera { /* Target video element */
  width: 100%;
  /* height: 100%; */ /* Let flexbox determine height or set specific flex properties */
  object-fit: contain; /* Contain to ensure full video is visible */
  flex-grow: 1; /* ADDED: Allow video to take up available space */
  min-height: 0; /* ADDED: Important for flex item shrinking */
  background-color: #000; /* Background for video area */
  border-radius: 6px 6px 0 0; /* Rounded top corners if selectors are below */
}

.hidden {
  display: none;
}

.self-camera {
  width: 100%;
  height: 100%;
}

.floating-name {
  position: absolute;
  bottom: 0;
  right: 0;
  margin-bottom: 0;
  background-color: black;
  color: white;
}

.controls {
  top: 0;
  left: 0;
  margin-top: 0;
  margin-left: 0;
  /* ADDED: Ensure controls (if this refers to device selectors) are styled */
  /* This class seems generic, the more specific .device-selector-wrapper is better */
}

.device-selector {
  width: calc(100% - 10px); /* Take most of the wrapper width */
  margin: 3px 5px; /* Add some margin */
  padding: 4px;
  border-radius: 3px;
  border: 1px solid #555;
  background-color: white; /* Ensure select is visible */
  color: black; /* Text color for select options */
}

.device-selector-wrapper {
  /* margin-bottom: 20px; */ /* Original, might not be needed with flex */
  padding: 8px 5px 5px 5px; /* Add padding */
  background-color: rgba(30, 30, 30, 0.85); /* Darker, slightly transparent background for the selectors area */
  flex-shrink: 0; /* ADDED: Prevent this container from shrinking */
  border-top: 1px solid #444; /* Separator line if video is above */
  border-radius: 0 0 6px 6px; /* Rounded bottom corners */
}

.device-selector-wrapper label {
  color: #e0e0e0; /* Light color for labels */
  font-size: 0.9em;
  margin: 0 5px 2px 5px;
  display: block; /* Make labels take full width for better spacing */
}

:disabled {
  cursor: default;
  background-color: dimgrey !important;
  color: linen !important;
  opacity: 1 !important;
}

select {
  color: black;
}

.top-bar {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  background-color: black;
  color: white;
  padding: 8px;
}

.video-placeholder {
  width: 100%;
  height: 100%;
  background-color: #242526;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.placeholder-content svg {
  width: 64px;
  height: 64px;
  fill: #8a8d91;
}

.placeholder-text {
  color: #8a8d91;
  font-size: 1.1rem;
  font-weight: 500;
}

.pin-icon {
  visibility: hidden;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2em;
  opacity: 0.6;
  background-color: black;
  border-radius: 50%;
  padding: 10px;
  text-align: center;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.grid-item:hover .pin-icon {
  visibility: visible;
}

.audio-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.audio-indicator svg {
  width: 20px;
  height: 20px;
  stroke: white;
}

/* Diagnostics styling */
.diagnostics-container {
  position: fixed;
  bottom: 10px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  color: #00ff00;
  padding: 10px;
  border-radius: 5px;
  font-family: monospace;
  max-width: 300px;
  max-height: 200px;
  overflow: auto;
  z-index: 1000;
}

.diagnostics-data {
  margin: 0;
  font-size: 12px;
  white-space: pre-wrap;
}

/* Diagnostics Sidebar */
#diagnostics-sidebar {
  position: fixed;
  right: -400px;
  top: 0;
  height: 100%;
  width: 400px;
  background-color: #242526;
  color: white;
  transition: right 0.3s ease;
  z-index: 20;
  overflow-y: auto;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
}

#diagnostics-sidebar.visible {
  right: 0;
  visibility: visible;
}

/* Diagnostics specific styles */
#diagnostics-sidebar .diagnostics-data {
  padding: 10px;
}

#diagnostics-sidebar .diagnostics-section {
  margin-bottom: 20px;
}

#diagnostics-sidebar .diagnostics-section h3 {
  color: #fff;
  font-size: 16px;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#diagnostics-sidebar .diagnostics-data pre {
  font-family: monospace;
  font-size: 14px;
  white-space: pre-wrap;
  color: #00ff00;
  background-color: rgba(0, 0, 0, 0.3);
  padding: 10px;
  border-radius: 5px;
  max-height: 40vh;
  overflow-y: auto;
  margin: 0;
}

#diagnostics-sidebar .diagnostics-empty {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
  color: #999;
  font-style: italic;
}

/* Sidebar Header */
#diagnostics-sidebar .sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background-color: #18191a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#diagnostics-sidebar .sidebar-header h2 {
  margin: 0;
  font-size: 18px;
  color: #fff;
}

#diagnostics-sidebar .close-button {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 0 5px;
}

#diagnostics-sidebar .close-button:hover {
  color: #ff4444;
}

#diagnostics-sidebar .sidebar-content {
  padding: 15px;
}

.diagnostics-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: 300px;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
    overflow-y: auto;
}

.diagnostics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 10px;
}

.diagnostics-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.close-button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.close-button:hover {
    color: #ff4444;
}

.diagnostics-data {
    max-height: 80vh;
    overflow-y: auto;
}

.diagnostics-section {
    margin-bottom: 20px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

.diagnostics-section h3 {
    margin: 0 0 10px 0;
    font-size: 1.2em;
    color: #4CAF50;
    border-bottom: 1px solid #4CAF50;
    padding-bottom: 5px;
}

.diagnostics-text {
    font-family: monospace;
    white-space: pre-wrap;
    margin: 0;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    font-size: 0.9em;
}

.diagnostics-section p {
    color: #888;
    font-style: italic;
    margin: 10px 0;
    text-align: center;
}

.grid-item-pinned {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  background-color: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-item-pinned .canvas-container {
  width: min(100%, calc(100vh * 16/9));
  height: min(100%, calc(100vw * 9/16));
}

.pin-icon {
  visibility: hidden;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2em;
  opacity: 0.6;
  background-color: black;
  border-radius: 50%;
  padding: 10px;
  text-align: center;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.grid-item:hover .pin-icon {
  visibility: visible;
}

/* Style for the simulation info message */
.simulation-info-message {
  color: #ffcc00; /* A warning-like yellow color */
  text-align: center;
  margin-top: 10px;
  font-size: 0.9em;
}

/* Device Settings Menu Button */
.device-settings-menu-button {
  visibility: hidden;
  position: absolute;
  bottom: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  background-color: rgba(0, 0, 0, 0.7);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  transition: background-color 0.3s ease;
}

.device-settings-menu-button:hover {
  background-color: rgba(0, 0, 0, 0.9);
}

.device-settings-menu-button svg {
  width: 20px;
  height: 20px;
}

/* Device Settings Modal */
.device-settings-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.device-settings-modal {
  background-color: #242526;
  border-radius: 12px;
  padding: 0;
  max-width: 90%;
  max-height: 80%;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.device-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background-color: #18191a;
  border-bottom: 1px solid #3a3b3c;
}

.device-settings-header h2 {
  margin: 0;
  font-size: 18px;
  color: white;
}

.device-settings-content {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.device-setting-group {
  margin-bottom: 20px;
}

.device-setting-group label {
  display: block;
  color: #e0e0e0;
  font-size: 14px;
  margin-bottom: 8px;
  font-weight: 500;
}

.device-selector-modal {
  width: 100%;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #555;
  background-color: white;
  color: black;
  font-size: 14px;
}

.ios-speaker-note {
  color: #888;
  font-style: italic;
  font-size: 12px;
  margin: 0;
  padding: 8px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Desktop Device Selector */
.desktop-device-selector {
  display: block;
}

/* Mobile elements are shown by default, hidden on desktop */
@media (min-width: 600px) {
  .mobile-only-grid-toggle {
    display: none !important;
  }
  
  .mobile-only-device-settings {
    display: none !important;
  }
}

/* Mobile Device Selector Hiding */
@media (max-width: 600px) {
  .desktop-device-selector {
    display: none !important;
  }
  
  .device-settings-menu-button {
    bottom: 8px;
    left: 8px;
    width: 36px;
    height: 36px;
  }
  
  .device-settings-menu-button svg {
    width: 18px;
    height: 18px;
  }
  
  /* Mobile Device Settings Modal - Full Screen */
  .device-settings-modal-overlay {
    visibility: visible !important;
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: #242526 !important;
    color: white !important;
    transition: transform 0.3s ease !important;
    z-index: 1000 !important;
    overflow-y: auto !important;
    transform: translateX(100%) !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  .device-settings-modal-overlay.visible {
    transform: translateX(0) !important;
    visibility: visible !important;
  }
  
  .device-settings-modal {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  
  .device-settings-header {
    padding: 20px !important;
    background-color: #18191a !important;
    border-bottom: 2px solid #3a3b3c !important;
  }
  
  .device-settings-header h2 {
    font-size: 20px !important;
    font-weight: 600 !important;
  }
  
  .device-settings-content {
    padding: 20px !important;
    max-height: none !important;
  }
  
  .device-setting-group {
    margin-bottom: 25px !important;
    padding: 15px !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-radius: 8px !important;
  }
  
  .device-selector-modal {
    font-size: 16px !important;
    padding: 15px !important;
  }
}

/* Connection LED Indicator */
.connection-led {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  z-index: 5;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.connection-led.connected {
  background-color: #4CAF50;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.connection-led.connecting {
  background-color: #FF9800;
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* Mobile adjustments for LED */
@media (max-width: 600px) {
  .connection-led {
    width: 10px;
    height: 10px;
    top: 6px;
    right: 6px;
  }
}

