/* Hand Toggle Switch */
#handToggleBtn {
  position: relative;
  display: inline-block;
  width: 170px;
  height: 36px;
  background: #e0e0e0;
  border: 1px solid #bbb;
  border-radius: 18px;
  transition: background 0.2s;
  font-size: 1em;
  color: #333;
  font-weight: bold;
  outline: none;
  cursor: pointer;
  padding: 0;
  margin-right: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

#handToggleBtn.toggle-left {
  background: #b3d1ff;
  color: #003366;
}

#handToggleBtn.toggle-right {
  background: #fbd1a2;
  color: #7a4c00;
}

#handToggleBtn::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 10px;
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  transition: left 0.2s;
}

#handToggleBtn.toggle-left::before {
  left: 10px;
}
#handToggleBtn.toggle-right::before {
  left: 132px;
}
/* Responsive Rhythm Generator Styles */

body {
  font-family: Arial, sans-serif;
  padding: 20px;
  text-align: center;
  background-color: #f9f9f9;
  margin: 0;
}

h2 {
  margin-bottom: 20px;
  text-align: center;
  color: #333;
}

/* Dual Pattern Tables */
.tables-container {
  display: flex;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.table-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.table-label {
  font-weight: bold;
  margin-bottom: 10px;
  color: #555;
}

.table-wrapper {
  overflow-x: auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

/* Dynamic Tables */
table {
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.8em;
  width: 100%;
}

th,
td {
  border: 1px solid #999;
  padding: 6px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dynamic-table {
  width: auto;
  display: inline-table;
}

.dynamic-table th,
.dynamic-table td {
  width: 30px;
  min-width: 30px;
  max-width: 30px;
  height: 20px;
}

.dynamic-table tr {
  height: 20px;
}

#dataRow1 td,
#dataRow2 td {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#dataRow1 td:hover,
#dataRow2 td:hover {
  background-color: #e0e0e0;
}

td[contenteditable="true"] {
  background-color: #fff8dc;
}

/* Column Controls */
.column-buttons {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.column-buttons button {
  height: 25px;
  line-height: 20px;
  padding: 0;
  width: 15px;
  margin: 0;
  background-color: #007acc;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-weight: bold;
}

.column-buttons button:hover {
  background-color: #005fa3;
}

/* Form Controls */
/* Form layout: horizontal label/input, autowidth label, consistent input height */
.form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-start;
  max-width: 800px;
  margin: 0 auto 30px auto;
}

.form-group {
  display: flex;
  align-items: center;
  margin-bottom: 0;
  flex-direction: row;
  gap: 4px;
}

.form-group label {
  width: auto;
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  font-weight: bold;
  font-size: 1em;
  margin-right: 8px;
  margin-bottom: 0;
  color: #333;
  white-space: nowrap;
}

input[type="number"],
input[type="color"] {
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1.1em;
  height: 32px;
  box-sizing: border-box;
  vertical-align: middle;
  width: 70px;
}

input[type="checkbox"] {
  margin-right: 8px;
  transform: scale(1.2);
  vertical-align: middle;
}

input[type="number"]:focus,
input[type="color"]:focus {
  outline: none;
  border-color: #007acc;
  box-shadow: 0 0 5px rgba(0, 122, 204, 0.3);
}

/* Action Buttons */
button.generate {
  padding: 10px 20px;
  font-size: 1em;
  background-color: #007acc;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin: 5px;
  transition: background-color 0.2s ease;
}

button.generate:hover {
  background-color: #005fa3;
}

button.generate:active {
  background-color: #004282;
}

/* Metronome Toggle */
.metronome-toggle {
  background-color: #f7f7f7;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 12px;
  margin: 15px auto;
  text-align: center;
}

.metronome-toggle label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: normal;
  margin: 0;
  cursor: pointer;
}

/* Highlighting Toggles Container */
.highlighting-toggles {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin: 10px auto;
}

/* Grid Container */
#gridContainer {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

#gridContainer table {
  width: 100%;
}

#gridContainer th,
#gridContainer td {
  width: auto;
  min-width: 20px;
  max-width: none;
}

td.placeholder {
  background-color: #f5f5f5;
}

/* Metronome Highlight */
.metronome-highlight {
  outline: 2px solid red !important;
  animation: pulse 0.1s ease-in-out;
}

/* Beat-level highlight - creates border around group of cells */
.beat-highlight-start {
  border-left: 3px solid #007acc !important;
  border-top: 3px solid #007acc !important;
  border-bottom: 3px solid #007acc !important;
}

.beat-highlight-middle {
  border-top: 3px solid #007acc !important;
  border-bottom: 3px solid #007acc !important;
}

.beat-highlight-end {
  border-right: 3px solid #007acc !important;
  border-top: 3px solid #007acc !important;
  border-bottom: 3px solid #007acc !important;
}

.beat-highlight-single {
  border: 3px solid #007acc !important;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Sound Test Buttons */
.sound-test-container {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sound-button {
  padding: 10px 20px;
  font-size: 1em;
  background-color: #007acc;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.sound-button:hover {
  background-color: #005fa3;
}

.sound-button:active {
  background-color: #004282;
  transform: scale(0.98);
}

/* Responsive Design */
@media (max-width: 768px) {
  .tables-container {
    flex-direction: column;
    gap: 20px;
  }
  .form-grid {
    flex-direction: column;
    gap: 6px;
    max-width: 400px;
  }
  .form-group {
    margin-bottom: 6px;
    flex-direction: row;
    gap: 4px;
  }
  .form-group label {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
  }
  input[type="number"],
  input[type="color"] {
    width: 65px;
  }
  .sound-test-container {
    flex-direction: column;
    align-items: center;
  }
  .sound-button {
    width: 200px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }
  
  .form-grid {
    max-width: 300px;
  }
  
  .tables-container {
    gap: 15px;
  }
}
