* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #333;
  padding: 20px;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

header {
  text-align: center;
  color: white;
  margin-bottom: 30px;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
  font-size: 1.1rem;
  opacity: 0.9;
}

main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.card h2 {
  color: #667eea;
  margin-bottom: 20px;
  font-size: 1.8rem;
  border-bottom: 2px solid #667eea;
  padding-bottom: 10px;
}

.card h3 {
  color: #555;
  margin: 20px 0 10px 0;
  font-size: 1.2rem;
}

/* Formularios */
.input-group {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-group label {
  font-weight: bold;
  min-width: 120px;
}

.form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

/* Rangos de LED */
#rangesList {
  margin: 15px 0;
  padding: 15px;
  background: #f7fafc;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
}

#rangesList h4 {
  color: #555;
  margin-bottom: 10px;
  font-size: 1rem;
}

#rangesContainer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.range-input {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: white;
  border-radius: 6px;
  border: 1px solid #cbd5e0;
}

.range-input input {
  flex: 1;
  min-width: 80px;
}

input[type="text"],
input[type="number"],
select {
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: #667eea;
}

input[type="number"] {
  width: 100px;
}

/* Botones */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 600;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.btn-success {
  background: #48bb78;
  color: white;
  font-size: 1.1rem;
}

.btn-success:hover {
  background: #38a169;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(72, 187, 120, 0.3);
}

.btn-secondary {
  background: #718096;
  color: white;
}

.btn-secondary:hover {
  background: #4a5568;
}

.btn-danger {
  background: #f56565;
  color: white;
}

.btn-danger:hover {
  background: #e53e3e;
}

.btn-small {
  padding: 5px 10px;
  font-size: 0.9rem;
}

/* Listas */
.segments-list,
.sequences-list {
  margin-top: 10px;
}

.segment-item,
.sequence-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  margin-bottom: 10px;
  background: #f7fafc;
  border-radius: 8px;
  border-left: 4px solid #667eea;
  transition: transform 0.2s;
}

.segment-item:hover,
.sequence-item:hover {
  transform: translateX(5px);
  background: #edf2f7;
}

.segment-actions,
.sequence-actions {
  display: flex;
  gap: 8px;
}

/* Visualización LED Strip */
.led-strip {
  margin-top: 20px;
}

.led-strip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 20px;
  background: #2d3748;
  border-radius: 8px;
  justify-content: center;
}

.led {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: transform 0.2s;
}

.led:hover {
  transform: scale(1.2);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 2px solid #eee;
  position: sticky;
  top: 0;
  background: white;
  z-index: 10;
}

.modal-header h2 {
  color: #667eea;
  margin: 0;
}

.close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #999;
  transition: color 0.3s;
}

.close-btn:hover {
  color: #333;
}

.modal-body {
  padding: 20px;
}

/* Frames */
.frame-item {
  background: #f7fafc;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
  border: 2px solid #e2e8f0;
}

.frame-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  cursor: pointer;
  user-select: none;
  padding: 10px;
  background: white;
  border-radius: 6px;
  transition: background 0.2s;
}

.frame-header:hover {
  background: #f0f0f0;
}

.frame-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.frame-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-toggle {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: #667eea;
  padding: 0;
  width: 20px;
  transition: transform 0.2s;
}

.frame-content {
  padding: 10px 0;
}

/* Edición en lote de frames */
.bulk-edit-section {
  background: #e6f3ff;
  border: 2px solid #667eea;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
}

.bulk-edit-header h4 {
  color: #667eea;
  margin: 0 0 10px 0;
  font-size: 1.1rem;
}

.bulk-edit-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bulk-edit-controls label {
  font-weight: bold;
  color: #333;
}

.bulk-edit-controls input[type="number"] {
  width: 120px;
}

.frames-select-all {
  background: #f7fafc;
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 15px;
  border: 1px solid #e2e8f0;
}

.frames-select-all label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
  color: #555;
}

.frames-expand-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  justify-content: center;
}

.frames-expand-controls .btn {
  flex: 1;
  max-width: 200px;
}

.frame-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin-right: 8px;
}

.frame-header h4 {
  color: #667eea;
  font-size: 1.2rem;
  margin: 0;
}

.frame-duration {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.frame-actions h5 {
  color: #555;
  margin-bottom: 10px;
}

.action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px;
  background: white;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.action-item select {
  flex: 0 0 100px;
}

.color-inputs {
  display: flex;
  gap: 5px;
  align-items: center;
}

.color-inputs input[type="number"] {
  width: 60px;
}

.color-picker {
  width: 50px;
  height: 40px;
  border: 2px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  padding: 2px;
  transition: transform 0.2s;
}

.color-picker:hover {
  transform: scale(1.05);
  border-color: #667eea;
}

.color-preview {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 2px solid #ddd;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Acciones principales */
.actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

#statusMessage {
  font-weight: bold;
  padding: 10px 20px;
  border-radius: 6px;
  transition: all 0.3s;
}

#statusMessage.success {
  background: #c6f6d5;
  color: #22543d;
}

#statusMessage.error {
  background: #fed7d7;
  color: #742a2a;
}

.empty {
  color: #999;
  font-style: italic;
  text-align: center;
  padding: 20px;
}

/* Simulador */
.simulator-controls {
  margin-bottom: 20px;
}

.simulator-controls .form-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  margin-bottom: 15px;
  gap: 10px;
  overflow-x: auto;
}

.simulator-controls label {
  font-weight: bold;
  margin-right: 10px;
}

.simulator-controls select {
  flex: 1;
  min-width: 180px;
  max-width: 300px;
}

.simulator-info {
  display: flex;
  gap: 20px;
  padding: 15px;
  background: #f7fafc;
  border-radius: 8px;
  margin-top: 15px;
  font-weight: bold;
}

.simulator-info span {
  padding: 8px 15px;
  border-radius: 6px;
  background: white;
  border: 2px solid #e2e8f0;
}

.status-playing {
  background: #c6f6d5 !important;
  color: #22543d !important;
  border-color: #48bb78 !important;
}

.status-paused {
  background: #feebc8 !important;
  color: #7c2d12 !important;
  border-color: #f59e0b !important;
}

.simulator-controls-row {
  display: flex;
  gap: 15px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.simulator-controls-row > div {
  flex: 1;
  min-width: 300px;
}

.simulator-speed-control {
  margin-top: 0;
  padding: 15px;
  background: #f0f4ff;
  border-radius: 8px;
  border: 2px solid #667eea;
}

.speed-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  font-weight: 600;
  color: #667eea;
}

.speed-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.speed-slider-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.speed-slider-container label {
  font-weight: 600;
  color: #555;
  font-size: 0.9rem;
}

.speed-slider-container #speedOverrideValue {
  color: #667eea;
  font-weight: 700;
}

.speed-slider-container input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #ddd;
  outline: none;
  -webkit-appearance: none;
}

.speed-slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  transition: background 0.3s;
}

.speed-slider-container input[type="range"]::-webkit-slider-thumb:hover {
  background: #5568d3;
}

.speed-slider-container input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  border: none;
  transition: background 0.3s;
}

.speed-slider-container input[type="range"]::-moz-range-thumb:hover {
  background: #5568d3;
}

.speed-slider-container input[type="range"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.simulator-palette-control {
  margin-top: 0;
  padding: 15px;
  background: #fff5f5;
  border-radius: 8px;
  border: 2px solid #f56565;
}

.palette-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  font-weight: 600;
  color: #c53030;
}

.palette-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.color-shift-slider-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-shift-slider-container label {
  font-weight: 600;
  color: #555;
  font-size: 0.9rem;
}

.color-shift-slider-container #colorShiftDegrees {
  color: #c53030;
  font-weight: 700;
}

.color-shift-slider-container input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, 
    rgb(255, 0, 0) 0%, 
    rgb(255, 255, 0) 16.67%, 
    rgb(0, 255, 0) 33.33%, 
    rgb(0, 255, 255) 50%, 
    rgb(0, 0, 255) 66.67%, 
    rgb(255, 0, 255) 83.33%, 
    rgb(255, 0, 0) 100%);
  outline: none;
  -webkit-appearance: none;
}

.color-shift-slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid #c53030;
  cursor: pointer;
  transition: transform 0.2s;
}

.color-shift-slider-container input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.color-shift-slider-container input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid #c53030;
  cursor: pointer;
  transition: transform 0.2s;
}

.color-shift-slider-container input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.2);
}

.color-shift-slider-container input[type="range"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.simulator-strip {
  margin-top: 20px;
}

.simulator-playback-actions {
  display: flex;
  gap: 10px;
}

.simulator-send-btn {
  display: none;
}

body.page-dispositivos .simulator-advanced-controls,
body.page-dispositivos .simulator-realtime-section {
  display: none;
}

body.page-dispositivos .simulator-info {
  display: none;
}

body.page-dispositivos .simulator-playback-actions {
  display: none;
}

body.page-dispositivos .simulator-send-btn {
  display: inline-block;
}

body.page-dispositivos .simulator-send-btn.queue-limit-reached,
body.page-dispositivos .simulator-send-btn.queue-limit-reached:disabled {
  background: #ecc94b;
  color: #1a202c;
  opacity: 1;
  cursor: not-allowed;
}

body.page-dispositivos .simulator-send-btn.queue-limit-reached:hover,
body.page-dispositivos .simulator-send-btn.queue-limit-reached:disabled:hover {
  background: #d69e2e;
  transform: none;
  box-shadow: none;
}

.simulator-container {
  background: #1a202c !important;
  padding: 30px 20px !important;
}

.simulator-svg {
  margin-top: 30px;
}

#svgContainer {
  background: #000000;
  padding: 20px;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 150px;
}

#svgContainer svg {
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
  background: transparent;
}

/* Dispositivos */
.devices-table-wrapper {
  overflow-x: auto;
}

.devices-table {
  width: 100%;
  border-collapse: collapse;
  background: #f7fafc;
  border-radius: 8px;
  overflow: hidden;
}

.devices-table th,
.devices-table td {
  text-align: left;
  padding: 14px;
  border-bottom: 1px solid #e2e8f0;
}

.devices-table th {
  background: #edf2f7;
  color: #4a5568;
  font-weight: 700;
}

.devices-table tbody tr:last-child td {
  border-bottom: none;
}

.status-badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}

.status-active {
  background: #c6f6d5;
  color: #22543d;
}

.status-inactive {
  background: #fed7d7;
  color: #742a2a;
}

.device-sequence-btn:disabled {
  background: #a0aec0;
  cursor: not-allowed;
  opacity: 0.75;
}

.device-sequence-btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

.sequence-queue-table th:last-child,
.sequence-queue-table td:last-child {
  width: 90px;
  text-align: center;
}

.queue-delete-btn {
  min-width: 42px;
  padding: 8px 10px;
}

.queue-delete-btn:disabled {
  background: #a0aec0;
  color: #edf2f7;
  cursor: not-allowed;
  opacity: 0.8;
}

.queue-delete-btn:disabled:hover {
  background: #a0aec0;
  transform: none;
  box-shadow: none;
}

/* Frame SVG Preview */
.frame-svg-preview {
  margin-top: 15px;
  padding: 15px;
  background: #000000;
  border-radius: 8px;
  border: 2px solid #667eea;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
}

.frame-svg-preview svg {
  max-width: 200px;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.frame-svg-preview svg path {
  cursor: pointer;
  transition: opacity 0.2s;
}

.frame-svg-preview svg path:hover {
  opacity: 0.7;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 12px;
    font-size: 14px;
  }

  header h1 {
    font-size: 1.6rem;
  }

  header p {
    font-size: 0.95rem;
  }

  .card {
    padding: 16px;
  }

  .card h2 {
    font-size: 1.35rem;
  }

  .card h3 {
    font-size: 1.05rem;
  }

  .btn {
    font-size: 0.9rem;
    padding: 8px 14px;
  }

  .btn-small {
    font-size: 0.8rem;
    padding: 5px 8px;
  }

  input[type="text"],
  input[type="number"],
  select {
    font-size: 0.9rem;
    padding: 8px;
  }

  .devices-table th,
  .devices-table td {
    padding: 10px;
    font-size: 0.9rem;
  }

  .status-badge {
    font-size: 0.8rem;
  }

  .form-row {
    flex-direction: column;
  }

  .simulator-controls .form-row {
    flex-direction: row;
    flex-wrap: nowrap;
  }

  input[type="text"],
  input[type="number"] {
    width: 100%;
  }

  .segment-item,
  .sequence-item {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .action-item {
    flex-wrap: wrap;
  }

  .actions {
    flex-direction: column;
  }

  .led-strip-container {
    gap: 5px;
  }

  .led {
    width: 30px;
    height: 30px;
    font-size: 0.7rem;
  }
}
